Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check disconnection when sending sendaddrv2 after verack #29699

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = [["-whitelist=addr@127.0.0.1"]]

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',
Comment on lines -92 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think this is a good example of why we shouldn't use assert_debug_log when we're able to check the logic otherwise)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

]):
addr_source.send_and_ping(msg)
self.nodes[0].setmocktime(int(time.time()) + 30 * 60)
Expand Down