AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 13 Bitcoin

Trim the cache tests down to what catches a regression

Public commit record

What the developer wrote

Authored by kdmukai

83/100 · Strong
Trim the cache tests down to what catches a regression

"Explain how MAX_CACHED_DERIVATIONS was chosen and test the cap" left
test_cache_does_not_change_parse_output hand-rolling its own comparison
as a tuple of field reprs, and promised to move it onto the new
assert_same_parse_result helper. Do that, and put it on patch.object
like the rest of the suite instead of the monkeypatch fixture.

Then measure what the tests around it are worth, by breaking the cache
eleven different ways and recording which tests notice. Two results
stood out.

The equivalence test is differential: it parses once with the cache and
once without and requires the two to agree, so it can only catch a
break that makes those two runs disagree. Anything in logic they share
passes it. Breaking legacy p2sh change detection and breaking taproot
change detection both went unnoticed here; TestPSBTParser is what
catches those. Running it across four wallet types and both fingerprint
states was therefore buying nothing, and all eight cases detect exactly
what two of them do. Narrow it to one single-sig and one multisig psbt,
the two routes into the cache, and drop the fingerprint-zeroing
variants: test_zero_fingerprint_fill_over_many_inputs is what actually
catches a break in the fill path.

test_derive_with_cache_matches_plain_derive caught nothing that
test_get_cosigners_identical_with_and_without_cache does not also
catch, so remove it.

Nothing covered the parse dropping its cache when it ends. Deleting
that clear leaves the whole suite green, and the cache holds keys
derived from the signing seed, so add a test that asserts the parse
filled the cache it was handed and that the parser is no longer holding
it afterward.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit only changes test code in tests/test_psbt_parser.py. It trims redundant test cases, switches from monkeypatch to patch.object, adds a helper assertion, and adds a new test verifying that a sensitive in-memory cache is cleared after parsing. There is no change to the actual PSBT parsing or caching logic in the application, so it does not introduce or fix a runtime security vulnerability on its own.

Recommended action

No security action required for this commit. Treat as routine test maintenance. If reviewing the broader feature, verify that production PSBTParser actually clears _child_key_derivation_cache after parse, since the new test only asserts current behavior.

Security signals we found

01

New test asserts that child key derivation cache is cleared after PSBT parse finishes

02

Commit message notes cache holds keys derived from the signing seed

03

Refactor of existing differential cache test; no production logic changed

Risk score

Why this scored 13/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 9/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.