diff --git a/src/sakia/core/graph/explorer_graph.py b/src/sakia/core/graph/explorer_graph.py index 11c8797978dd6f30382508a0068b694e071d6e6d..af804f5fbc2f2f7beb9d30868f9822aaf27a0156 100644 --- a/src/sakia/core/graph/explorer_graph.py +++ b/src/sakia/core/graph/explorer_graph.py @@ -33,8 +33,8 @@ class ExplorerGraph(BaseGraph): if self.exploration_task: if self.explored_identity is not identity or steps != self.steps: self.exploration_task.cancel() - else: - return + #else: + # return self.nx_graph.clear() self.explored_identity = identity self.steps = steps @@ -69,6 +69,7 @@ class ExplorerGraph(BaseGraph): for step in range(0, steps): while len(explorable[step]) > 0: + current_identity = explorable[step].pop() # for each pubkey connected... if current_identity not in explored: self.current_identity_changed.emit(current_identity.pubkey) @@ -95,5 +96,4 @@ class ExplorerGraph(BaseGraph): explored.append(current_identity) logging.debug("New identity explored : {pubkey}".format(pubkey=current_identity.pubkey[:5])) self.graph_changed.emit() - current_identity = explorable[step].pop() self.current_identity_changed.emit("") diff --git a/src/sakia/tests/unit/core/graph/test_explorer_graph.py b/src/sakia/tests/unit/core/graph/test_explorer_graph.py index 5147f404073f72bf26bb0ee63524843cddcf31a7..035faab3b06da16e604c48779e56c0a8882ad295 100644 --- a/src/sakia/tests/unit/core/graph/test_explorer_graph.py +++ b/src/sakia/tests/unit/core/graph/test_explorer_graph.py @@ -72,7 +72,7 @@ class TestExplorerGraph(unittest.TestCase, QuamashTest): } ]) - self.idC.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certifierd_by', + self.idC.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49100, @@ -123,7 +123,7 @@ class TestExplorerGraph(unittest.TestCase, QuamashTest): @patch('sakia.core.Application') @patch('sakia.core.Community') @patch('time.time', Mock(return_value=50000)) - def test_explore_full(self, app, community): + def test_explore_full_from_center(self, app, community): community.parameters = CoroutineMock(return_value = {'sigValidity': 1000}) community.network.confirmations = Mock(side_effect=lambda n: 4 if 996 else None) app.preferences = {'expert_mode': True} @@ -137,6 +137,23 @@ class TestExplorerGraph(unittest.TestCase, QuamashTest): self.lp.run_until_complete(exec_test()) + @patch('sakia.core.Application') + @patch('sakia.core.Community') + @patch('time.time', Mock(return_value=50000)) + def test_explore_full_from_extremity(self, app, community): + community.parameters = CoroutineMock(return_value = {'sigValidity': 1000}) + community.network.confirmations = Mock(side_effect=lambda n: 4 if 996 else None) + app.preferences = {'expert_mode': True} + + explorer_graph = ExplorerGraph(app, community) + + async def exec_test(): + await explorer_graph._explore(self.idA, 5) + self.assertEqual(len(explorer_graph.nx_graph.nodes()), 5) + self.assertEqual(len(explorer_graph.nx_graph.edges()), 4) + + self.lp.run_until_complete(exec_test()) + @patch('sakia.core.Application') @patch('sakia.core.Community') @patch('time.time', Mock(return_value=50000))