Skip to content

Commit

Permalink
test: Add functional tests for sendtxrcncl message from outbound
Browse files Browse the repository at this point in the history
  • Loading branch information
naumenkogs committed Oct 17, 2022
1 parent cfcef60 commit e56d1d2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
28 changes: 28 additions & 0 deletions test/functional/p2p_sendtxrcncl.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,34 @@ def run_test(self):
peer.send_message(msg_verack())
peer.peer_disconnect()

self.log.info('SENDTXRCNCL sent to an outbound')
peer = self.nodes[0].add_outbound_p2p_connection(
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=1, connection_type="outbound-full-relay")
assert peer.sendtxrcncl_msg_received
assert peer.sendtxrcncl_msg_received.initiator
assert not peer.sendtxrcncl_msg_received.responder
assert_equal(peer.sendtxrcncl_msg_received.version, 1)
peer.peer_disconnect()

self.log.info('SENDTXRCNCL should not be sent if block-relay-only')
peer = self.nodes[0].add_outbound_p2p_connection(
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=2, connection_type="block-relay-only")
assert not peer.sendtxrcncl_msg_received
peer.peer_disconnect()

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()

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()

self.log.info('SENDTXRCNCL not sent if -txreconciliation flag is not set')
self.restart_node(0, [])
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=True, wait_for_verack=True)
Expand Down
7 changes: 4 additions & 3 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):

return p2p_conn

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

p2p_conn.wait_for_verack()
p2p_conn.sync_with_ping()
if wait_for_verack:
p2p_conn.wait_for_verack()
p2p_conn.sync_with_ping()

return p2p_conn

Expand Down

0 comments on commit e56d1d2

Please sign in to comment.