mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
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:
parent
998386d446
commit
3e167085ba
1 changed files with 6 additions and 1 deletions
|
@ -925,7 +925,12 @@ BOOST_AUTO_TEST_CASE(script_json_test)
|
|||
if (test.size() > 0 && test[pos].isArray()) {
|
||||
unsigned int i=0;
|
||||
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]);
|
||||
pos++;
|
||||
|
|
Loading…
Add table
Reference in a new issue