mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
message-capture-parser: fix AssertionError on parsing headers
message
If a test framework message's field name is in the list of
`HASH_INT_VECTORS`, we currently assume that it _always_ has to contain
a vector of integers and throw otherwise (introduced in PR #25367,
commit 42bbbba7c8
). However, that
assumption is too strict. In this concrete case, the (de)serialization
field name "headers" is used in two different message types, one for
`cfcheckpt` (where it is serialized as an integer vector), and another
time for `headers` (where it is serialized as a vector of
`CBlockHeader`s). Fix by adding the integer type check as additional
condition to the `HASH_INT_VECTORS` check rather than asserting.
Fixes #25954.
This commit is contained in:
parent
0ebd4db32b
commit
644772b9ef
1 changed files with 1 additions and 2 deletions
|
@ -79,8 +79,7 @@ def to_jsonable(obj: Any) -> Any:
|
||||||
val = getattr(obj, slot, None)
|
val = getattr(obj, slot, None)
|
||||||
if slot in HASH_INTS and isinstance(val, int):
|
if slot in HASH_INTS and isinstance(val, int):
|
||||||
ret[slot] = ser_uint256(val).hex()
|
ret[slot] = ser_uint256(val).hex()
|
||||||
elif slot in HASH_INT_VECTORS:
|
elif slot in HASH_INT_VECTORS and all(isinstance(a, int) for a in val):
|
||||||
assert all(isinstance(a, int) for a in val)
|
|
||||||
ret[slot] = [ser_uint256(a).hex() for a in val]
|
ret[slot] = [ser_uint256(a).hex() for a in val]
|
||||||
else:
|
else:
|
||||||
ret[slot] = to_jsonable(val)
|
ret[slot] = to_jsonable(val)
|
||||||
|
|
Loading…
Add table
Reference in a new issue