mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
test: Update test framework p2p protocol version to 70016
This new p2p protocol version allows to use WTXIDs for tx relay.
This commit is contained in:
parent
dd78d1d641
commit
9a5392fdf6
2 changed files with 28 additions and 3 deletions
|
@ -31,7 +31,7 @@ from test_framework.siphash import siphash256
|
||||||
from test_framework.util import hex_str_to_bytes, assert_equal
|
from test_framework.util import hex_str_to_bytes, assert_equal
|
||||||
|
|
||||||
MIN_VERSION_SUPPORTED = 60001
|
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_SUBVERSION = b"/python-mininode-tester:0.0.3/"
|
||||||
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
|
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ MSG_TX = 1
|
||||||
MSG_BLOCK = 2
|
MSG_BLOCK = 2
|
||||||
MSG_FILTERED_BLOCK = 3
|
MSG_FILTERED_BLOCK = 3
|
||||||
MSG_CMPCT_BLOCK = 4
|
MSG_CMPCT_BLOCK = 4
|
||||||
|
MSG_WTX = 5
|
||||||
MSG_WITNESS_FLAG = 1 << 30
|
MSG_WITNESS_FLAG = 1 << 30
|
||||||
MSG_TYPE_MASK = 0xffffffff >> 2
|
MSG_TYPE_MASK = 0xffffffff >> 2
|
||||||
|
|
||||||
|
@ -242,7 +243,8 @@ class CInv:
|
||||||
MSG_TX | MSG_WITNESS_FLAG: "WitnessTx",
|
MSG_TX | MSG_WITNESS_FLAG: "WitnessTx",
|
||||||
MSG_BLOCK | MSG_WITNESS_FLAG: "WitnessBlock",
|
MSG_BLOCK | MSG_WITNESS_FLAG: "WitnessBlock",
|
||||||
MSG_FILTERED_BLOCK: "filtered Block",
|
MSG_FILTERED_BLOCK: "filtered Block",
|
||||||
4: "CompactBlock"
|
4: "CompactBlock",
|
||||||
|
5: "WTX",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, t=0, h=0):
|
def __init__(self, t=0, h=0):
|
||||||
|
@ -263,6 +265,9 @@ class CInv:
|
||||||
return "CInv(type=%s hash=%064x)" \
|
return "CInv(type=%s hash=%064x)" \
|
||||||
% (self.typemap[self.type], self.hash)
|
% (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:
|
class CBlockLocator:
|
||||||
__slots__ = ("nVersion", "vHave")
|
__slots__ = ("nVersion", "vHave")
|
||||||
|
@ -1124,6 +1129,22 @@ class msg_tx:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "msg_tx(tx=%s)" % (repr(self.tx))
|
return "msg_tx(tx=%s)" % (repr(self.tx))
|
||||||
|
|
||||||
|
class msg_wtxidrelay:
|
||||||
|
__slots__ = ()
|
||||||
|
msgtype = 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):
|
class msg_no_witness_tx(msg_tx):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
|
@ -59,6 +59,8 @@ from test_framework.messages import (
|
||||||
MSG_TYPE_MASK,
|
MSG_TYPE_MASK,
|
||||||
msg_verack,
|
msg_verack,
|
||||||
msg_version,
|
msg_version,
|
||||||
|
MSG_WTX,
|
||||||
|
msg_wtxidrelay,
|
||||||
NODE_NETWORK,
|
NODE_NETWORK,
|
||||||
NODE_WITNESS,
|
NODE_WITNESS,
|
||||||
sha256,
|
sha256,
|
||||||
|
@ -96,6 +98,7 @@ MESSAGEMAP = {
|
||||||
b"tx": msg_tx,
|
b"tx": msg_tx,
|
||||||
b"verack": msg_verack,
|
b"verack": msg_verack,
|
||||||
b"version": msg_version,
|
b"version": msg_version,
|
||||||
|
b"wtxidrelay": msg_wtxidrelay,
|
||||||
}
|
}
|
||||||
|
|
||||||
MAGIC_BYTES = {
|
MAGIC_BYTES = {
|
||||||
|
@ -356,6 +359,7 @@ class P2PInterface(P2PConnection):
|
||||||
def on_sendcmpct(self, message): pass
|
def on_sendcmpct(self, message): pass
|
||||||
def on_sendheaders(self, message): pass
|
def on_sendheaders(self, message): pass
|
||||||
def on_tx(self, message): pass
|
def on_tx(self, message): pass
|
||||||
|
def on_wtxidrelay(self, message): pass
|
||||||
|
|
||||||
def on_inv(self, message):
|
def on_inv(self, message):
|
||||||
want = msg_getdata()
|
want = msg_getdata()
|
||||||
|
@ -654,7 +658,7 @@ class P2PTxInvStore(P2PInterface):
|
||||||
super().on_inv(message) # Send getdata in response.
|
super().on_inv(message) # Send getdata in response.
|
||||||
# Store how many times invs have been received for each tx.
|
# Store how many times invs have been received for each tx.
|
||||||
for i in message.inv:
|
for i in message.inv:
|
||||||
if i.type == MSG_TX:
|
if (i.type == MSG_TX) or (i.type == MSG_WTX):
|
||||||
# save txid
|
# save txid
|
||||||
self.tx_invs_received[i.hash] += 1
|
self.tx_invs_received[i.hash] += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue