Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[2].p2p.wait_until( | self.nodes[2].p2p.wait_until( | ||||
lambda: sorted(blocks) == sorted(list( | lambda: sorted(blocks) == sorted(list( | ||||
self.nodes[2].p2p.block_receive_map.keys())), | self.nodes[2].p2p.block_receive_map.keys())), | ||||
timeout=5) | timeout=5) | ||||
self.log.info("Check that each block was received only once") | self.log.info("Check that each block was received only once") | ||||
# The network thread uses a global lock on data access to the P2PConnection objects when sending and receiving | # The network thread uses a global lock on data access to the P2PConnection objects when sending and receiving | ||||
# messages. The test thread should acquire the global lock before accessing any P2PConnection data to avoid locking | # messages. The test thread should acquire the global lock before accessing any P2PConnection data to avoid locking | ||||
# and synchronization issues. Note wait_until() acquires this global | # and synchronization issues. Note p2p.wait_until() acquires this | ||||
# lock when testing the predicate. | # global lock internally when testing the predicate. | ||||
with p2p_lock: | with p2p_lock: | ||||
for block in self.nodes[2].p2p.block_receive_map.values(): | for block in self.nodes[2].p2p.block_receive_map.values(): | ||||
assert_equal(block, 1) | assert_equal(block, 1) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ExampleTest().main() | ExampleTest().main() |