Exercise the cache's read path in the equivalence test

Both psbts carried a single change output, so every derivation was a
first-time miss and the cached run only ever wrote to the cache. A
wrong value returned on a hit would have gone unnoticed. Carrying the
change output twice makes the second traversal read back what the
first one cached.
This commit is contained in:
kdmukai
2026-08-14 17:52:32 -05:00
parent 2b1ce93cd7
commit 193728896f
+5 -1
View File
@@ -658,9 +658,13 @@ class TestPSBTParserOptimizations:
each cosigner's account xpub.
"""
def build_psbt(input_base64: str, change_hex: str) -> PSBT:
# A fresh psbt for each parse: the base psbt plus its change output
# A fresh psbt for each parse: the base psbt plus its change output, twice.
psbt = PSBT.parse(a2b_base64(input_base64))
psbt.outputs.append(create_output(change_hex, 10_000))
# Add a duplicate output to ensure that the cache yields some hits; the second
# output will traverse the same levels the first one just cached.
psbt.outputs.append(create_output(change_hex, 10_000))
return psbt
def assert_cache_makes_no_difference(input_base64: str, change_hex: str):