Skip to content

Commit 9a5392f

Browse files
fjahrsdaftuar
authored andcommitted
test: Update test framework p2p protocol version to 70016
This new p2p protocol version allows to use WTXIDs for tx relay.
1 parent dd78d1d commit 9a5392f

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

test/functional/test_framework/messages.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from test_framework.util import hex_str_to_bytes, assert_equal
3232

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

@@ -59,6 +59,7 @@
5959
MSG_BLOCK = 2
6060
MSG_FILTERED_BLOCK = 3
6161
MSG_CMPCT_BLOCK = 4
62+
MSG_WTX = 5
6263
MSG_WITNESS_FLAG = 1 << 30
6364
MSG_TYPE_MASK = 0xffffffff >> 2
6465

@@ -242,7 +243,8 @@ class CInv:
242243
MSG_TX | MSG_WITNESS_FLAG: "WitnessTx",
243244
MSG_BLOCK | MSG_WITNESS_FLAG: "WitnessBlock",
244245
MSG_FILTERED_BLOCK: "filtered Block",
245-
4: "CompactBlock"
246+
4: "CompactBlock",
247+
5: "WTX",
246248
}
247249

248250
def __init__(self, t=0, h=0):
@@ -263,6 +265,9 @@ def __repr__(self):
263265
return "CInv(type=%s hash=%064x)" \
264266
% (self.typemap[self.type], self.hash)
265267

268+
def __eq__(self, other):
269+
return isinstance(other, CInv) and self.hash == other.hash and self.type == other.type
270+
266271

267272
class CBlockLocator:
268273
__slots__ = ("nVersion", "vHave")
@@ -1124,6 +1129,22 @@ def serialize(self):
11241129
def __repr__(self):
11251130
return "msg_tx(tx=%s)" % (repr(self.tx))
11261131

1132+
class msg_wtxidrelay:
1133+
__slots__ = ()
1134+
msgtype = b"wtxidrelay"
1135+
1136+
def __init__(self):
1137+
pass
1138+
1139+
def deserialize(self, f):
1140+
pass
1141+
1142+
def serialize(self):
1143+
return b""
1144+
1145+
def __repr__(self):
1146+
return "msg_wtxidrelay()"
1147+
11271148

11281149
class msg_no_witness_tx(msg_tx):
11291150
__slots__ = ()

test/functional/test_framework/mininode.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
MSG_TYPE_MASK,
6060
msg_verack,
6161
msg_version,
62+
MSG_WTX,
63+
msg_wtxidrelay,
6264
NODE_NETWORK,
6365
NODE_WITNESS,
6466
sha256,
@@ -96,6 +98,7 @@
9698
b"tx": msg_tx,
9799
b"verack": msg_verack,
98100
b"version": msg_version,
101+
b"wtxidrelay": msg_wtxidrelay,
99102
}
100103

101104
MAGIC_BYTES = {
@@ -356,6 +359,7 @@ def on_pong(self, message): pass
356359
def on_sendcmpct(self, message): pass
357360
def on_sendheaders(self, message): pass
358361
def on_tx(self, message): pass
362+
def on_wtxidrelay(self, message): pass
359363

360364
def on_inv(self, message):
361365
want = msg_getdata()
@@ -654,7 +658,7 @@ def on_inv(self, message):
654658
super().on_inv(message) # Send getdata in response.
655659
# Store how many times invs have been received for each tx.
656660
for i in message.inv:
657-
if i.type == MSG_TX:
661+
if (i.type == MSG_TX) or (i.type == MSG_WTX):
658662
# save txid
659663
self.tx_invs_received[i.hash] += 1
660664

0 commit comments

Comments
 (0)