Skip to content

Commit 23ab55a

Browse files
author
hcleonis
committed
Review fix: guard againt hashing a None transaction
1 parent d882cc9 commit 23ab55a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/helpers/txparser/transaction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,12 @@ def _recursive_hash_obj(obj: Any,
143143
tmp = path[:]
144144
tmp.append(key)
145145
_recursive_hash_obj(getattr(obj, key), hasher, ignored_fields, tmp, show_path)
146-
else:
146+
elif isinstance(obj, (bytes, bytearray)):
147147
# Terminal byte object, add it to the hash
148148
if show_path:
149149
print(f"Adding to hash: {'/'.join(path)} = {cast(bytes, obj).hex()}")
150150
hasher.update(cast(bytes, obj))
151+
# else return without hashing a None object (not supported by sha256())
151152

152153
h1, h2 = (sha256(), sha256())
153154
if isinstance(tx, (bytes, bytearray)):

0 commit comments

Comments
 (0)