From 62dc9cb17b26c5532b744a7e56738ccceeb9262b Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 20 Oct 2024 10:53:35 +0000 Subject: [PATCH] merge bitcoin#26381: Fix intermittent issue in p2p_sendtxrcncl.py --- test/functional/p2p_sendtxrcncl.py | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/test/functional/p2p_sendtxrcncl.py b/test/functional/p2p_sendtxrcncl.py index bebb35a939..139cee40ca 100755 --- a/test/functional/p2p_sendtxrcncl.py +++ b/test/functional/p2p_sendtxrcncl.py @@ -7,7 +7,6 @@ from test_framework.messages import ( msg_sendtxrcncl, - msg_verack, msg_version, ) from test_framework.p2p import ( @@ -103,37 +102,39 @@ class SendTxRcnclTest(BitcoinTestFramework): peer.send_message(create_sendtxrcncl_msg()) self.wait_until(lambda : "sendtxrcncl" in self.nodes[0].getpeerinfo()[-1]["bytesrecv_per_msg"]) self.log.info('second SENDTXRCNCL triggers a disconnect') - peer.send_message(create_sendtxrcncl_msg()) - peer.wait_for_disconnect() + with self.nodes[0].assert_debug_log(["(sendtxrcncl received from already registered peer); disconnecting"]): + peer.send_message(create_sendtxrcncl_msg()) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL with initiator=responder=0 triggers a disconnect') sendtxrcncl_no_role = create_sendtxrcncl_msg() sendtxrcncl_no_role.initiator = False sendtxrcncl_no_role.responder = False peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False) - peer.send_message(sendtxrcncl_no_role) - peer.wait_for_disconnect() + with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]): + peer.send_message(sendtxrcncl_no_role) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL with initiator=0 and responder=1 from inbound triggers a disconnect') sendtxrcncl_wrong_role = create_sendtxrcncl_msg(initiator=False) peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False) - peer.send_message(sendtxrcncl_wrong_role) - peer.wait_for_disconnect() + with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]): + peer.send_message(sendtxrcncl_wrong_role) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL with version=0 triggers a disconnect') sendtxrcncl_low_version = create_sendtxrcncl_msg() sendtxrcncl_low_version.version = 0 peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False) - peer.send_message(sendtxrcncl_low_version) - peer.wait_for_disconnect() + with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]): + peer.send_message(sendtxrcncl_low_version) + peer.wait_for_disconnect() self.log.info('sending SENDTXRCNCL after sending VERACK triggers a disconnect') - # We use PeerNoVerack even though verack is sent right after, to make sure it was actually - # sent before sendtxrcncl is sent. - peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False) - peer.send_and_ping(msg_verack()) - peer.send_message(create_sendtxrcncl_msg()) - peer.wait_for_disconnect() + peer = self.nodes[0].add_p2p_connection(P2PInterface()) + with self.nodes[0].assert_debug_log(["sendtxrcncl received after verack"]): + peer.send_message(create_sendtxrcncl_msg()) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL sent to an outbound') peer = self.nodes[0].add_outbound_p2p_connection( @@ -153,15 +154,17 @@ class SendTxRcnclTest(BitcoinTestFramework): self.log.info('SENDTXRCNCL if block-relay-only triggers a disconnect') peer = self.nodes[0].add_outbound_p2p_connection( PeerNoVerack(), wait_for_verack=False, p2p_idx=3, connection_type="block-relay-only") - peer.send_message(create_sendtxrcncl_msg(initiator=False)) - peer.wait_for_disconnect() + with self.nodes[0].assert_debug_log(["we indicated no tx relay; disconnecting"]): + peer.send_message(create_sendtxrcncl_msg(initiator=False)) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL with initiator=1 and responder=0 from outbound triggers a disconnect') sendtxrcncl_wrong_role = create_sendtxrcncl_msg(initiator=True) peer = self.nodes[0].add_outbound_p2p_connection( - P2PInterface(), wait_for_verack=False, p2p_idx=4, connection_type="outbound-full-relay") - peer.send_message(sendtxrcncl_wrong_role) - peer.wait_for_disconnect() + PeerNoVerack(), wait_for_verack=False, p2p_idx=4, connection_type="outbound-full-relay") + with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]): + peer.send_message(sendtxrcncl_wrong_role) + peer.wait_for_disconnect() self.log.info('SENDTXRCNCL not sent if -txreconciliation flag is not set') self.restart_node(0, [])