diff options
author | glozow <gzhao408@berkeley.edu> | 2021-02-23 06:56:34 -0800 |
---|---|---|
committer | glozow <gzhao408@berkeley.edu> | 2021-04-07 19:00:17 -0700 |
commit | 8a365df5586b36d1772c78069f9d93c56a81df6f (patch) | |
tree | 0fafacf5b38e3c6c5ae648139f3d6fe8477b6e88 /src/test/transaction_tests.cpp | |
parent | 8cac2923f57ac33848ff41b74c3be520b75936df (diff) |
[test] fix bug in ExcludeIndividualFlags
PR #19168 introduced this function but it always returns an empty vector.
Diffstat (limited to 'src/test/transaction_tests.cpp')
-rw-r--r-- | src/test/transaction_tests.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 8f1d99b199..f87779a478 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -152,14 +152,17 @@ unsigned int FillFlags(unsigned int flags) return flags; } -// Return valid flags that are all except one flag for each flag -std::vector<unsigned int> ExcludeIndividualFlags(unsigned int flags) +// Exclude each possible script verify flag from flags. Returns a set of these flag combinations +// that are valid and without duplicates. For example: if flags=1111 and the 4 possible flags are +// 0001, 0010, 0100, and 1000, this should return the set {0111, 1011, 1101, 1110}. +// Assumes that mapFlagNames contains all script verify flags. +std::set<unsigned int> ExcludeIndividualFlags(unsigned int flags) { - std::vector<unsigned int> flags_combos; - for (unsigned int i = 0; i < mapFlagNames.size(); ++i) { - const unsigned int flags_excluding_i = TrimFlags(flags & ~(1U << i)); - if (flags != flags_excluding_i && std::find(flags_combos.begin(), flags_combos.end(), flags_excluding_i) != flags_combos.end()) { - flags_combos.push_back(flags_excluding_i); + std::set<unsigned int> flags_combos; + for (const auto& pair : mapFlagNames) { + const unsigned int flags_excluding_one = TrimFlags(flags & ~(pair.second)); + if (flags != flags_excluding_one) { + flags_combos.insert(flags_excluding_one); } } return flags_combos; |