diff --git a/test/functional/abc-invalid-chains.py b/test/functional/abc-invalid-chains.py --- a/test/functional/abc-invalid-chains.py +++ b/test/functional/abc-invalid-chains.py @@ -46,7 +46,6 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() self.genesis_hash = int(node.getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 diff --git a/test/functional/abc-invalid-message.py b/test/functional/abc-invalid-message.py --- a/test/functional/abc-invalid-message.py +++ b/test/functional/abc-invalid-message.py @@ -62,19 +62,18 @@ def run_test(self): # Try to connect to a node using an invalid checksum on version message bad_interface = BadVersionP2PInterface() - self.nodes[0].add_p2p_connection(bad_interface) + self.nodes[0].add_p2p_connection( + bad_interface, send_version=False, wait_for_verack=False) # Also connect to a node with a valid version message interface = P2PInterface() + # Node with valid version message should connect successfully connection = self.nodes[1].add_p2p_connection(interface) # The invalid version message should cause a disconnect on the first # connection because we are now banned bad_interface.wait_for_disconnect() - # Node with valid version message should connect successfully - connection.wait_for_verack() - # Create a valid message valid_message = msg_ping(interface.ping_counter) diff --git a/test/functional/abc-mempool-accept-txn.py b/test/functional/abc-mempool-accept-txn.py --- a/test/functional/abc-mempool-accept-txn.py +++ b/test/functional/abc-mempool-accept-txn.py @@ -143,7 +143,6 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -155,7 +155,6 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() node.setmocktime(ACTIVATION_TIME) self.genesis_hash = int(node.getbestblockhash(), 16) diff --git a/test/functional/abc-minimaldata-activation.py b/test/functional/abc-minimaldata-activation.py --- a/test/functional/abc-minimaldata-activation.py +++ b/test/functional/abc-minimaldata-activation.py @@ -72,7 +72,6 @@ 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/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -226,8 +226,6 @@ node = self.nodes[0] default_p2p = node.add_p2p_connection(P2PDataStore()) test_p2p = node.add_p2p_connection(TestP2PConn()) - default_p2p.wait_for_verack() - test_p2p.wait_for_verack() # Set the blocksize to 2MB as initial condition node.setexcessiveblock(self.excessive_block_size) diff --git a/test/functional/abc-p2p-fullblocktest.py b/test/functional/abc-p2p-fullblocktest.py --- a/test/functional/abc-p2p-fullblocktest.py +++ b/test/functional/abc-p2p-fullblocktest.py @@ -201,7 +201,7 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() + # Set the blocksize to 2MB as initial condition node.setexcessiveblock(self.excessive_block_size) diff --git a/test/functional/abc-replay-protection.py b/test/functional/abc-replay-protection.py --- a/test/functional/abc-replay-protection.py +++ b/test/functional/abc-replay-protection.py @@ -87,7 +87,6 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() node.setmocktime(REPLAY_PROTECTION_START_TIME) self.genesis_hash = int(node.getbestblockhash(), 16) diff --git a/test/functional/abc-schnorr.py b/test/functional/abc-schnorr.py --- a/test/functional/abc-schnorr.py +++ b/test/functional/abc-schnorr.py @@ -71,7 +71,6 @@ 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/abc-schnorrmultisig-activation.py b/test/functional/abc-schnorrmultisig-activation.py --- a/test/functional/abc-schnorrmultisig-activation.py +++ b/test/functional/abc-schnorrmultisig-activation.py @@ -96,7 +96,6 @@ 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/abc-segwit-recovery.py b/test/functional/abc-segwit-recovery.py --- a/test/functional/abc-segwit-recovery.py +++ b/test/functional/abc-segwit-recovery.py @@ -110,8 +110,6 @@ for node in self.nodes: for _ in range(num_connections): node.add_p2p_connection(P2PDataStore()) - for node in self.nodes: - node.p2p.wait_for_verack() def reconnect_p2p(self, **kwargs): """Tear down and bootstrap the P2P connection to the node. diff --git a/test/functional/abc-sync-chain.py b/test/functional/abc-sync-chain.py --- a/test/functional/abc-sync-chain.py +++ b/test/functional/abc-sync-chain.py @@ -41,7 +41,6 @@ def run_test(self): node0 = self.nodes[0] node0conn = node0.add_p2p_connection(BaseNode()) - node0.p2p.wait_for_verack() tip = int(node0.getbestblockhash(), 16) height = node0.getblockcount() + 1 diff --git a/test/functional/abc-transaction-ordering.py b/test/functional/abc-transaction-ordering.py --- a/test/functional/abc-transaction-ordering.py +++ b/test/functional/abc-transaction-ordering.py @@ -130,7 +130,6 @@ def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PDataStore()) - node.p2p.wait_for_verack() self.genesis_hash = int(node.getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 diff --git a/test/functional/example_test.py b/test/functional/example_test.py --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -132,12 +132,9 @@ 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]]) @@ -192,7 +189,6 @@ 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 --- a/test/functional/feature_assumevalid.py +++ b/test/functional/feature_assumevalid.py @@ -99,10 +99,7 @@ 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) @@ -179,10 +176,6 @@ 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 --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -99,7 +99,6 @@ def run_test(self): self.nodes[0].add_p2p_connection(P2PInterface()) - self.nodes[0].p2p.wait_for_verack() self.log.info("Mining {} blocks".format(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 --- a/test/functional/feature_csv_activation.py +++ b/test/functional/feature_csv_activation.py @@ -226,7 +226,6 @@ 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.") # Enough to build up to 1000 blocks 10 minutes apart without worrying diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py --- a/test/functional/feature_dersig.py +++ b/test/functional/feature_dersig.py @@ -61,9 +61,6 @@ 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 {} blocks".format(DERSIG_HEIGHT - 1)) self.coinbase_blocks = self.nodes[0].generate(DERSIG_HEIGHT - 1) self.nodeaddress = self.nodes[0].getnewaddress() diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -64,11 +64,6 @@ 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_big_block(self.nodes[0], self.utxo_cache) @@ -157,7 +152,6 @@ # 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/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -841,8 +841,6 @@ 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 --- a/test/functional/p2p_feefilter.py +++ b/test/functional/p2p_feefilter.py @@ -57,9 +57,7 @@ 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 --- a/test/functional/p2p_fingerprint.py +++ b/test/functional/p2p_fingerprint.py @@ -74,7 +74,6 @@ # 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 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -34,7 +34,6 @@ # 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 --- a/test/functional/p2p_invalid_tx.py +++ b/test/functional/p2p_invalid_tx.py @@ -40,7 +40,6 @@ 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 --- a/test/functional/p2p_leak.py +++ b/test/functional/p2p_leak.py @@ -134,9 +134,9 @@ def run_test(self): no_version_bannode = self.nodes[0].add_p2p_connection( - CNodeNoVersionBan(), send_version=False) + CNodeNoVersionBan(), send_version=False, wait_for_verack=False) no_version_idlenode = self.nodes[0].add_p2p_connection( - CNodeNoVersionIdle(), send_version=False) + CNodeNoVersionIdle(), send_version=False, wait_for_verack=False) no_verack_idlenode = self.nodes[0].add_p2p_connection( CNodeNoVerackIdle()) diff --git a/test/functional/p2p_leak_tx.py b/test/functional/p2p_leak_tx.py --- a/test/functional/p2p_leak_tx.py +++ b/test/functional/p2p_leak_tx.py @@ -31,10 +31,6 @@ # An "attacking" inbound peer inbound_peer = self.nodes[0].add_p2p_connection(P2PNode()) - # Backport note: the following two lines were backported out of order, - # and should be removed in the appropriate future backports that do a - # blanket removal of each of these calls across many tests. - self.nodes[0].p2p.wait_for_verack() MAX_REPEATS = 100 self.log.info("Running test up to {} times.".format(MAX_REPEATS)) diff --git a/test/functional/p2p_mempool.py b/test/functional/p2p_mempool.py --- a/test/functional/p2p_mempool.py +++ b/test/functional/p2p_mempool.py @@ -23,7 +23,6 @@ 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 --- a/test/functional/p2p_node_network_limited.py +++ b/test/functional/p2p_node_network_limited.py @@ -70,7 +70,6 @@ def run_test(self): node = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) - node.wait_for_verack() expected_services = NODE_BLOOM | NODE_BITCOIN_CASH | NODE_NETWORK_LIMITED @@ -101,7 +100,6 @@ 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_sendheaders.py b/test/functional/p2p_sendheaders.py --- a/test/functional/p2p_sendheaders.py +++ b/test/functional/p2p_sendheaders.py @@ -247,8 +247,6 @@ # 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=0) - 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 --- a/test/functional/p2p_timeouts.py +++ b/test/functional/p2p_timeouts.py @@ -43,9 +43,9 @@ # 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) + TestP2PConn(), send_version=False, wait_for_verack=False) no_send_node = self.nodes[0].add_p2p_connection( - TestP2PConn(), send_version=False) + 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 --- a/test/functional/p2p_unrequested_blocks.py +++ b/test/functional/p2p_unrequested_blocks.py @@ -100,8 +100,6 @@ 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] @@ -234,7 +232,6 @@ 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)) @@ -328,7 +325,6 @@ 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 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -306,12 +306,8 @@ 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 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -330,7 +330,7 @@ ctx = FromHex(CTransaction(), self.getrawtransaction(txid)) return self.calculate_fee(ctx) - 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 @@ -340,8 +340,10 @@ 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