Merge #11078: [tests] Make p2p-leaktests.py more robust

0063d2c3d [tests] Make p2p-leaktests.py more robust (John Newbery)

Pull request description:

  There has been an example of p2p-leaktests.py failing on travis in the new service bits test (introduced in #11001 . It appeared to me that the previous p2p connections had not been fully disconnected before attempting to add new p2p connections.

  I've added a sleep and restarted the NetworkThread, but I don't know whether this will fix the problem, since I'm unable to reproduce the failure locally.

  @MarcoFalke - not sure what you want to do here? I don't think this change could make things any worse.

Tree-SHA512: f5427c26267185a903c9b75bb3925bf153b8afce70c8e493bf8f585f57d809d20643b4ee69081300b211d22e960242aecc3d719f4ddd230aa08fdc5484b55055
This commit is contained in:
MarcoFalke
2017-09-13 18:54:09 +02:00
2 changed files with 8 additions and 2 deletions

View File

@ -139,6 +139,9 @@ class P2PLeakTest(BitcoinTestFramework):
[conn.disconnect_node() for conn in connections]
# Wait until all connections are closed
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0)
# Make sure no unexpected messages came in
assert(no_version_bannode.unexpected_msg == False)
assert(no_version_idlenode.unexpected_msg == False)
@ -157,8 +160,10 @@ class P2PLeakTest(BitcoinTestFramework):
allowed_service_bit5_node.add_connection(connections[5])
allowed_service_bit7_node.add_connection(connections[6])
wait_until(lambda: allowed_service_bit5_node.message_count["verack"], timeout=10, lock=mininode_lock)
wait_until(lambda: allowed_service_bit7_node.message_count["verack"], timeout=10, lock=mininode_lock)
NetworkThread().start() # Network thread stopped when all previous NodeConnCBs disconnected. Restart it
wait_until(lambda: allowed_service_bit5_node.message_count["verack"], lock=mininode_lock)
wait_until(lambda: allowed_service_bit7_node.message_count["verack"], lock=mininode_lock)
if __name__ == '__main__':
P2PLeakTest().main()