Merge bitcoin/bitcoin#29363: test: Fix CPartialMerkleTree.nTransactions signedness

facafa90f7 test: Fix CPartialMerkleTree.nTransactions signedness (MarcoFalke)

Pull request description:

  It is unsigned in Bitcoin Core, so the tests should match it:

  aa9231fafe/src/merkleblock.h (L59)

  Large positive values, or "negative" values, are rejected anyway, but it still seems fine to fix this.

  The bug was introduced when the code was written in d280617bf5.

  (Lowercase `i` means signed, see https://docs.python.org/3/library/struct.html#format-characters)

ACKs for top commit:
  theStack:
    LGTM ACK facafa90f7
  Empact:
    ACK facafa90f7

Tree-SHA512: 35ac11bb5382dffe132bfae6097efc343ef6c06b1b4b1545130ca27b228ca6894679004862fee921b095172abaddbef5972c24d9bc195ce970f35643bd4a0f09
pull/29404/head
fanquake 9 months ago
commit 6737331c4c
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

@ -1063,7 +1063,7 @@ class CPartialMerkleTree:
self.vBits = []
def deserialize(self, f):
self.nTransactions = int.from_bytes(f.read(4), "little", signed=True)
self.nTransactions = int.from_bytes(f.read(4), "little")
self.vHash = deser_uint256_vector(f)
vBytes = deser_string(f)
self.vBits = []
@ -1072,7 +1072,7 @@ class CPartialMerkleTree:
def serialize(self):
r = b""
r += self.nTransactions.to_bytes(4, "little", signed=True)
r += self.nTransactions.to_bytes(4, "little")
r += ser_uint256_vector(self.vHash)
vBytesArray = bytearray([0x00] * ((len(self.vBits) + 7)//8))
for i in range(len(self.vBits)):

Loading…
Cancel
Save