Skip to content

Commit

Permalink
test: Update test framework p2p protocol version to 70016
Browse files Browse the repository at this point in the history
This new p2p protocol version allows to use WTXIDs for tx relay.
  • Loading branch information
fjahr authored and jnewbery committed Sep 24, 2020
1 parent e364b2a commit 6be398b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/functional/test_framework/messages.py
Expand Up @@ -31,7 +31,7 @@
from test_framework.util import hex_str_to_bytes, assert_equal

MIN_VERSION_SUPPORTED = 60001
MY_VERSION = 70014 # past bip-31 for ping/pong
MY_VERSION = 70016 # past wtxid relay
MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)

Expand All @@ -52,6 +52,7 @@
MSG_TX = 1
MSG_BLOCK = 2
MSG_FILTERED_BLOCK = 3
MSG_WTX = 5
MSG_WITNESS_FLAG = 1 << 30
MSG_TYPE_MASK = 0xffffffff >> 2

Expand Down Expand Up @@ -231,7 +232,8 @@ class CInv:
MSG_TX | MSG_WITNESS_FLAG: "WitnessTx",
MSG_BLOCK | MSG_WITNESS_FLAG: "WitnessBlock",
MSG_FILTERED_BLOCK: "filtered Block",
4: "CompactBlock"
4: "CompactBlock",
5: "WTX",
}

def __init__(self, t=0, h=0):
Expand All @@ -252,6 +254,9 @@ def __repr__(self):
return "CInv(type=%s hash=%064x)" \
% (self.typemap[self.type], self.hash)

def __eq__(self, other):
return isinstance(other, CInv) and self.hash == other.hash and self.type == other.type


class CBlockLocator:
__slots__ = ("nVersion", "vHave")
Expand Down Expand Up @@ -1113,6 +1118,22 @@ def serialize(self):
def __repr__(self):
return "msg_tx(tx=%s)" % (repr(self.tx))

class msg_wtxidrelay:
__slots__ = ()
command = b"wtxidrelay"

def __init__(self):
pass

def deserialize(self, f):
pass

def serialize(self):
return b""

def __repr__(self):
return "msg_wtxidrelay()"


class msg_no_witness_tx(msg_tx):
__slots__ = ()
Expand Down
3 changes: 3 additions & 0 deletions test/functional/test_framework/mininode.py
Expand Up @@ -52,6 +52,7 @@
MSG_TYPE_MASK,
msg_verack,
msg_version,
msg_wtxidrelay,
NODE_NETWORK,
NODE_WITNESS,
sha256,
Expand Down Expand Up @@ -86,6 +87,7 @@
b"tx": msg_tx,
b"verack": msg_verack,
b"version": msg_version,
b"wtxidrelay": msg_wtxidrelay,
}

MAGIC_BYTES = {
Expand Down Expand Up @@ -343,6 +345,7 @@ def on_reject(self, message): pass
def on_sendcmpct(self, message): pass
def on_sendheaders(self, message): pass
def on_tx(self, message): pass
def on_wtxidrelay(self, message): pass

def on_inv(self, message):
want = msg_getdata()
Expand Down

0 comments on commit 6be398b

Please sign in to comment.