Skip to content

Commit e56d1d2

Browse files
committed
test: Add functional tests for sendtxrcncl message from outbound
1 parent cfcef60 commit e56d1d2

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

test/functional/p2p_sendtxrcncl.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,34 @@ def run_test(self):
146146
peer.send_message(msg_verack())
147147
peer.peer_disconnect()
148148

149+
self.log.info('SENDTXRCNCL sent to an outbound')
150+
peer = self.nodes[0].add_outbound_p2p_connection(
151+
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=1, connection_type="outbound-full-relay")
152+
assert peer.sendtxrcncl_msg_received
153+
assert peer.sendtxrcncl_msg_received.initiator
154+
assert not peer.sendtxrcncl_msg_received.responder
155+
assert_equal(peer.sendtxrcncl_msg_received.version, 1)
156+
peer.peer_disconnect()
157+
158+
self.log.info('SENDTXRCNCL should not be sent if block-relay-only')
159+
peer = self.nodes[0].add_outbound_p2p_connection(
160+
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=2, connection_type="block-relay-only")
161+
assert not peer.sendtxrcncl_msg_received
162+
peer.peer_disconnect()
163+
164+
self.log.info('SENDTXRCNCL if block-relay-only triggers a disconnect')
165+
peer = self.nodes[0].add_outbound_p2p_connection(
166+
PeerNoVerack(), wait_for_verack=False, p2p_idx=3, connection_type="block-relay-only")
167+
peer.send_message(create_sendtxrcncl_msg(initiator=False))
168+
peer.wait_for_disconnect()
169+
170+
self.log.info('SENDTXRCNCL with initiator=1 and responder=0 from outbound triggers a disconnect')
171+
sendtxrcncl_wrong_role = create_sendtxrcncl_msg(initiator=True)
172+
peer = self.nodes[0].add_outbound_p2p_connection(
173+
P2PInterface(), wait_for_verack=False, p2p_idx=4, connection_type="outbound-full-relay")
174+
peer.send_message(sendtxrcncl_wrong_role)
175+
peer.wait_for_disconnect()
176+
149177
self.log.info('SENDTXRCNCL not sent if -txreconciliation flag is not set')
150178
self.restart_node(0, [])
151179
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True)

test/functional/test_framework/test_node.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
618618

619619
return p2p_conn
620620

621-
def add_outbound_p2p_connection(self, p2p_conn, *, p2p_idx, connection_type="outbound-full-relay", **kwargs):
621+
def add_outbound_p2p_connection(self, p2p_conn, *, wait_for_verack=True, p2p_idx, connection_type="outbound-full-relay", **kwargs):
622622
"""Add an outbound p2p connection from node. Must be an
623623
"outbound-full-relay", "block-relay-only", "addr-fetch" or "feeler" connection.
624624
@@ -640,8 +640,9 @@ def addconnection_callback(address, port):
640640
p2p_conn.wait_for_connect()
641641
self.p2ps.append(p2p_conn)
642642

643-
p2p_conn.wait_for_verack()
644-
p2p_conn.sync_with_ping()
643+
if wait_for_verack:
644+
p2p_conn.wait_for_verack()
645+
p2p_conn.sync_with_ping()
645646

646647
return p2p_conn
647648

0 commit comments

Comments
 (0)