Skip to content

Commit 9f21ed4

Browse files
committed
[test] Check user agent string from test framework connections
Add a check that new connections from the test framework to the node have the correct user agent string. This makes bugs easier to detect if the user agent string ever changes.
1 parent 9ce4c3c commit 9f21ed4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/functional/test_framework/test_node.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .p2p import P2P_SUBVERSION
2727
from .util import (
2828
MAX_NODES,
29+
assert_equal,
2930
append_config,
3031
delete_cookie_file,
3132
get_auth_cookie,
@@ -545,6 +546,11 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
545546
# in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely.
546547
p2p_conn.sync_with_ping()
547548

549+
# Consistency check that the Bitcoin Core has received our user agent string. This checks the
550+
# node's newest peer. It could be racy if another Bitcoin Core node has connected since we opened
551+
# our connection, but we don't expect that to happen.
552+
assert_equal(self.getpeerinfo()[-1]['subver'], P2P_SUBVERSION)
553+
548554
return p2p_conn
549555

550556
def add_outbound_p2p_connection(self, p2p_conn, *, p2p_idx, connection_type="outbound-full-relay", **kwargs):

0 commit comments

Comments
 (0)