diff options
author | John Newbery <john@johnnewbery.com> | 2020-11-28 11:41:25 +0000 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-02-17 09:29:41 +0000 |
commit | 9ce4c3c4c1682032500c97af2d6383897b87c413 (patch) | |
tree | 91948ee41870498512f3f3c13636140d76b9589b /test | |
parent | 010542614dbebba5f5ad6a58c0554930e9e214fc (diff) |
[test] Add P2P_SERVICES 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 specify the nServices value in the calling code,
not in the messages.py module.
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/p2p_filter.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_leak.py | 2 | ||||
-rwxr-xr-x | test/functional/test_framework/messages.py | 2 | ||||
-rwxr-xr-x | test/functional/test_framework/p2p.py | 4 |
4 files changed, 8 insertions, 2 deletions
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index 4df3dd6a21..8f64419138 100755 --- a/test/functional/p2p_filter.py +++ b/test/functional/p2p_filter.py @@ -21,6 +21,7 @@ from test_framework.messages import ( ) from test_framework.p2p import ( P2PInterface, + P2P_SERVICES, P2P_SUBVERSION, P2P_VERSION, p2p_lock, @@ -225,6 +226,7 @@ class FilterTest(BitcoinTestFramework): version_without_fRelay = msg_version() version_without_fRelay.nVersion = P2P_VERSION version_without_fRelay.strSubVer = P2P_SUBVERSION + version_without_fRelay.nServices = P2P_SERVICES version_without_fRelay.relay = 0 filter_peer_without_nrelay.send_message(version_without_fRelay) filter_peer_without_nrelay.wait_for_verack() diff --git a/test/functional/p2p_leak.py b/test/functional/p2p_leak.py index 42e9b9f270..12b8b7baff 100755 --- a/test/functional/p2p_leak.py +++ b/test/functional/p2p_leak.py @@ -20,6 +20,7 @@ from test_framework.messages import ( from test_framework.p2p import ( P2PInterface, P2P_SUBVERSION, + P2P_SERVICES, P2P_VERSION_RELAY, ) from test_framework.test_framework import BitcoinTestFramework @@ -136,6 +137,7 @@ class P2PLeakTest(BitcoinTestFramework): old_version_msg = msg_version() old_version_msg.nVersion = 31799 old_version_msg.strSubVer = P2P_SUBVERSION + old_version_msg.nServices = P2P_SERVICES old_version_msg.relay = P2P_VERSION_RELAY with self.nodes[0].assert_debug_log(['peer=3 using obsolete version 31799; disconnecting']): p2p_old_peer.send_message(old_version_msg) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 5170d430b7..a18a9ec109 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -1022,7 +1022,7 @@ class msg_version: def __init__(self): self.nVersion = 0 - self.nServices = NODE_NETWORK | NODE_WITNESS + self.nServices = 0 self.nTime = int(time.time()) self.addrTo = CAddress() self.addrFrom = CAddress() diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 179d03e93a..05099f3339 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 services that this test framework offers in its `version` message +P2P_SERVICES = NODE_NETWORK | NODE_WITNESS # The P2P user agent string that this test framework sends in its `version` message P2P_SUBVERSION = "/python-p2p-tester:0.0.3/" # Value for relay that this test framework sends in its `version` message @@ -346,7 +348,7 @@ class P2PInterface(P2PConnection): vt.addrFrom.port = 0 self.on_connection_send_msg = vt # Will be sent in connection_made callback - def peer_connect(self, *args, services=NODE_NETWORK | NODE_WITNESS, send_version=True, **kwargs): + def peer_connect(self, *args, services=P2P_SERVICES, send_version=True, **kwargs): create_conn = super().peer_connect(*args, **kwargs) if send_version: |