Skip to content

Commit

Permalink
Merge bitcoin#29699: test: check disconnection when sending sendaddrv…
Browse files Browse the repository at this point in the history
…2 after verack

b4c9ace test: check disconnection when sending sendaddrv2 after verack (brunoerg)

Pull request description:

  This PR adds test coverage for:
  https://github.com/bitcoin/bitcoin/blob/71b63195b30b2fa0dff20ebb262ce7566dd5d673/src/net_processing.cpp#L3796-L3807

ACKs for top commit:
  maflcko:
    lgtm ACK b4c9ace
  byaye:
    Tested ACK b4c9ace

Tree-SHA512: 2ad49a269cb64794b8d626941cf532acafdbe6e97f3da5ccb52f3201a6773d2f5e3d7d62ce4289334b85d578790d4dd5833f6b8ba54bd49a8418a20aee0c3e5f
  • Loading branch information
glozow committed Apr 15, 2024
2 parents 22c8614 + b4c9ace commit df609a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/functional/p2p_addrv2_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from test_framework.messages import (
CAddress,
msg_addrv2,
msg_sendaddrv2,
)
from test_framework.p2p import (
P2PInterface,
Expand Down Expand Up @@ -75,6 +76,12 @@ def set_test_params(self):
self.extra_args = [["[email protected]"]]

def run_test(self):
self.log.info('Check disconnection when sending sendaddrv2 after verack')
conn = self.nodes[0].add_p2p_connection(P2PInterface())
with self.nodes[0].assert_debug_log(['sendaddrv2 received after verack from peer=0; disconnecting']):
conn.send_message(msg_sendaddrv2())
conn.wait_for_disconnect()

self.log.info('Create connection that sends addrv2 messages')
addr_source = self.nodes[0].add_p2p_connection(P2PInterface())
msg = msg_addrv2()
Expand All @@ -89,8 +96,8 @@ def run_test(self):
msg.addrs = ADDRS
msg_size = calc_addrv2_msg_size(ADDRS)
with self.nodes[0].assert_debug_log([
f'received: addrv2 ({msg_size} bytes) peer=0',
f'sending addrv2 ({msg_size} bytes) peer=1',
f'received: addrv2 ({msg_size} bytes) peer=1',
f'sending addrv2 ({msg_size} bytes) peer=2',
]):
addr_source.send_and_ping(msg)
self.nodes[0].setmocktime(int(time.time()) + 30 * 60)
Expand Down

0 comments on commit df609a3

Please sign in to comment.