Skip to content
Snippets Groups Projects
Commit 9c16ded0 authored by inso's avatar inso
Browse files

Fix bug in explorer

parent 931c2c7c
No related branches found
No related tags found
No related merge requests found
......@@ -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("")
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment