qa: better error reporting on descriptor parsing error

A nit, but was helpful when writing unit tests for Miniscript parsing
This commit is contained in:
Antoine Poinsot
2021-10-04 00:18:08 +02:00
parent d25d58bf5f
commit 4a082887be

View File

@@ -141,14 +141,13 @@ void DoCheck(const std::string& prv, const std::string& pub, const std::string&
} else { } else {
parse_priv = Parse(prv, keys_priv, error); parse_priv = Parse(prv, keys_priv, error);
} }
BOOST_CHECK_MESSAGE(parse_priv, error);
if (replace_apostrophe_with_h_in_pub) { if (replace_apostrophe_with_h_in_pub) {
parse_pub = Parse(UseHInsteadOfApostrophe(pub), keys_pub, error); parse_pub = Parse(UseHInsteadOfApostrophe(pub), keys_pub, error);
} else { } else {
parse_pub = Parse(pub, keys_pub, error); parse_pub = Parse(pub, keys_pub, error);
} }
BOOST_CHECK_MESSAGE(parse_pub, error);
BOOST_CHECK(parse_priv);
BOOST_CHECK(parse_pub);
// Check that the correct OutputType is inferred // Check that the correct OutputType is inferred
BOOST_CHECK(parse_priv->GetOutputType() == type); BOOST_CHECK(parse_priv->GetOutputType() == type);
@@ -161,8 +160,8 @@ void DoCheck(const std::string& prv, const std::string& pub, const std::string&
// Check that both versions serialize back to the public version. // Check that both versions serialize back to the public version.
std::string pub1 = parse_priv->ToString(); std::string pub1 = parse_priv->ToString();
std::string pub2 = parse_pub->ToString(); std::string pub2 = parse_pub->ToString();
BOOST_CHECK(EqualDescriptor(pub, pub1)); BOOST_CHECK_MESSAGE(EqualDescriptor(pub, pub1), "Private ser: " + pub1 + " Public desc: " + pub);
BOOST_CHECK(EqualDescriptor(pub, pub2)); BOOST_CHECK_MESSAGE(EqualDescriptor(pub, pub2), "Public ser: " + pub2 + " Public desc: " + pub);
// Check that both can be serialized with private key back to the private version, but not without private key. // Check that both can be serialized with private key back to the private version, but not without private key.
if (!(flags & MISSING_PRIVKEYS)) { if (!(flags & MISSING_PRIVKEYS)) {