mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-31 18:22:04 +02:00
[test] check that mapFlagNames is up to date
There is no way to iterate through all script verification flags, and it's not guaranteed that every power of 2 is used. Just make sure that all flags in STANDARD_SCRIPT_VERIFY_FLAGS are present in mapFlagNames; this covers all consensus and policy flags. If mapFlagNames has more flags than STANDARD_SCRIPT_VERIFY_FLAGS, that's okay. Nonexistent flags will be caught by the compiler.
This commit is contained in:
parent
5d3ced72f9
commit
b109bde46a
@ -82,6 +82,16 @@ unsigned int ParseScriptFlags(std::string strFlags)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that all flags in STANDARD_SCRIPT_VERIFY_FLAGS are present in mapFlagNames.
|
||||||
|
bool CheckMapFlagNames()
|
||||||
|
{
|
||||||
|
unsigned int standard_flags_missing{STANDARD_SCRIPT_VERIFY_FLAGS};
|
||||||
|
for (const auto& pair : mapFlagNames) {
|
||||||
|
standard_flags_missing &= ~(pair.second);
|
||||||
|
}
|
||||||
|
return standard_flags_missing == 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::string FormatScriptFlags(unsigned int flags)
|
std::string FormatScriptFlags(unsigned int flags)
|
||||||
{
|
{
|
||||||
if (flags == 0) {
|
if (flags == 0) {
|
||||||
@ -178,6 +188,7 @@ BOOST_FIXTURE_TEST_SUITE(transaction_tests, BasicTestingSetup)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(tx_valid)
|
BOOST_AUTO_TEST_CASE(tx_valid)
|
||||||
{
|
{
|
||||||
|
BOOST_CHECK_MESSAGE(CheckMapFlagNames(), "mapFlagNames is missing a script verification flag");
|
||||||
// Read tests from test/data/tx_valid.json
|
// Read tests from test/data/tx_valid.json
|
||||||
UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
|
UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user