diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-11-02 19:19:39 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-11-28 15:24:49 -0800 |
commit | 82df4c64ffa2f0dd45e7ae694903615358f121a6 (patch) | |
tree | 942cc9dcb23e0004660d129358fd8afed6ba2467 /src/test | |
parent | 1eda33aabc15b905a1e23ffab648ecf2a8f5322b (diff) | |
download | bitcoin-82df4c64ffa2f0dd45e7ae694903615358f121a6.tar.xz |
Add descriptor expansion cache
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/descriptor_tests.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/test/descriptor_tests.cpp b/src/test/descriptor_tests.cpp index 0e98f5a826..1a35b5ea71 100644 --- a/src/test/descriptor_tests.cpp +++ b/src/test/descriptor_tests.cpp @@ -88,9 +88,18 @@ void Check(const std::string& prv, const std::string& pub, int flags, const std: const auto& ref = scripts[(flags & RANGE) ? i : 0]; for (int t = 0; t < 2; ++t) { const FlatSigningProvider& key_provider = (flags & HARDENED) ? keys_priv : keys_pub; - FlatSigningProvider script_provider; - std::vector<CScript> spks; - BOOST_CHECK((t ? parse_priv : parse_pub)->Expand(i, key_provider, spks, script_provider)); + FlatSigningProvider script_provider, script_provider_cached; + std::vector<CScript> spks, spks_cached; + std::vector<unsigned char> cache; + BOOST_CHECK((t ? parse_priv : parse_pub)->Expand(i, key_provider, spks, script_provider, &cache)); + + // Try to expand again using cached data, and compare. + BOOST_CHECK(parse_pub->ExpandFromCache(i, cache, spks_cached, script_provider_cached)); + BOOST_CHECK(spks == spks_cached); + BOOST_CHECK(script_provider.pubkeys == script_provider_cached.pubkeys); + BOOST_CHECK(script_provider.scripts == script_provider_cached.scripts); + BOOST_CHECK(script_provider.origins == script_provider_cached.origins); + BOOST_CHECK_EQUAL(spks.size(), ref.size()); for (size_t n = 0; n < spks.size(); ++n) { BOOST_CHECK_EQUAL(ref[n], HexStr(spks[n].begin(), spks[n].end())); |