Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hathor/simulator/fake_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ def is_both_synced(self) -> bool:
if not state1_is_synced or not state2_is_synced:
self.log.debug('peer not synced', peer1_synced=state1_is_synced, peer2_synced=state2_is_synced)
return False
[best_block_info1] = state1.protocol.node.tx_storage.get_n_height_tips(1)
[best_block_info2] = state2.protocol.node.tx_storage.get_n_height_tips(1)
if best_block_info1.id != best_block_info2.id:
self.log.debug('best block is different')
return False
tips1 = {i.data for i in state1.protocol.node.tx_storage.get_tx_tips()}
tips2 = {i.data for i in state2.protocol.node.tx_storage.get_tx_tips()}
if tips1 != tips2:
self.log.debug('tx tips are different')
return False
return True

def can_step(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions tests/simulation/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_two_nodes(self):
self.simulator.add_connection(conn12)
self.simulator.run(60)

miner2 = self.simulator.create_miner(manager2, hashpower=100e6)
miner2 = self.simulator.create_miner(manager2, hashpower=10e9)
miner2.start()
self.simulator.run(120)

Expand All @@ -57,7 +57,7 @@ def test_two_nodes(self):
gen_tx1.stop()
gen_tx2.stop()

self.assertTrue(self.simulator.run(600, trigger=StopWhenSynced(conn12)))
self.assertTrue(self.simulator.run(3000, trigger=StopWhenSynced(conn12)))

self.assertTrue(conn12.is_connected)
self.assertTipsEqual(manager1, manager2)
Expand Down