mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-22 04:38:55 +02:00
Consolidate redundant implementations of ParseHashStr
This change: * adds a length check to ParseHashStr, appropriate given its use to populate a 256-bit number from a hex str. * allows the caller to handle the failure, which allows for the more appropriate JSONRPCError on failure in prioritisetransaction rpc
This commit is contained in:
@@ -114,7 +114,8 @@ BOOST_AUTO_TEST_CASE(blockfilters_json_test)
|
||||
|
||||
unsigned int pos = 0;
|
||||
/*int block_height =*/ test[pos++].get_int();
|
||||
/*uint256 block_hash =*/ ParseHashStr(test[pos++].get_str(), "block_hash");
|
||||
uint256 block_hash;
|
||||
BOOST_CHECK(ParseHashStr(test[pos++].get_str(), block_hash));
|
||||
|
||||
CBlock block;
|
||||
BOOST_REQUIRE(DecodeHexBlk(block, test[pos++].get_str()));
|
||||
@@ -129,9 +130,11 @@ BOOST_AUTO_TEST_CASE(blockfilters_json_test)
|
||||
tx_undo.vprevout.emplace_back(txout, 0, false);
|
||||
}
|
||||
|
||||
uint256 prev_filter_header_basic = ParseHashStr(test[pos++].get_str(), "prev_filter_header_basic");
|
||||
uint256 prev_filter_header_basic;
|
||||
BOOST_CHECK(ParseHashStr(test[pos++].get_str(), prev_filter_header_basic));
|
||||
std::vector<unsigned char> filter_basic = ParseHex(test[pos++].get_str());
|
||||
uint256 filter_header_basic = ParseHashStr(test[pos++].get_str(), "filter_header_basic");
|
||||
uint256 filter_header_basic;
|
||||
BOOST_CHECK(ParseHashStr(test[pos++].get_str(), filter_header_basic));
|
||||
|
||||
BlockFilter computed_filter_basic(BlockFilterType::BASIC, block, block_undo);
|
||||
BOOST_CHECK(computed_filter_basic.GetFilter().GetEncoded() == filter_basic);
|
||||
|
||||
Reference in New Issue
Block a user