mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
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
This commit is contained in:
parent
389aaa07d1
commit
e1497f67b2
@ -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])
|
||||
@ -190,7 +187,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("Test that node2 propagates all the blocks to us")
|
||||
|
||||
|
@ -96,10 +96,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)
|
||||
@ -169,10 +166,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()
|
||||
|
||||
# Make sure nodes actually accept the many headers
|
||||
self.mocktime = self.block_time
|
||||
set_node_times(self.nodes, self.mocktime)
|
||||
|
@ -85,7 +85,6 @@ class BlockRewardReallocationTest(DashTestFramework):
|
||||
self.nodes[0].generate(10)
|
||||
|
||||
self.nodes[0].add_p2p_connection(P2PDataStore())
|
||||
self.nodes[0].p2p.wait_for_verack()
|
||||
|
||||
self.log.info("Mine all but one remaining block in the window")
|
||||
bi = self.nodes[0].getblockchaininfo()
|
||||
|
@ -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)
|
||||
|
@ -187,7 +187,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.")
|
||||
self.coinbase_blocks = self.nodes[0].generate(1 + 16 + 2 * 32 + 1) # 82 blocks generated for inputs
|
||||
|
@ -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()
|
||||
|
@ -40,7 +40,6 @@ class LLMQCoinbaseCommitmentsTest(DashTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||
self.nodes[0].p2p.wait_for_verack()
|
||||
|
||||
self.confirm_mns()
|
||||
|
||||
|
@ -54,7 +54,6 @@ class LLMQ_IS_CL_Conflicts(DashTestFramework):
|
||||
self.activate_dip8()
|
||||
|
||||
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||
self.nodes[0].p2p.wait_for_verack()
|
||||
|
||||
self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
||||
self.wait_for_sporks_same()
|
||||
|
@ -95,7 +95,6 @@ class LLMQSigningTest(DashTestFramework):
|
||||
mn = self.get_mninfo(q['recoveryMembers'][0])
|
||||
# Open a P2P connection to it
|
||||
p2p_interface = mn.node.add_p2p_connection(P2PInterface())
|
||||
mn.node.p2p.wait_for_verack()
|
||||
# Send the last required QSIGSHARE message to the recovery member
|
||||
p2p_interface.send_message(msg_qsigshare([sig_share]))
|
||||
else:
|
||||
|
@ -61,11 +61,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)
|
||||
|
||||
@ -151,7 +146,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)]
|
||||
|
@ -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)
|
||||
|
@ -242,7 +242,6 @@ class DashZMQTest (DashTestFramework):
|
||||
self.subscribe(instantsend_publishers)
|
||||
# Initialize test node
|
||||
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||
self.nodes[0].p2p.wait_for_verack()
|
||||
# Make sure all nodes agree
|
||||
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
|
||||
# Create two raw TXs, they will conflict with each other
|
||||
|
@ -50,7 +50,6 @@ class AddrTest(BitcoinTestFramework):
|
||||
|
||||
self.log.info('Create connection that sends addrv2 messages')
|
||||
addr_source = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||
addr_source.wait_for_verack()
|
||||
|
||||
msg = msg_addrv2()
|
||||
|
||||
@ -64,8 +63,6 @@ class AddrTest(BitcoinTestFramework):
|
||||
self.log.info('Check that addrv2 message content is relayed and added to addrman')
|
||||
addr_source = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||
addr_receiver = self.nodes[0].add_p2p_connection(AddrReceiver())
|
||||
addr_source.wait_for_verack()
|
||||
addr_receiver.wait_for_verack()
|
||||
|
||||
msg.addrs = ADDRS
|
||||
with self.nodes[0].assert_debug_log([
|
||||
|
@ -718,8 +718,6 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||
self.second_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
|
||||
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()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -34,7 +34,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.
|
||||
|
@ -91,9 +91,8 @@ class P2PLeakTest(BitcoinTestFramework):
|
||||
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)
|
||||
|
@ -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())
|
||||
|
@ -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_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()
|
||||
|
@ -148,8 +148,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
self.log.info("Testing basics of QGETDATA/QDATA")
|
||||
p2p_node0 = p2p_connection(node0)
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_node0.wait_for_verack()
|
||||
p2p_mn1.wait_for_verack()
|
||||
id_p2p_node0 = get_mininode_id(node0)
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
|
||||
@ -170,7 +168,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
node0.disconnect_p2ps()
|
||||
mn1.node.disconnect_p2ps()
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_mn1.wait_for_verack()
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
mnauth(mn1.node, id_p2p_mn1, fake_mnauth_1[0], fake_mnauth_1[1])
|
||||
# The masternode should now respond to qgetdata requests
|
||||
@ -192,8 +189,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
self.log.info("Test ban score increase for invalid / unexpected QDATA")
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_mn2 = p2p_connection(mn2.node)
|
||||
p2p_mn1.wait_for_verack()
|
||||
p2p_mn2.wait_for_verack()
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
id_p2p_mn2 = get_mininode_id(mn2.node)
|
||||
mnauth(mn1.node, id_p2p_mn1, fake_mnauth_1[0], fake_mnauth_1[1])
|
||||
@ -241,7 +236,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
mn2.node.disconnect_p2ps()
|
||||
self.log.info("Test all available error codes")
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_mn1.wait_for_verack()
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
mnauth(mn1.node, id_p2p_mn1, fake_mnauth_1[0], fake_mnauth_1[1])
|
||||
qgetdata_invalid_type = msg_qgetdata(quorum_hash_int, 103, 0x01, protx_hash_int)
|
||||
@ -258,8 +252,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
# Re-connect to the masternode
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_mn2 = p2p_connection(mn2.node)
|
||||
p2p_mn1.wait_for_verack()
|
||||
p2p_mn2.wait_for_verack()
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
id_p2p_mn2 = get_mininode_id(mn2.node)
|
||||
assert id_p2p_mn1 is not None
|
||||
@ -310,7 +302,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
self.log.info("Test request limiting / banscore increases")
|
||||
|
||||
p2p_mn1 = p2p_connection(mn1.node)
|
||||
p2p_mn1.wait_for_verack()
|
||||
id_p2p_mn1 = get_mininode_id(mn1.node)
|
||||
mnauth(mn1.node, id_p2p_mn1, fake_mnauth_1[0], fake_mnauth_1[1])
|
||||
p2p_mn1.test_qgetdata(qgetdata_vvec, 0, self.llmq_threshold, 0)
|
||||
@ -326,8 +317,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
# in banscore increase for either of both.
|
||||
p2p_mn3_1 = p2p_connection(mn3.node, uacomment_m3_1)
|
||||
p2p_mn3_2 = p2p_connection(mn3.node, uacomment_m3_2)
|
||||
p2p_mn3_1.wait_for_verack()
|
||||
p2p_mn3_2.wait_for_verack()
|
||||
id_p2p_mn3_1 = get_mininode_id(mn3.node, uacomment_m3_1)
|
||||
id_p2p_mn3_2 = get_mininode_id(mn3.node, uacomment_m3_2)
|
||||
assert id_p2p_mn3_1 != id_p2p_mn3_2
|
||||
@ -357,8 +346,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
force_request_expire()
|
||||
p2p_mn3_1 = p2p_connection(mn3.node, uacomment_m3_1)
|
||||
p2p_mn3_2 = p2p_connection(mn3.node, uacomment_m3_2)
|
||||
p2p_mn3_1.wait_for_verack()
|
||||
p2p_mn3_2.wait_for_verack()
|
||||
id_p2p_mn3_1 = get_mininode_id(mn3.node, uacomment_m3_1)
|
||||
id_p2p_mn3_2 = get_mininode_id(mn3.node, uacomment_m3_2)
|
||||
assert id_p2p_mn3_1 != id_p2p_mn3_2
|
||||
@ -387,8 +374,6 @@ class QuorumDataMessagesTest(DashTestFramework):
|
||||
connect_nodes(node0, i + 1)
|
||||
p2p_node0 = p2p_connection(node0)
|
||||
p2p_mn2 = p2p_connection(mn2.node)
|
||||
p2p_node0.wait_for_verack()
|
||||
p2p_mn2.wait_for_verack()
|
||||
id_p2p_node0 = get_mininode_id(node0)
|
||||
id_p2p_mn2 = get_mininode_id(mn2.node)
|
||||
mnauth(node0, id_p2p_node0, fake_mnauth_1[0], fake_mnauth_1[1])
|
||||
|
@ -240,8 +240,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=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()
|
||||
|
@ -42,8 +42,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)
|
||||
|
||||
|
@ -77,8 +77,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 ]
|
||||
@ -201,7 +199,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))
|
||||
|
||||
@ -286,7 +283,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)
|
||||
|
@ -260,12 +260,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']
|
||||
|
||||
|
@ -21,8 +21,7 @@ class FakeMNAUTHTest(DashTestFramework):
|
||||
def run_test(self):
|
||||
|
||||
masternode = self.mninfo[0]
|
||||
p2p_masternode = masternode.node.add_p2p_connection(P2PInterface())
|
||||
p2p_masternode.wait_for_verack()
|
||||
masternode.node.add_p2p_connection(P2PInterface())
|
||||
|
||||
protx_hash = masternode.proTxHash
|
||||
public_key = masternode.pubKeyOperator
|
||||
|
@ -302,7 +302,7 @@ class TestNode():
|
||||
assert_msg = "dashd should have exited with expected error " + expected_msg
|
||||
self._raise_assertion_error(assert_msg)
|
||||
|
||||
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
|
||||
@ -312,8 +312,10 @@ class TestNode():
|
||||
if 'dstaddr' not in kwargs:
|
||||
kwargs['dstaddr'] = '127.0.0.1'
|
||||
|
||||
p2p_conn.peer_connect(*args, **kwargs, net=self.chain)()
|
||||
p2p_conn.peer_connect(**kwargs, net=self.chain)()
|
||||
self.p2ps.append(p2p_conn)
|
||||
if wait_for_verack:
|
||||
p2p_conn.wait_for_verack()
|
||||
|
||||
return p2p_conn
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user