diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-08-09 08:07:16 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-08-09 08:07:28 -0400 |
commit | 8ac7125d59ce874d2bc37f5a8dddcc42fc2b5780 (patch) | |
tree | dfb375153e79693bea6ae89922e7561f3d3229db /test/functional | |
parent | 8eb987005288e9c13d46b2f6b5bf5c3aaddd8b06 (diff) | |
parent | fa5587fe71ce041dc69cb0d46697975bb51ef1f6 (diff) |
Merge #13916: qa: wait_for_verack by default
fa5587fe71 qa: wait_for_verack by default (MarcoFalke)
Pull request description:
This removes the need to do so manually every time a connection is added.
Tree-SHA512: a46c92cb4df41e30778b42b9fd3dcbd8d2d82aa7503d1213cb1c1165034f648d8caee01c292e2d87d05b0f71696996eef5be8a753f35ab49e5f66b0e3bf29f21
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/example_test.py | 6 | ||||
-rwxr-xr-x | test/functional/feature_assumevalid.py | 7 | ||||
-rwxr-xr-x | test/functional/feature_cltv.py | 1 | ||||
-rwxr-xr-x | test/functional/feature_csv_activation.py | 1 | ||||
-rwxr-xr-x | test/functional/feature_dersig.py | 3 | ||||
-rwxr-xr-x | test/functional/feature_maxuploadtarget.py | 6 | ||||
-rwxr-xr-x | test/functional/feature_versionbits_warning.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_compactblocks.py | 4 | ||||
-rwxr-xr-x | test/functional/p2p_feefilter.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_fingerprint.py | 1 | ||||
-rwxr-xr-x | test/functional/p2p_invalid_block.py | 1 | ||||
-rwxr-xr-x | test/functional/p2p_invalid_tx.py | 1 | ||||
-rwxr-xr-x | test/functional/p2p_leak.py | 6 | ||||
-rwxr-xr-x | test/functional/p2p_mempool.py | 1 | ||||
-rwxr-xr-x | test/functional/p2p_node_network_limited.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_segwit.py | 3 | ||||
-rwxr-xr-x | test/functional/p2p_sendheaders.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_timeouts.py | 4 | ||||
-rwxr-xr-x | test/functional/p2p_unrequested_blocks.py | 4 | ||||
-rwxr-xr-x | test/functional/rpc_blockchain.py | 4 | ||||
-rwxr-xr-x | test/functional/test_framework/test_node.py | 6 |
21 files changed, 11 insertions, 56 deletions
diff --git a/test/functional/example_test.py b/test/functional/example_test.py index b0fb0d47f5..714d977380 100755 --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -130,12 +130,9 @@ class ExampleTest(BitcoinTestFramework): def run_test(self): """Main test logic""" - # Create P2P connections to two of the nodes + # Create P2P connections will wait for a verack to make sure the connection is fully up self.nodes[0].add_p2p_connection(BaseNode()) - # wait_for_verack ensures that the P2P connection is fully up. - self.nodes[0].p2p.wait_for_verack() - # Generating a block on one of the nodes will get us out of IBD blocks = [int(self.nodes[0].generate(nblocks=1)[0], 16)] self.sync_all([self.nodes[0:1]]) @@ -187,7 +184,6 @@ class ExampleTest(BitcoinTestFramework): self.nodes[0].disconnect_p2ps() self.nodes[2].add_p2p_connection(BaseNode()) - self.nodes[2].p2p.wait_for_verack() self.log.info("Wait for node2 reach current tip. Test that it has propagated all the blocks to us") diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py index 960ca5a212..3d0467038d 100755 --- a/test/functional/feature_assumevalid.py +++ b/test/functional/feature_assumevalid.py @@ -95,10 +95,7 @@ class AssumeValidTest(BitcoinTestFramework): break def run_test(self): - - # Connect to node0 p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) - self.nodes[0].p2p.wait_for_verack() # Build the blockchain self.tip = int(self.nodes[0].getbestblockhash(), 16) @@ -168,10 +165,6 @@ class AssumeValidTest(BitcoinTestFramework): p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) p2p2 = self.nodes[2].add_p2p_connection(BaseNode()) - p2p0.wait_for_verack() - p2p1.wait_for_verack() - p2p2.wait_for_verack() - # send header lists to all three nodes p2p0.send_header_for_blocks(self.blocks[0:2000]) p2p0.send_header_for_blocks(self.blocks[2000:]) diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py index 7a106ea3d0..ca35def3ce 100755 --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -67,7 +67,6 @@ class BIP65Test(BitcoinTestFramework): def run_test(self): self.nodes[0].add_p2p_connection(P2PInterface()) - self.nodes[0].p2p.wait_for_verack() self.log.info("Mining %d blocks", CLTV_HEIGHT - 2) self.coinbase_blocks = self.nodes[0].generate(CLTV_HEIGHT - 2) diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py index 6199b753be..56d2ac463d 100755 --- a/test/functional/feature_csv_activation.py +++ b/test/functional/feature_csv_activation.py @@ -183,7 +183,6 @@ class BIP68_112_113Test(BitcoinTestFramework): def run_test(self): self.nodes[0].add_p2p_connection(P2PDataStore()) - self.nodes[0].p2p.wait_for_verack() self.log.info("Generate blocks in the past for coinbase outputs.") long_past_time = int(time.time()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py index 1848ea99c0..5b46b4d4b4 100755 --- a/test/functional/feature_dersig.py +++ b/test/functional/feature_dersig.py @@ -57,9 +57,6 @@ class BIP66Test(BitcoinTestFramework): def run_test(self): self.nodes[0].add_p2p_connection(P2PInterface()) - # wait_for_verack ensures that the P2P connection is fully up. - self.nodes[0].p2p.wait_for_verack() - self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2) self.coinbase_blocks = self.nodes[0].generate(DERSIG_HEIGHT - 2) self.nodeaddress = self.nodes[0].getnewaddress() diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py index 2803efd346..88282e9fac 100755 --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -57,11 +57,6 @@ class MaxUploadTest(BitcoinTestFramework): for _ in range(3): p2p_conns.append(self.nodes[0].add_p2p_connection(TestP2PConn())) - for p2pc in p2p_conns: - p2pc.wait_for_verack() - - # Test logic begins here - # Now mine a big block mine_large_block(self.nodes[0], self.utxo_cache) @@ -147,7 +142,6 @@ class MaxUploadTest(BitcoinTestFramework): # Reconnect to self.nodes[0] self.nodes[0].add_p2p_connection(TestP2PConn()) - self.nodes[0].p2p.wait_for_verack() #retrieve 20 blocks which should be enough to break the 1MB limit getdata_request.inv = [CInv(2, big_new_block)] diff --git a/test/functional/feature_versionbits_warning.py b/test/functional/feature_versionbits_warning.py index 590b31d350..896c36fa53 100755 --- a/test/functional/feature_versionbits_warning.py +++ b/test/functional/feature_versionbits_warning.py @@ -62,10 +62,8 @@ class VersionBitsWarningTest(BitcoinTestFramework): return VB_PATTERN.search(alert_text) is not None def run_test(self): - # Handy alias node = self.nodes[0] node.add_p2p_connection(P2PInterface()) - node.p2p.wait_for_verack() # Mine one period worth of blocks node.generate(VB_PERIOD) diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index 8f3a938856..334e4048d2 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -790,11 +790,9 @@ class CompactBlocksTest(BitcoinTestFramework): def run_test(self): # Setup the p2p connections self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) - self.segwit_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK|NODE_WITNESS) + self.segwit_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK | NODE_WITNESS) self.old_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK) - self.test_node.wait_for_verack() - # We will need UTXOs to construct transactions in later tests. self.make_utxos() diff --git a/test/functional/p2p_feefilter.py b/test/functional/p2p_feefilter.py index a6eec8d117..c348202245 100755 --- a/test/functional/p2p_feefilter.py +++ b/test/functional/p2p_feefilter.py @@ -47,9 +47,7 @@ class FeeFilterTest(BitcoinTestFramework): node1.generate(1) sync_blocks(self.nodes) - # Setup the p2p connections self.nodes[0].add_p2p_connection(TestP2PConn()) - self.nodes[0].p2p.wait_for_verack() # Test that invs are received for all txs at feerate of 20 sat/byte node1.settxfee(Decimal("0.00020000")) diff --git a/test/functional/p2p_fingerprint.py b/test/functional/p2p_fingerprint.py index 5763057d23..7cb22ad940 100755 --- a/test/functional/p2p_fingerprint.py +++ b/test/functional/p2p_fingerprint.py @@ -75,7 +75,6 @@ class P2PFingerprintTest(BitcoinTestFramework): # last month but that have over a month's worth of work are also withheld. def run_test(self): node0 = self.nodes[0].add_p2p_connection(P2PInterface()) - node0.wait_for_verack() # Set node time to 60 days ago self.nodes[0].setmocktime(int(time.time()) - 60 * 24 * 60 * 60) diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index 7c02abffec..b14270cb96 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -28,7 +28,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework): # Add p2p connection to node0 node = self.nodes[0] # convenience reference to the node node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() best_block = node.getblock(node.getbestblockhash()) tip = int(node.getbestblockhash(), 16) diff --git a/test/functional/p2p_invalid_tx.py b/test/functional/p2p_invalid_tx.py index 16c4b1b407..8236cdf89b 100755 --- a/test/functional/p2p_invalid_tx.py +++ b/test/functional/p2p_invalid_tx.py @@ -32,7 +32,6 @@ class InvalidTxRequestTest(BitcoinTestFramework): Helper to connect and wait for version handshake.""" for _ in range(num_connections): self.nodes[0].add_p2p_connection(P2PDataStore()) - self.nodes[0].p2p.wait_for_verack() def reconnect_p2p(self, **kwargs): """Tear down and bootstrap the P2P connection to the node. diff --git a/test/functional/p2p_leak.py b/test/functional/p2p_leak.py index 44a7b60604..058d0025c2 100755 --- a/test/functional/p2p_leak.py +++ b/test/functional/p2p_leak.py @@ -88,11 +88,11 @@ class CNodeNoVerackIdle(CLazyNode): class P2PLeakTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.extra_args = [['-banscore='+str(banscore)]] + self.extra_args = [['-banscore=' + str(banscore)]] def run_test(self): - no_version_bannode = self.nodes[0].add_p2p_connection(CNodeNoVersionBan(), send_version=False) - no_version_idlenode = self.nodes[0].add_p2p_connection(CNodeNoVersionIdle(), send_version=False) + no_version_bannode = self.nodes[0].add_p2p_connection(CNodeNoVersionBan(), send_version=False, wait_for_verack=False) + no_version_idlenode = self.nodes[0].add_p2p_connection(CNodeNoVersionIdle(), send_version=False, wait_for_verack=False) no_verack_idlenode = self.nodes[0].add_p2p_connection(CNodeNoVerackIdle()) wait_until(lambda: no_version_bannode.ever_connected, timeout=10, lock=mininode_lock) diff --git a/test/functional/p2p_mempool.py b/test/functional/p2p_mempool.py index d43ab2146f..bdf51778ef 100755 --- a/test/functional/p2p_mempool.py +++ b/test/functional/p2p_mempool.py @@ -21,7 +21,6 @@ class P2PMempoolTests(BitcoinTestFramework): def run_test(self): # Add a p2p connection self.nodes[0].add_p2p_connection(P2PInterface()) - self.nodes[0].p2p.wait_for_verack() #request mempool self.nodes[0].p2p.send_message(msg_mempool()) diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py index ab0a7429b5..0e20b95565 100755 --- a/test/functional/p2p_node_network_limited.py +++ b/test/functional/p2p_node_network_limited.py @@ -48,7 +48,6 @@ class NodeNetworkLimitedTest(BitcoinTestFramework): def run_test(self): node = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) - node.wait_for_verack() expected_services = NODE_BLOOM | NODE_WITNESS | NODE_NETWORK_LIMITED @@ -74,7 +73,6 @@ class NodeNetworkLimitedTest(BitcoinTestFramework): self.log.info("Check local address relay, do a fresh connection.") self.nodes[0].disconnect_p2ps() node1 = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) - node1.wait_for_verack() node1.send_message(msg_verack()) node1.wait_for_addr() diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 5ffc736c97..be79a13237 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -231,9 +231,6 @@ class SegWitTest(BitcoinTestFramework): # self.std_node is for testing node1 (fRequireStandard=true) self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK | NODE_WITNESS) - for conn in (self.test_node, self.old_node, self.std_node): - conn.wait_for_verack() - assert self.test_node.nServices & NODE_WITNESS != 0 # Keep a place to store utxo's that can be used in later tests diff --git a/test/functional/p2p_sendheaders.py b/test/functional/p2p_sendheaders.py index 3d1b681a96..7c987b171c 100755 --- a/test/functional/p2p_sendheaders.py +++ b/test/functional/p2p_sendheaders.py @@ -242,8 +242,6 @@ class SendHeadersTest(BitcoinTestFramework): # Make sure NODE_NETWORK is not set for test_node, so no block download # will occur outside of direct fetching test_node = self.nodes[0].add_p2p_connection(BaseNode(), services=NODE_WITNESS) - inv_node.wait_for_verack() - test_node.wait_for_verack() # Ensure verack's have been processed by our peer inv_node.sync_with_ping() diff --git a/test/functional/p2p_timeouts.py b/test/functional/p2p_timeouts.py index 52f9e3f3cc..788f80cc44 100755 --- a/test/functional/p2p_timeouts.py +++ b/test/functional/p2p_timeouts.py @@ -40,8 +40,8 @@ class TimeoutsTest(BitcoinTestFramework): def run_test(self): # Setup the p2p connections no_verack_node = self.nodes[0].add_p2p_connection(TestP2PConn()) - no_version_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False) - no_send_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False) + no_version_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False, wait_for_verack=False) + no_send_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False, wait_for_verack=False) sleep(1) diff --git a/test/functional/p2p_unrequested_blocks.py b/test/functional/p2p_unrequested_blocks.py index 0c5d8f3a3f..04a81b0be5 100755 --- a/test/functional/p2p_unrequested_blocks.py +++ b/test/functional/p2p_unrequested_blocks.py @@ -78,8 +78,6 @@ class AcceptBlockTest(BitcoinTestFramework): test_node = self.nodes[0].add_p2p_connection(P2PInterface()) # min_work_node connects to node1 (whitelisted) min_work_node = self.nodes[1].add_p2p_connection(P2PInterface()) - test_node.wait_for_verack() - min_work_node.wait_for_verack() # 1. Have nodes mine a block (leave IBD) [ n.generate(1) for n in self.nodes ] @@ -202,7 +200,6 @@ class AcceptBlockTest(BitcoinTestFramework): self.nodes[1].disconnect_p2ps() test_node = self.nodes[0].add_p2p_connection(P2PInterface()) - test_node.wait_for_verack() test_node.send_message(msg_block(block_h1f)) @@ -287,7 +284,6 @@ class AcceptBlockTest(BitcoinTestFramework): self.nodes[0].disconnect_p2ps() test_node = self.nodes[0].add_p2p_connection(P2PInterface()) - test_node.wait_for_verack() # We should have failed reorg and switched back to 290 (but have block 291) assert_equal(self.nodes[0].getblockcount(), 290) diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index e8c4923105..49f44b0c6d 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -256,12 +256,8 @@ class BlockchainTest(BitcoinTestFramework): def _test_waitforblockheight(self): self.log.info("Test waitforblockheight") - node = self.nodes[0] - - # Start a P2P connection since we'll need to create some blocks. node.add_p2p_connection(P2PInterface()) - node.p2p.wait_for_verack() current_height = node.getblock(node.getbestblockhash())['height'] diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 7164a9beef..56ea110f16 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -276,7 +276,7 @@ class TestNode(): self.encryptwallet(passphrase) self.wait_until_stopped() - def add_p2p_connection(self, p2p_conn, *args, **kwargs): + def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): """Add a p2p connection to the node. This method adds the p2p connection to the self.p2ps list and also @@ -286,8 +286,10 @@ class TestNode(): if 'dstaddr' not in kwargs: kwargs['dstaddr'] = '127.0.0.1' - p2p_conn.peer_connect(*args, **kwargs)() + p2p_conn.peer_connect(**kwargs)() self.p2ps.append(p2p_conn) + if wait_for_verack: + p2p_conn.wait_for_verack() return p2p_conn |