From d76ec4de148724e6b384efb0a4180722ed30db10 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 3 Mar 2026 16:02:01 -0500 Subject: [PATCH] fuzz: make sure PSBT serialization roundtrips This will prevent us from creating a serialization we do not accept going forward. --- src/test/fuzz/psbt.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/fuzz/psbt.cpp b/src/test/fuzz/psbt.cpp index a7b2490e2d7..e0f2177abe3 100644 --- a/src/test/fuzz/psbt.cpp +++ b/src/test/fuzz/psbt.cpp @@ -33,6 +33,17 @@ FUZZ_TARGET(psbt) } const PartiallySignedTransaction psbt = psbt_mut; + // A PSBT must roundtrip. + PartiallySignedTransaction psbt_roundtrip; + std::vector psbt_ser; + VectorWriter{psbt_ser, 0, psbt}; + SpanReader{psbt_ser} >> psbt_roundtrip; + + // And be stable across roundtrips. + std::vector 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) {