26
26
27
27
#include < cstdint>
28
28
#include < fstream>
29
+ #include < optional>
29
30
#include < string>
30
31
#include < vector>
31
32
@@ -1740,8 +1741,10 @@ static void AssetTest(const UniValue& test)
1740
1741
// "final": true tests are valid for all flags. Others are only valid with flags that are
1741
1742
// a subset of test_flags.
1742
1743
if (fin || ((flags & test_flags) == flags)) {
1743
- bool ret = VerifyScript (tx.vin [idx].scriptSig , prevouts[idx].scriptPubKey , &tx.witness .vtxinwit [idx].scriptWitness , flags, txcheck, nullptr );
1744
+ ScriptError serror;
1745
+ bool ret = VerifyScript (tx.vin [idx].scriptSig , prevouts[idx].scriptPubKey , &tx.witness .vtxinwit [idx].scriptWitness , flags, txcheck, &serror);
1744
1746
BOOST_CHECK (ret);
1747
+ BOOST_CHECK_EQUAL (serror, SCRIPT_ERR_OK);
1745
1748
}
1746
1749
}
1747
1750
}
@@ -1753,11 +1756,22 @@ static void AssetTest(const UniValue& test)
1753
1756
PrecomputedTransactionData txdata (hash_genesis_block);
1754
1757
txdata.Init (tx, std::vector<CTxOut>(prevouts));
1755
1758
CachingTransactionSignatureChecker txcheck (&tx, idx, prevouts[idx].nValue , true , txdata);
1759
+
1760
+ std::optional<ScriptError> expected_error;
1761
+ if (test[" failure" ].exists (" error" )) {
1762
+ expected_error = ParseScriptError (test[" failure" ][" error" ].get_str ());
1763
+ }
1764
+
1756
1765
for (const auto flags : ALL_CONSENSUS_FLAGS) {
1757
1766
// If a test is supposed to fail with test_flags, it should also fail with any superset thereof.
1758
1767
if ((flags & test_flags) == test_flags) {
1759
- bool ret = VerifyScript (tx.vin [idx].scriptSig , prevouts[idx].scriptPubKey , &tx.witness .vtxinwit [idx].scriptWitness , flags, txcheck, nullptr );
1768
+ ScriptError serror;
1769
+ bool ret = VerifyScript (tx.vin [idx].scriptSig , prevouts[idx].scriptPubKey , &tx.witness .vtxinwit [idx].scriptWitness , flags, txcheck, &serror);
1760
1770
BOOST_CHECK (!ret);
1771
+
1772
+ if (expected_error) {
1773
+ BOOST_CHECK_EQUAL (serror, *expected_error);
1774
+ }
1761
1775
}
1762
1776
}
1763
1777
}
0 commit comments