Skip to content

Commit

Permalink
[test] Check user agent string from test framework connections
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jnewbery committed Feb 17, 2021
1 parent 9ce4c3c commit 9f21ed4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/functional/test_framework/test_node.py
Expand Up @@ -26,6 +26,7 @@
from .p2p import P2P_SUBVERSION
from .util import (
MAX_NODES,
assert_equal,
append_config,
delete_cookie_file,
get_auth_cookie,
Expand Down Expand Up @@ -545,6 +546,11 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
# in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely.
p2p_conn.sync_with_ping()

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

return p2p_conn

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

0 comments on commit 9f21ed4

Please sign in to comment.