test: Ensures test fails if witness is not hex
This commit ensures that we do not fail silently when the test script encounters a witness string in the JSON test data that can not be parsed as hex.
This commit is contained in:
1 parent
998386d446
commit
3e167085ba
1 file changed
+6
-1
@@ -925,7 +925,12 @@ BOOST_AUTO_TEST_CASE(script_json_test)
|
|||||||
if (test.size() > 0 && test[pos].isArray()) {
|
if (test.size() > 0 && test[pos].isArray()) {
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
for (i = 0; i < test[pos].size()-1; i++) {
|
for (i = 0; i < test[pos].size()-1; i++) {
|
||||||
witness.stack.push_back(ParseHex(test[pos][i].get_str()));
|
auto element = test[pos][i].get_str();
|
||||||
|
const auto witness_value{TryParseHex<unsigned char>(element)};
|
||||||
|
if (!witness_value.has_value()) {
|
||||||
|
BOOST_ERROR("Bad witness in test: " << strTest << " witness is not hex: " << element);
|
||||||
|
}
|
||||||
|
witness.stack.push_back(witness_value.value());
|
||||||
}
|
}
|
||||||
nValue = AmountFromValue(test[pos][i]);
|
nValue = AmountFromValue(test[pos][i]);
|
||||||
pos++;
|
pos++;
|
||||||
|
|||||||
Reference in new issue
Block a user