diff --git a/hathor/simulator/fake_connection.py b/hathor/simulator/fake_connection.py index 9db893559..5f7581611 100644 --- a/hathor/simulator/fake_connection.py +++ b/hathor/simulator/fake_connection.py @@ -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: diff --git a/tests/simulation/test_simulator.py b/tests/simulation/test_simulator.py index d39cf81e0..cce6c795b 100644 --- a/tests/simulation/test_simulator.py +++ b/tests/simulation/test_simulator.py @@ -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) @@ -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)