aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2021-02-18 13:52:31 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2021-02-18 14:01:57 +0100
commit860f9168034f0f43e419e5a01024d87236677be6 (patch)
tree4a921af3f9989e35270f089ed6b20ff62c26d3b7 /test/functional/test_framework/test_node.py
parentdb656db2ed5aecc6e623fd3ef1e1bb34207b9e57 (diff)
parent9f21ed4037758f407b536c0dd129f8da83173c79 (diff)
Merge #20524: test: Move MIN_VERSION_SUPPORTED to p2p.py
9f21ed4037758f407b536c0dd129f8da83173c79 [test] Check user agent string from test framework connections (John Newbery) 9ce4c3c4c1682032500c97af2d6383897b87c413 [test] Add P2P_SERVICES to p2p.py (John Newbery) 010542614dbebba5f5ad6a58c0554930e9e214fc [test] Move MY_RELAY to p2p.py (John Newbery) 9b4054cb7af22123c7fcc4989e143606a630b2af [test] Move MY_SUBVERSION to p2p.py (John Newbery) 7e158a69104831611462cb555da931331b237c78 [test] Move MY_VERSION to p2p.py (John Newbery) 652311165c4ef298dab71d7162f9054abf439f77 [test] Move MIN_VERSION_SUPPORTED to p2p.py (John Newbery) Pull request description: The messages.py module should contain code and helpers for [de]serializing p2p messages. Specific usage of those messages should be in p2p.py. This PR moves test framework specific constants to p2p.py. It also changes the SUBVERSION constant to be a string instead of a bytes object. That means that it needs to be explicitly converted to a bytes object to serialize into a version message. Failing to do so would cause an easy-to-spot bug. This should avoid silent failures like the one solved in #20522. ACKs for top commit: laanwj: Code review ACK 9f21ed4037758f407b536c0dd129f8da83173c79 Tree-SHA512: 41d46575ac0ec36ad074d6c6a5b9cef50b05eeb8ddd8ed0a8f0d0c4617cc7b8baa6580af5b83a668230ce1ac27bf0e56914d0361a48b1b05fd75e2e60350eeaf
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-rwxr-xr-xtest/functional/test_framework/test_node.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 9f2b570913..5bc1409ba2 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -23,9 +23,10 @@ import sys
from .authproxy import JSONRPCException
from .descriptors import descsum_create
-from .messages import MY_SUBVERSION
+from .p2p import P2P_SUBVERSION
from .util import (
MAX_NODES,
+ assert_equal,
append_config,
delete_cookie_file,
get_auth_cookie,
@@ -545,6 +546,11 @@ class TestNode():
# 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):
@@ -572,7 +578,7 @@ class TestNode():
def num_test_p2p_connections(self):
"""Return number of test framework p2p connections to the node."""
- return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION])
+ return len([peer for peer in self.getpeerinfo() if peer['subver'] == P2P_SUBVERSION])
def disconnect_p2ps(self):
"""Close all p2p connections to the node."""