Skip to content

Commit

Permalink
Review fix: guard againt hashing a None transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
hcleonis committed Jul 9, 2020
1 parent d882cc9 commit 23ab55a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/helpers/txparser/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ def _recursive_hash_obj(obj: Any,
tmp = path[:]
tmp.append(key)
_recursive_hash_obj(getattr(obj, key), hasher, ignored_fields, tmp, show_path)
else:
elif isinstance(obj, (bytes, bytearray)):
# Terminal byte object, add it to the hash
if show_path:
print(f"Adding to hash: {'/'.join(path)} = {cast(bytes, obj).hex()}")
hasher.update(cast(bytes, obj))
# else return without hashing a None object (not supported by sha256())

h1, h2 = (sha256(), sha256())
if isinstance(tx, (bytes, bytearray)):
Expand Down

0 comments on commit 23ab55a

Please sign in to comment.