Changeset View
Changeset View
Standalone View
Standalone View
src/test/descriptor_tests.cpp
Show All 24 Lines | |||||
} | } | ||||
constexpr int DEFAULT = 0; | constexpr int DEFAULT = 0; | ||||
// Expected to be ranged descriptor | // Expected to be ranged descriptor | ||||
constexpr int RANGE = 1; | constexpr int RANGE = 1; | ||||
// Derivation needs access to private keys | // Derivation needs access to private keys | ||||
constexpr int HARDENED = 2; | constexpr int HARDENED = 2; | ||||
// This descriptor is not expected to be solvable | // This descriptor is not expected to be solvable | ||||
// constexpr int UNSOLVABLE = 4; | constexpr int UNSOLVABLE = 4; | ||||
// We can sign with this descriptor (this is not true when actual BIP32 | // We can sign with this descriptor (this is not true when actual BIP32 | ||||
// derivation is used, as that's not integrated in our signing code) | // derivation is used, as that's not integrated in our signing code) | ||||
constexpr int SIGNABLE = 8; | constexpr int SIGNABLE = 8; | ||||
std::string MaybeUseHInsteadOfApostrophy(std::string ret) { | std::string MaybeUseHInsteadOfApostrophy(std::string ret) { | ||||
if (InsecureRandBool()) { | if (InsecureRandBool()) { | ||||
while (true) { | while (true) { | ||||
auto it = ret.find("'"); | auto it = ret.find("'"); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < max; ++i) { | ||||
FlatSigningProvider script_provider; | FlatSigningProvider script_provider; | ||||
std::vector<CScript> spks; | std::vector<CScript> spks; | ||||
BOOST_CHECK((t ? parse_priv : parse_pub) | BOOST_CHECK((t ? parse_priv : parse_pub) | ||||
->Expand(i, key_provider, spks, script_provider)); | ->Expand(i, key_provider, spks, script_provider)); | ||||
BOOST_CHECK_EQUAL(spks.size(), ref.size()); | BOOST_CHECK_EQUAL(spks.size(), ref.size()); | ||||
for (size_t n = 0; n < spks.size(); ++n) { | for (size_t n = 0; n < spks.size(); ++n) { | ||||
BOOST_CHECK_EQUAL(ref[n], | BOOST_CHECK_EQUAL(ref[n], | ||||
HexStr(spks[n].begin(), spks[n].end())); | HexStr(spks[n].begin(), spks[n].end())); | ||||
BOOST_CHECK_EQUAL( | |||||
IsSolvable(Merge(key_provider, script_provider), spks[n]), | |||||
(flags & UNSOLVABLE) == 0); | |||||
if (flags & SIGNABLE) { | if (flags & SIGNABLE) { | ||||
CMutableTransaction spend; | CMutableTransaction spend; | ||||
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, | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |