mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 19:43:13 +02:00
test: Add basic test for BIP 37
This commit is contained in:
@@ -51,6 +51,7 @@ NODE_NETWORK_LIMITED = (1 << 10)
|
||||
|
||||
MSG_TX = 1
|
||||
MSG_BLOCK = 2
|
||||
MSG_FILTERED_BLOCK = 3
|
||||
MSG_WITNESS_FLAG = 1 << 30
|
||||
MSG_TYPE_MASK = 0xffffffff >> 2
|
||||
|
||||
@@ -225,10 +226,11 @@ class CInv:
|
||||
|
||||
typemap = {
|
||||
0: "Error",
|
||||
1: "TX",
|
||||
2: "Block",
|
||||
1|MSG_WITNESS_FLAG: "WitnessTx",
|
||||
2|MSG_WITNESS_FLAG : "WitnessBlock",
|
||||
MSG_TX: "TX",
|
||||
MSG_BLOCK: "Block",
|
||||
MSG_TX | MSG_WITNESS_FLAG: "WitnessTx",
|
||||
MSG_BLOCK | MSG_WITNESS_FLAG: "WitnessBlock",
|
||||
MSG_FILTERED_BLOCK: "filtered Block",
|
||||
4: "CompactBlock"
|
||||
}
|
||||
|
||||
@@ -1318,6 +1320,41 @@ class msg_headers:
|
||||
return "msg_headers(headers=%s)" % repr(self.headers)
|
||||
|
||||
|
||||
class msg_merkleblock:
|
||||
command = b"merkleblock"
|
||||
|
||||
def deserialize(self, f):
|
||||
pass # Placeholder for now
|
||||
|
||||
|
||||
class msg_filterload:
|
||||
__slots__ = ("data", "nHashFuncs", "nTweak", "nFlags")
|
||||
command = b"filterload"
|
||||
|
||||
def __init__(self, data=b'00', nHashFuncs=0, nTweak=0, nFlags=0):
|
||||
self.data = data
|
||||
self.nHashFuncs = nHashFuncs
|
||||
self.nTweak = nTweak
|
||||
self.nFlags = nFlags
|
||||
|
||||
def deserialize(self, f):
|
||||
self.data = deser_string(f)
|
||||
self.nHashFuncs = struct.unpack("<I", f.read(4))[0]
|
||||
self.nTweak = struct.unpack("<I", f.read(4))[0]
|
||||
self.nFlags = struct.unpack("<B", f.read(1))[0]
|
||||
|
||||
def serialize(self):
|
||||
r = b""
|
||||
r += ser_string(self.data)
|
||||
r += struct.pack("<I", self.nHashFuncs)
|
||||
r += struct.pack("<I", self.nTweak)
|
||||
r += struct.pack("<B", self.nFlags)
|
||||
return r
|
||||
|
||||
def __repr__(self):
|
||||
return "msg_filterload(data={}, nHashFuncs={}, nTweak={}, nFlags={})".format(
|
||||
self.data, self.nHashFuncs, self.nTweak, self.nFlags)
|
||||
|
||||
|
||||
class msg_feefilter:
|
||||
__slots__ = ("feerate",)
|
||||
|
Reference in New Issue
Block a user