fuzz: make sure PSBT serialization roundtrips

This will prevent us from creating a serialization we do not accept
going forward.
This commit is contained in:
Antoine Poinsot 2026-03-03 16:02:01 -05:00
parent e09b81638b
commit d76ec4de14

View File

@ -33,6 +33,17 @@ FUZZ_TARGET(psbt)
}
const PartiallySignedTransaction psbt = psbt_mut;
// A PSBT must roundtrip.
PartiallySignedTransaction psbt_roundtrip;
std::vector<uint8_t> psbt_ser;
VectorWriter{psbt_ser, 0, psbt};
SpanReader{psbt_ser} >> psbt_roundtrip;
// And be stable across roundtrips.
std::vector<uint8_t> roundtrip_ser;
VectorWriter{roundtrip_ser, 0, psbt_roundtrip};
Assert(psbt_ser == roundtrip_ser);
const PSBTAnalysis analysis = AnalyzePSBT(psbt);
(void)PSBTRoleName(analysis.next);
for (const PSBTInputAnalysis& input_analysis : analysis.inputs) {