mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Add tests for InferDescriptor and Descriptor::IsSolvable
This commit is contained in:
parent
225bf3e3b0
commit
9b2a25b13f
@ -24,6 +24,11 @@ struct KeyOriginInfo
|
||||
{
|
||||
unsigned char fingerprint[4];
|
||||
std::vector<uint32_t> 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. */
|
||||
|
@ -102,7 +102,19 @@ void Check(const std::string& prv, const std::string& pub, int flags, const std:
|
||||
spend.vout.resize(1);
|
||||
BOOST_CHECK_MESSAGE(SignSignature(Merge(keys_priv, script_provider), spks[n], spend, 0, 1, SIGHASH_ALL), 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<CScript> 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.
|
||||
for (const auto& origin : script_provider.origins) {
|
||||
|
Loading…
Reference in New Issue
Block a user