merge bitcoin#26448: fix intermittent failure in p2p_sendtxrcncl.py

This commit is contained in:
Kittywhiskers Van Gogh 2024-10-19 16:22:06 +00:00
parent 36be978fc9
commit b55a6f794b
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -69,7 +69,7 @@ class SendTxRcnclTest(BitcoinTestFramework):
assert not peer.sendtxrcncl_msg_received.initiator assert not peer.sendtxrcncl_msg_received.initiator
assert peer.sendtxrcncl_msg_received.responder assert peer.sendtxrcncl_msg_received.responder
assert_equal(peer.sendtxrcncl_msg_received.version, 1) assert_equal(peer.sendtxrcncl_msg_received.version, 1)
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL should be sent before VERACK') self.log.info('SENDTXRCNCL should be sent before VERACK')
peer = self.nodes[0].add_p2p_connection(PeerTrackMsgOrder(), send_version=True, wait_for_verack=True) peer = self.nodes[0].add_p2p_connection(PeerTrackMsgOrder(), send_version=True, wait_for_verack=True)
@ -77,7 +77,7 @@ class SendTxRcnclTest(BitcoinTestFramework):
verack_index = [i for i, msg in enumerate(peer.messages) if msg.msgtype == b'verack'][0] verack_index = [i for i, msg in enumerate(peer.messages) if msg.msgtype == b'verack'][0]
sendtxrcncl_index = [i for i, msg in enumerate(peer.messages) if msg.msgtype == b'sendtxrcncl'][0] sendtxrcncl_index = [i for i, msg in enumerate(peer.messages) if msg.msgtype == b'sendtxrcncl'][0]
assert(sendtxrcncl_index < verack_index) assert(sendtxrcncl_index < verack_index)
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL on pre-v22 version should not be sent') self.log.info('SENDTXRCNCL on pre-v22 version should not be sent')
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False) peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False)
@ -89,7 +89,7 @@ class SendTxRcnclTest(BitcoinTestFramework):
peer.send_message(pre_v22_version_msg) peer.send_message(pre_v22_version_msg)
peer.wait_for_verack() peer.wait_for_verack()
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL for fRelay=false should not be sent') self.log.info('SENDTXRCNCL for fRelay=false should not be sent')
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False) peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False)
@ -101,7 +101,7 @@ class SendTxRcnclTest(BitcoinTestFramework):
peer.send_message(no_txrelay_version_msg) peer.send_message(no_txrelay_version_msg)
peer.wait_for_verack() peer.wait_for_verack()
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('valid SENDTXRCNCL received') self.log.info('valid SENDTXRCNCL received')
peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False) peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False)
@ -144,27 +144,27 @@ class SendTxRcnclTest(BitcoinTestFramework):
self.log.info('SENDTXRCNCL sent to an outbound') self.log.info('SENDTXRCNCL sent to an outbound')
peer = self.nodes[0].add_outbound_p2p_connection( peer = self.nodes[0].add_outbound_p2p_connection(
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=1, connection_type="outbound-full-relay") SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=0, connection_type="outbound-full-relay")
assert peer.sendtxrcncl_msg_received assert peer.sendtxrcncl_msg_received
assert peer.sendtxrcncl_msg_received.initiator assert peer.sendtxrcncl_msg_received.initiator
assert not peer.sendtxrcncl_msg_received.responder assert not peer.sendtxrcncl_msg_received.responder
assert_equal(peer.sendtxrcncl_msg_received.version, 1) assert_equal(peer.sendtxrcncl_msg_received.version, 1)
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL should not be sent if block-relay-only') self.log.info('SENDTXRCNCL should not be sent if block-relay-only')
peer = self.nodes[0].add_outbound_p2p_connection( peer = self.nodes[0].add_outbound_p2p_connection(
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=2, connection_type="block-relay-only") SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=0, connection_type="block-relay-only")
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info("SENDTXRCNCL should not be sent if feeler") self.log.info("SENDTXRCNCL should not be sent if feeler")
peer = self.nodes[0].add_outbound_p2p_connection(P2PFeelerReceiver(), p2p_idx=2, connection_type="feeler") peer = self.nodes[0].add_outbound_p2p_connection(P2PFeelerReceiver(), p2p_idx=0, connection_type="feeler")
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL if block-relay-only triggers a disconnect') self.log.info('SENDTXRCNCL if block-relay-only triggers a disconnect')
peer = self.nodes[0].add_outbound_p2p_connection( peer = self.nodes[0].add_outbound_p2p_connection(
PeerNoVerack(), wait_for_verack=False, p2p_idx=3, connection_type="block-relay-only") PeerNoVerack(), wait_for_verack=False, p2p_idx=0, connection_type="block-relay-only")
with self.nodes[0].assert_debug_log(["we indicated no tx relay; disconnecting"]): with self.nodes[0].assert_debug_log(["we indicated no tx relay; disconnecting"]):
peer.send_message(create_sendtxrcncl_msg(initiator=False)) peer.send_message(create_sendtxrcncl_msg(initiator=False))
peer.wait_for_disconnect() peer.wait_for_disconnect()
@ -172,7 +172,7 @@ class SendTxRcnclTest(BitcoinTestFramework):
self.log.info('SENDTXRCNCL with initiator=1 and responder=0 from outbound triggers a disconnect') self.log.info('SENDTXRCNCL with initiator=1 and responder=0 from outbound triggers a disconnect')
sendtxrcncl_wrong_role = create_sendtxrcncl_msg(initiator=True) sendtxrcncl_wrong_role = create_sendtxrcncl_msg(initiator=True)
peer = self.nodes[0].add_outbound_p2p_connection( peer = self.nodes[0].add_outbound_p2p_connection(
PeerNoVerack(), wait_for_verack=False, p2p_idx=4, connection_type="outbound-full-relay") PeerNoVerack(), wait_for_verack=False, p2p_idx=0, connection_type="outbound-full-relay")
with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]): with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]):
peer.send_message(sendtxrcncl_wrong_role) peer.send_message(sendtxrcncl_wrong_role)
peer.wait_for_disconnect() peer.wait_for_disconnect()
@ -181,13 +181,13 @@ class SendTxRcnclTest(BitcoinTestFramework):
self.restart_node(0, []) self.restart_node(0, [])
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True) peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True)
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
self.log.info('SENDTXRCNCL not sent if blocksonly is set') self.log.info('SENDTXRCNCL not sent if blocksonly is set')
self.restart_node(0, ["-txreconciliation", "-blocksonly"]) self.restart_node(0, ["-txreconciliation", "-blocksonly"])
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True) peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True)
assert not peer.sendtxrcncl_msg_received assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect() self.nodes[0].disconnect_p2ps()
if __name__ == '__main__': if __name__ == '__main__':