tests: add Hypothesis property tests for PSBTParser#911
Open
nkatha23 wants to merge 1 commit intoSeedSigner:devfrom
Open
tests: add Hypothesis property tests for PSBTParser#911nkatha23 wants to merge 1 commit intoSeedSigner:devfrom
nkatha23 wants to merge 1 commit intoSeedSigner:devfrom
Conversation
PSBTParser has no property-based tests. The conservation of value property (input == spend + change + fee) should hold across all combinations of input types, change types, and recipients. Add two tests: - Health check: existing fixtures parse cleanly under Hypothesis - Conservation: spend + change + fee == input_amount for all single-sig input/change/recipient combinations (p2wpkh, p2sh-p2wpkh, p2tr, p2pkh) Add hypothesis and pytest-benchmark to tests/requirements.txt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PSBTParser has no property-based tests. The conservation of value invariant (input_amount == spend + change + fee) is only checked against hardcoded fixtures. Edge case combinations of input types, change outputs, and recipients are never exercised.
hypothesis and pytest-benchmark were also missing from tests/requirements.txt (raised in #899).
Fix:
Two Hypothesis tests in tests/test_psbt_parser_hypothesis.py:
Coverage baseline before this PR:
psbt_parser.py: 88.18%
embit_utils.py: 86.90%