Skip to content

Commit 42973f8

Browse files
author
MarcoFalke
committed
Merge #11078: [tests] Make p2p-leaktests.py more robust
0063d2c [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
2 parents 8df48b3 + 0063d2c commit 42973f8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

test/functional/p2p-leaktests.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ def run_test(self):
139139

140140
[conn.disconnect_node() for conn in connections]
141141

142+
# Wait until all connections are closed
143+
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0)
144+
142145
# Make sure no unexpected messages came in
143146
assert(no_version_bannode.unexpected_msg == False)
144147
assert(no_version_idlenode.unexpected_msg == False)
@@ -157,8 +160,10 @@ def run_test(self):
157160
allowed_service_bit5_node.add_connection(connections[5])
158161
allowed_service_bit7_node.add_connection(connections[6])
159162

160-
wait_until(lambda: allowed_service_bit5_node.message_count["verack"], timeout=10, lock=mininode_lock)
161-
wait_until(lambda: allowed_service_bit7_node.message_count["verack"], timeout=10, lock=mininode_lock)
163+
NetworkThread().start() # Network thread stopped when all previous NodeConnCBs disconnected. Restart it
164+
165+
wait_until(lambda: allowed_service_bit5_node.message_count["verack"], lock=mininode_lock)
166+
wait_until(lambda: allowed_service_bit7_node.message_count["verack"], lock=mininode_lock)
162167

163168
if __name__ == '__main__':
164169
P2PLeakTest().main()

test/functional/test_framework/mininode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ def run(self):
18301830
disconnected.append(obj)
18311831
[ obj.handle_close() for obj in disconnected ]
18321832
asyncore.loop(0.1, use_poll=True, map=mininode_socket_map, count=1)
1833+
logger.debug("Network thread closing")
18331834

18341835

18351836
# An exception we can raise if we detect a potential disconnect

0 commit comments

Comments
 (0)