aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/messages.py
diff options
context:
space:
mode:
authorJim Posen <jim.posen@gmail.com>2020-05-04 14:10:18 -0400
committerJohn Newbery <john@johnnewbery.com>2020-05-08 16:36:19 -0400
commit23083856a551ca13e8b142791c296ecb25cc4e7f (patch)
tree9fd276e7c7fa030c0d1d139608e72cedd4491776 /test/functional/test_framework/messages.py
parentf9e00bb25ac4039056808affeb5ffa86a2c317fe (diff)
downloadbitcoin-23083856a551ca13e8b142791c296ecb25cc4e7f.tar.xz
[test] Add test for cfcheckpt
Diffstat (limited to 'test/functional/test_framework/messages.py')
-rwxr-xr-xtest/functional/test_framework/messages.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 4855f62a8f..ef5ef49eaf 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -57,6 +57,8 @@ MSG_FILTERED_BLOCK = 3
MSG_WITNESS_FLAG = 1 << 30
MSG_TYPE_MASK = 0xffffffff >> 2
+FILTER_TYPE_BASIC = 0
+
# Serialization/deserialization tools
def sha256(s):
return hashlib.new('sha256', s).digest()
@@ -1512,3 +1514,50 @@ class msg_no_witness_blocktxn(msg_blocktxn):
def serialize(self):
return self.block_transactions.serialize(with_witness=False)
+
+class msg_getcfcheckpt:
+ __slots__ = ("filter_type", "stop_hash")
+ msgtype = b"getcfcheckpt"
+
+ def __init__(self, filter_type, stop_hash):
+ self.filter_type = filter_type
+ self.stop_hash = stop_hash
+
+ def deserialize(self, f):
+ self.filter_type = struct.unpack("<B", f.read(1))[0]
+ self.stop_hash = deser_uint256(f)
+
+ def serialize(self):
+ r = b""
+ r += struct.pack("<B", self.filter_type)
+ r += ser_uint256(self.stop_hash)
+ return r
+
+ def __repr__(self):
+ return "msg_getcfcheckpt(filter_type={:#x}, stop_hash={:x})".format(
+ self.filter_type, self.stop_hash)
+
+class msg_cfcheckpt:
+ __slots__ = ("filter_type", "stop_hash", "headers")
+ msgtype = b"cfcheckpt"
+
+ def __init__(self, filter_type=None, stop_hash=None, headers=None):
+ self.filter_type = filter_type
+ self.stop_hash = stop_hash
+ self.headers = headers
+
+ def deserialize(self, f):
+ self.filter_type = struct.unpack("<B", f.read(1))[0]
+ self.stop_hash = deser_uint256(f)
+ self.headers = deser_uint256_vector(f)
+
+ def serialize(self):
+ r = b""
+ r += struct.pack("<B", self.filter_type)
+ r += ser_uint256(self.stop_hash)
+ r += ser_uint256_vector(self.headers)
+ return r
+
+ def __repr__(self):
+ return "msg_cfcheckpt(filter_type={:#x}, stop_hash={:x})".format(
+ self.filter_type, self.stop_hash)