aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-09-09 10:37:43 +0200
committerMacroFake <falke.marco@gmail.com>2022-09-09 10:38:37 +0200
commit3c5fb9691b7b49042160cb161daa07ab2827c064 (patch)
treed071eab0768a407a4b814222c0171050fb851148 /contrib
parentdd3ada6ec483befcc2233844ebcde26793299064 (diff)
parent644772b9efffda4dac01aff54042b3162079514d (diff)
downloadbitcoin-3c5fb9691b7b49042160cb161daa07ab2827c064.tar.xz
Merge bitcoin/bitcoin#26007: [contrib] message-capture-parser: fix AssertionError on parsing `headers` message
644772b9efffda4dac01aff54042b3162079514d message-capture-parser: fix AssertionError on parsing `headers` message (Sebastian Falbesoner) Pull request description: 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: https://github.com/bitcoin/bitcoin/blob/0ebd4db32b39cb7c505148f090df4b7ac778c307/contrib/message-capture/message-capture-parser.py#L82-L83 (introduced in PR #25367, commit 42bbbba7c83d1e2baad18b4c6f05bad1358eb117). However, that assumption is too strict. 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). Parsing the latter fails as it is not an integer vector and thus triggers the assert. Fix this by adding the integer type check as additional condition to the `HASH_INT_VECTORS` check rather than asserting. Fixes #25954. ACKs for top commit: glozow: ACK 644772b9efffda4dac01aff54042b3162079514d Tree-SHA512: c98a107f6703c6c1a81771907c25bcc171c631b57fd605fbebaedd93d651e2ef02fb5601853a9bc7d659ab531c5f47770181173a36ea2b37f584aa7a37b66505
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/message-capture/message-capture-parser.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/contrib/message-capture/message-capture-parser.py b/contrib/message-capture/message-capture-parser.py
index eefd22a60e..33759ee713 100755
--- a/contrib/message-capture/message-capture-parser.py
+++ b/contrib/message-capture/message-capture-parser.py
@@ -79,8 +79,7 @@ def to_jsonable(obj: Any) -> Any:
val = getattr(obj, slot, None)
if slot in HASH_INTS and isinstance(val, int):
ret[slot] = ser_uint256(val).hex()
- elif slot in HASH_INT_VECTORS:
- assert all(isinstance(a, int) for a in val)
+ elif slot in HASH_INT_VECTORS and all(isinstance(a, int) for a in val):
ret[slot] = [ser_uint256(a).hex() for a in val]
else:
ret[slot] = to_jsonable(val)