Skip to content

tests: add Hypothesis property tests for PSBTParser#911

Open
nkatha23 wants to merge 1 commit intoSeedSigner:devfrom
nkatha23:hypothesis/psbt-conservation-property
Open

tests: add Hypothesis property tests for PSBTParser#911
nkatha23 wants to merge 1 commit intoSeedSigner:devfrom
nkatha23:hypothesis/psbt-conservation-property

Conversation

@nkatha23
Copy link
Copy Markdown

@nkatha23 nkatha23 commented Apr 10, 2026

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:

  • Health check: existing PSBT fixtures parse cleanly under Hypothesis with no health checks suppressed
  • Conservation property: input_amount == spend + change + fee holds across generated combinations of single-sig inputs, change outputs, and external recipients covering p2wpkh, p2sh-p2wpkh, p2tr, p2pkh
    Coverage baseline before this PR:
    psbt_parser.py: 88.18%
    embit_utils.py: 86.90%

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant