aboutsummaryrefslogtreecommitdiff
path: root/src/test/descriptor_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2018-10-13 10:45:15 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2018-10-26 10:21:05 -0700
commit9b2a25b13f81a45ff59a6a4adde595404a6c062a (patch)
treef2035f603310c78274f872bd15245ecbe4ef6c56 /src/test/descriptor_tests.cpp
parent225bf3e3b0a89a285da451cd589be148324039ab (diff)
Add tests for InferDescriptor and Descriptor::IsSolvable
Diffstat (limited to 'src/test/descriptor_tests.cpp')
-rw-r--r--src/test/descriptor_tests.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/descriptor_tests.cpp b/src/test/descriptor_tests.cpp
index f3083bab4a..7e9d14a8ef 100644
--- a/src/test/descriptor_tests.cpp
+++ b/src/test/descriptor_tests.cpp
@@ -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) {