Skip to content

Commit 644772b

Browse files
committed
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 42bbbba). 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.
1 parent 0ebd4db commit 644772b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

contrib/message-capture/message-capture-parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def to_jsonable(obj: Any) -> Any:
7979
val = getattr(obj, slot, None)
8080
if slot in HASH_INTS and isinstance(val, int):
8181
ret[slot] = ser_uint256(val).hex()
82-
elif slot in HASH_INT_VECTORS:
83-
assert all(isinstance(a, int) for a in val)
82+
elif slot in HASH_INT_VECTORS and all(isinstance(a, int) for a in val):
8483
ret[slot] = [ser_uint256(a).hex() for a in val]
8584
else:
8685
ret[slot] = to_jsonable(val)

0 commit comments

Comments
 (0)