From 7e158a69104831611462cb555da931331b237c78 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Sat, 28 Nov 2020 11:41:25 +0000 Subject: [test] Move MY_VERSION 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_VERSION to p2p.py. Also rename to P2P_VERSION to distinguish it from other versioning used in Bitcoin/Bitcoin Core. Also always set the nVersion field in CBlockLocator to 0 and ignore the field in deserialized messages. The field is not currently used for anything in Bitcoin Core. --- test/functional/p2p_filter.py | 7 ++++++- test/functional/test_framework/messages.py | 11 ++++------- test/functional/test_framework/p2p.py | 4 ++++ 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index 458e5235b6..2324a3f588 100755 --- a/test/functional/p2p_filter.py +++ b/test/functional/p2p_filter.py @@ -19,7 +19,11 @@ from test_framework.messages import ( msg_mempool, msg_version, ) -from test_framework.p2p import P2PInterface, p2p_lock +from test_framework.p2p import ( + P2PInterface, + P2P_VERSION, + p2p_lock, +) from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE from test_framework.test_framework import BitcoinTestFramework @@ -218,6 +222,7 @@ class FilterTest(BitcoinTestFramework): filter_peer_without_nrelay = self.nodes[0].add_p2p_connection(P2PBloomFilter(), send_version=False, wait_for_verack=False) # Send version with fRelay=False version_without_fRelay = msg_version() + version_without_fRelay.nVersion = P2P_VERSION version_without_fRelay.nRelay = 0 filter_peer_without_nrelay.send_message(version_without_fRelay) filter_peer_without_nrelay.wait_for_verack() diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 623c01908b..b120ce2438 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_VERSION = 70016 # past wtxid relay MY_SUBVERSION = "/python-p2p-tester:0.0.3/" MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37) @@ -325,22 +324,20 @@ class CBlockLocator: __slots__ = ("nVersion", "vHave") def __init__(self): - self.nVersion = MY_VERSION self.vHave = [] def deserialize(self, f): - self.nVersion = struct.unpack("