Changeset View
Changeset View
Standalone View
Standalone View
src/test/descriptor_tests.cpp
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < max; ++i) { | ||||
spend.vin.resize(1); | spend.vin.resize(1); | ||||
spend.vout.resize(1); | spend.vout.resize(1); | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
SignSignature(Merge(keys_priv, script_provider), | SignSignature(Merge(keys_priv, script_provider), | ||||
spks[n], spend, 0, 1 * COIN, | spks[n], spend, 0, 1 * COIN, | ||||
SigHashType().withForkId()), | SigHashType().withForkId()), | ||||
prv); | 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' | // Test whether the observed key path is present in the 'paths' | ||||
// variable (which contains expected, unobserved paths), and then | // variable (which contains expected, unobserved paths), and then | ||||
// remove it from that set. | // remove it from that set. | ||||
for (const auto &origin : script_provider.origins) { | for (const auto &origin : script_provider.origins) { | ||||
BOOST_CHECK_MESSAGE(paths.count(origin.second.path), | BOOST_CHECK_MESSAGE(paths.count(origin.second.path), | ||||
"Unexpected key path: " + prv); | "Unexpected key path: " + prv); | ||||
left_paths.erase(origin.second.path); | left_paths.erase(origin.second.path); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines |