HomePhabricator

[electrum] make read_compact_size return None at EOF instead of raising an error

Description

[electrum] make read_compact_size return None at EOF instead of raising an error

Summary:
This is useful for detecting the end of the file without having to wrap the entire parser code in `try: ... except: ... clauses when parsing a PSBT. See D16333 for a use case.
Now this moves the responsibility to raise an error to callers of that function when None is returned, do that in the two callsites.

Add test coverage for read_compact_size, add test coverage for the two errors now raised in deserialize_blob and deserialize_sequence (one of these is already indirectly tested in test_avalanche.py when deserializing garbage data as a Delegation)

Test Plan: python test_runner.py

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D16336

Details

Provenance
PiRKAuthored on Jun 14 2024, 20:01
PiRKPushed on Jun 17 2024, 15:31
Reviewer
Restricted Project
Differential Revision
D16336: [electrum] make read_compact_size return None at EOF instead of raising an error
Parents
rABC59b1ef875c5a: [Cashtab] Improve target output generation tests
Branches
Unknown
Tags
Unknown