From 519966efff46e8582dee69c1e233ca0c29b67bf9 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 1 Nov 2024 15:16:42 +0300 Subject: [PATCH] refactor: Refactor `CCbTx` python class to match c++ declaration --- .../feature_dip4_coinbasemerkleroots.py | 2 +- test/functional/feature_llmq_rotation.py | 2 +- test/functional/test_framework/messages.py | 44 ++++++++++--------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/test/functional/feature_dip4_coinbasemerkleroots.py b/test/functional/feature_dip4_coinbasemerkleroots.py index 844e26ea61..ac45de1176 100755 --- a/test/functional/feature_dip4_coinbasemerkleroots.py +++ b/test/functional/feature_dip4_coinbasemerkleroots.py @@ -204,7 +204,7 @@ class LLMQCoinbaseCommitmentsTest(DashTestFramework): cbtx = CCbTx() cbtx.deserialize(BytesIO(d.cbTx.vExtraPayload)) - if cbtx.version >= 2: + if cbtx.nVersion >= 2: hashes = [] for qc in newQuorumList.values(): hashes.append(hash256(qc.serialize())) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 31e637686b..3d933eb8e4 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -252,7 +252,7 @@ class LLMQQuorumRotationTest(DashTestFramework): cbtx = CCbTx() cbtx.deserialize(BytesIO(d.cbTx.vExtraPayload)) - if cbtx.version >= 2: + if cbtx.nVersion >= 2: hashes = [] for qc in newQuorumList.values(): hashes.append(hash256(qc.serialize())) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index ac0cb3faa2..ae2c405e6e 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -1094,14 +1094,14 @@ class CMerkleBlock: class CCbTx: - __slots__ = ("version", "height", "merkleRootMNList", "merkleRootQuorums", "bestCLHeightDiff", "bestCLSignature", "lockedAmount") + __slots__ = ("nVersion", "nHeight", "merkleRootMNList", "merkleRootQuorums", "bestCLHeightDiff", "bestCLSignature", "assetLockedAmount") - def __init__(self, version=None, height=None, merkleRootMNList=None, merkleRootQuorums=None, bestCLHeightDiff=None, bestCLSignature=None, lockedAmount=None): + def __init__(self, version=None, height=None, merkleRootMNList=None, merkleRootQuorums=None, bestCLHeightDiff=None, bestCLSignature=None, assetLockedAmount=None): self.set_null() if version is not None: - self.version = version + self.nVersion = version if height is not None: - self.height = height + self.nHeight = height if merkleRootMNList is not None: self.merkleRootMNList = merkleRootMNList if merkleRootQuorums is not None: @@ -1110,42 +1110,46 @@ class CCbTx: self.bestCLHeightDiff = bestCLHeightDiff if bestCLSignature is not None: self.bestCLSignature = bestCLSignature - if lockedAmount is not None: - self.lockedAmount = lockedAmount + if assetLockedAmount is not None: + self.assetLockedAmount = assetLockedAmount def set_null(self): - self.version = 0 - self.height = 0 + self.nVersion = 0 + self.nHeight = 0 self.merkleRootMNList = None + self.merkleRootQuorums = None self.bestCLHeightDiff = 0 self.bestCLSignature = b'\x00' * 96 - self.lockedAmount = 0 + self.assetLockedAmount = 0 def deserialize(self, f): - self.version = struct.unpack("= 2: + if self.nVersion >= 2: self.merkleRootQuorums = deser_uint256(f) - if self.version >= 3: + if self.nVersion >= 3: self.bestCLHeightDiff = deser_compact_size(f) self.bestCLSignature = f.read(96) - self.lockedAmount = struct.unpack("= 2: + if self.nVersion >= 2: r += ser_uint256(self.merkleRootQuorums) - if self.version >= 3: + if self.nVersion >= 3: r += ser_compact_size(self.bestCLHeightDiff) r += self.bestCLSignature - r += struct.pack("