diff options
author | John Newbery <john@johnnewbery.com> | 2017-12-07 13:40:39 -0500 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-12-11 09:17:21 -0500 |
commit | 34e08b3510c64e35fc51327562d15d938f4b656e (patch) | |
tree | c6f09d62e3a5da99daa809c942e7f8bd7c474558 /test/functional/assumevalid.py | |
parent | 74e64f24b8cb701379b34442f21332361dcc91f9 (diff) | |
download | bitcoin-34e08b3510c64e35fc51327562d15d938f4b656e.tar.xz |
[tests] Fix network threading in functional tests
assumevalid.py, example_test.py and p2p-acceptblocks.py add
p2p_connections after the NetworkThread has been started. This isn't
permitted. Fix test to restart the network thread when adding new
connections.
p2p-leaktest.py had a potential race condition if the NetworkThread
hadn't terminated by the time we tried to restart it.
Diffstat (limited to 'test/functional/assumevalid.py')
-rwxr-xr-x | test/functional/assumevalid.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/functional/assumevalid.py b/test/functional/assumevalid.py index 68ff319d12..362b94e0d3 100755 --- a/test/functional/assumevalid.py +++ b/test/functional/assumevalid.py @@ -38,10 +38,11 @@ from test_framework.mininode import (CBlockHeader, CTransaction, CTxIn, CTxOut, + network_thread_join, + network_thread_start, P2PInterface, msg_block, - msg_headers, - network_thread_start) + msg_headers) from test_framework.script import (CScript, OP_TRUE) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal @@ -159,13 +160,22 @@ class AssumeValidTest(BitcoinTestFramework): self.block_time += 1 height += 1 + # We're adding new connections so terminate the network thread + self.nodes[0].disconnect_p2ps() + network_thread_join() + # Start node1 and node2 with assumevalid so they accept a block with a bad signature. self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)]) - p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) - p2p1.wait_for_verack() - self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)]) + + p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) + p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) p2p2 = self.nodes[2].add_p2p_connection(BaseNode()) + + network_thread_start() + + p2p0.wait_for_verack() + p2p1.wait_for_verack() p2p2.wait_for_verack() # send header lists to all three nodes |