aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-11-28 11:41:25 +0000
committerJohn Newbery <john@johnnewbery.com>2021-02-17 09:22:37 +0000
commit9b4054cb7af22123c7fcc4989e143606a630b2af (patch)
tree3556018b69f5e836bf127413544b90a0982e22ba /test/functional/test_framework
parent7e158a69104831611462cb555da931331b237c78 (diff)
downloadbitcoin-9b4054cb7af22123c7fcc4989e143606a630b2af.tar.xz
[test] Move MY_SUBVERSION to p2p.py
The messages.py module should contain code and helpers for [de]serializing p2p messages. Specific usage of those messages should be in p2p.py. Therefore move MY_SUBVERSION to p2p.py. Also rename to P2P_SUBVERSION.
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-xtest/functional/test_framework/messages.py3
-rwxr-xr-xtest/functional/test_framework/p2p.py3
-rwxr-xr-xtest/functional/test_framework/test_node.py4
3 files changed, 6 insertions, 4 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index b120ce2438..cee662aade 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -31,7 +31,6 @@ import time
from test_framework.siphash import siphash256
from test_framework.util import hex_str_to_bytes, assert_equal
-MY_SUBVERSION = "/python-p2p-tester:0.0.3/"
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
MAX_LOCATOR_SZ = 101
@@ -1030,7 +1029,7 @@ class msg_version:
self.addrTo = CAddress()
self.addrFrom = CAddress()
self.nNonce = random.getrandbits(64)
- self.strSubVer = MY_SUBVERSION
+ self.strSubVer = ''
self.nStartingHeight = -1
self.nRelay = MY_RELAY
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
index 998763ff4d..0814dec546 100755
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -83,6 +83,8 @@ MIN_P2P_VERSION_SUPPORTED = 60001
# The P2P version that this test framework implements and sends in its `version` message
# Version 70016 supports wtxid relay
P2P_VERSION = 70016
+# The P2P user agent string that this test framework sends in its `version` message
+P2P_SUBVERSION = "/python-p2p-tester:0.0.3/"
MESSAGEMAP = {
b"addr": msg_addr,
@@ -333,6 +335,7 @@ class P2PInterface(P2PConnection):
# Send a version msg
vt = msg_version()
vt.nVersion = P2P_VERSION
+ vt.strSubVer = P2P_SUBVERSION
vt.nServices = services
vt.addrTo.ip = self.dstaddr
vt.addrTo.port = self.dstport
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 9f2b570913..24f48d5535 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -23,7 +23,7 @@ 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,
append_config,
@@ -572,7 +572,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."""