Skip to content

Commit 9bb1cf4

Browse files
committed
test: add platforban message to test framework
1 parent fe94d7d commit 9bb1cf4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/functional/test_framework/messages.py

+35
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,41 @@ def __repr__(self):
23452345
(self.nVersion, repr(self.inputs), self.txid, self.cycleHash)
23462346

23472347

2348+
class msg_platformban:
2349+
__slots__ = ("protx_hash", "requested_height", "quorum_hash", "sig")
2350+
msgtype = b"platformban"
2351+
2352+
def __init__(self, protx_hash=0, requested_height=0, quorum_hash=0, sig=b'\x00' * 96):
2353+
self.protx_hash = protx_hash
2354+
self.requested_height = requested_height
2355+
self.quorum_hash = quorum_hash
2356+
self.sig = sig
2357+
2358+
def deserialize(self, f):
2359+
self.protx_hash = deser_uint256(f)
2360+
self.requested_height= struct.unpack("<I", f.read(4))[0]
2361+
self.quorum_hash = deser_uint256(f)
2362+
self.sig = f.read(96)
2363+
2364+
def serialize(self):
2365+
r = b""
2366+
r += ser_uint256(self.protx_hash)
2367+
r += struct.pack("<I", self.requested_height)
2368+
r += ser_uint256(self.quorum_hash)
2369+
r += self.sig
2370+
return r
2371+
2372+
def calc_sha256(self):
2373+
r = b""
2374+
r += ser_uint256(self.protx_hash)
2375+
r += struct.pack("<I", self.requested_height)
2376+
return uint256_from_str(hash256(r))
2377+
2378+
def __repr__(self):
2379+
return "msg_platformban(protx_hash=%064x requested_height=%d, quorum_hash=%064x)" % \
2380+
(self.protx_hash, self.requested_height, self.quorum_hash)
2381+
2382+
23482383
class msg_qsigshare:
23492384
__slots__ = ("sig_shares",)
23502385
msgtype = b"qsigshare"

test/functional/test_framework/p2p.py

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
msg_merkleblock,
6666
msg_notfound,
6767
msg_ping,
68+
msg_platformban,
6869
msg_pong,
6970
msg_qdata,
7071
msg_qgetdata,
@@ -154,6 +155,7 @@
154155
b"isdlock": msg_isdlock,
155156
b"mnlistdiff": msg_mnlistdiff,
156157
b"notfound": msg_notfound,
158+
b"platformban": msg_platformban,
157159
b"qdata": msg_qdata,
158160
b"qfcommit": None,
159161
b"qgetdata": msg_qgetdata,
@@ -591,6 +593,7 @@ def on_clsig(self, message): pass
591593
def on_isdlock(self, message): pass
592594
def on_islock(self, message): pass
593595
def on_mnlistdiff(self, message): pass
596+
def on_platformban(self, message): pass
594597
def on_qdata(self, message): pass
595598
def on_qgetdata(self, message): pass
596599
def on_qwatch(self, message): pass

0 commit comments

Comments
 (0)