Skip to content

Commit

Permalink
[test] fix bug in ExcludeIndividualFlags
Browse files Browse the repository at this point in the history
PR bitcoin#19168 introduced this function but it always returns an empty vector.
  • Loading branch information
glozow committed Apr 8, 2021
1 parent 8cac292 commit 8a365df
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/test/transaction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8a365df

Please sign in to comment.