Skip to content

Commit

Permalink
Display back confirmations in wot tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Jan 28, 2016
1 parent 35ada03 commit b438efa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/sakia/core/graph/base_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def node_status(self, node_identity, account_identity):
node_status += NodeStatus.OUT
return node_status

async def confirmation_text(self, block_number):
def confirmation_text(self, block_number):
"""
Build confirmation text of an arc
:param int block_number: the block number of the certification
Expand Down Expand Up @@ -107,7 +107,7 @@ async def add_certifier_list(self, certifier_list, identity, account_identity):
QLocale.dateFormat(QLocale(), QLocale.ShortFormat)
),
'cert_time': certifier['cert_time'],
'confirmation_text': (await self.confirmation_text(certifier['cert_time']))
'confirmation_text': self.confirmation_text(certifier['block_number'])
}

self.nx_graph.add_edge(certifier['identity'].pubkey, identity.pubkey, attr_dict=arc, weight=len(certifier_list))
Expand Down Expand Up @@ -145,7 +145,7 @@ async def add_certified_list(self, certified_list, identity, account_identity):
QLocale.dateFormat(QLocale(), QLocale.ShortFormat)
),
'cert_time': certified['cert_time'],
'confirmation_text': (await self.confirmation_text(certified['cert_time']))
'confirmation_text': self.confirmation_text(certified['block_number'])
}

self.nx_graph.add_edge(identity.pubkey, certified['identity'].pubkey, attr_dict=arc,
Expand Down
9 changes: 6 additions & 3 deletions src/sakia/core/net/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ def confirmations(self, block_number):
:return: the number of confirmations of a data
:rtype: int
"""
if block_number > self.current_blockid.number:
raise ValueError("Could not compute confirmations : data block number is after current block")
return self.current_blockid.number - block_number + 1
if block_number:
if block_number > self.current_blockid.number:
raise ValueError("Could not compute confirmations : data block number is after current block")
return self.current_blockid.number - block_number + 1
else:
return 0

def add_node(self, node):
"""
Expand Down
10 changes: 2 additions & 8 deletions src/sakia/tests/unit/core/graph/test_base_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def test_confirmation_text_expert_enabled(self, app, community):

base_graph = BaseGraph(app, community)

async def exec_test():
self.assertEquals((await base_graph.confirmation_text(200)), "2/6")

self.lp.run_until_complete(exec_test())
self.assertEquals(base_graph.confirmation_text(200), "2/6")

@patch('sakia.core.Application')
@patch('sakia.core.Community')
Expand All @@ -89,10 +86,7 @@ def test_confirmation_text_expert_disabled(self, app, community):

base_graph = BaseGraph(app, community)

async def exec_test():
self.assertEquals((await base_graph.confirmation_text(200)), "33 %")

self.lp.run_until_complete(exec_test())
self.assertEquals(base_graph.confirmation_text(200), "33 %")

@patch('sakia.core.Community')
@patch('sakia.core.Application')
Expand Down

0 comments on commit b438efa

Please sign in to comment.