diff --git a/src/script/sign.h b/src/script/sign.h --- a/src/script/sign.h +++ b/src/script/sign.h @@ -24,6 +24,12 @@ struct KeyOriginInfo { uint8_t fingerprint[4]; std::vector path; + + friend bool operator==(const KeyOriginInfo &a, const KeyOriginInfo &b) { + return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), + std::begin(b.fingerprint)) && + a.path == b.path; + } }; /** An interface to be implemented by keystores that support signing. */ diff --git a/src/test/descriptor_tests.cpp b/src/test/descriptor_tests.cpp --- a/src/test/descriptor_tests.cpp +++ b/src/test/descriptor_tests.cpp @@ -121,7 +121,25 @@ SigHashType().withForkId()), prv); } + + // Infer a descriptor from the generated script, and verify its + // solvability and that it roundtrips. + auto inferred = InferDescriptor(spks[n], script_provider); + BOOST_CHECK_EQUAL(inferred->IsSolvable(), + !(flags & UNSOLVABLE)); + std::vector spks_inferred; + FlatSigningProvider provider_inferred; + BOOST_CHECK(inferred->Expand(0, provider_inferred, + spks_inferred, provider_inferred)); + BOOST_CHECK_EQUAL(spks_inferred.size(), 1); + BOOST_CHECK(spks_inferred[0] == spks[n]); + BOOST_CHECK_EQUAL( + IsSolvable(provider_inferred, spks_inferred[0]), + !(flags & UNSOLVABLE)); + BOOST_CHECK(provider_inferred.origins == + script_provider.origins); } + // Test whether the observed key path is present in the 'paths' // variable (which contains expected, unobserved paths), and then // remove it from that set.