Skip to content

Commit 8a365df

Browse files
committed
[test] fix bug in ExcludeIndividualFlags
PR #19168 introduced this function but it always returns an empty vector.
1 parent 8cac292 commit 8a365df

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/test/transaction_tests.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,17 @@ unsigned int FillFlags(unsigned int flags)
152152
return flags;
153153
}
154154

155-
// Return valid flags that are all except one flag for each flag
156-
std::vector<unsigned int> ExcludeIndividualFlags(unsigned int flags)
155+
// Exclude each possible script verify flag from flags. Returns a set of these flag combinations
156+
// that are valid and without duplicates. For example: if flags=1111 and the 4 possible flags are
157+
// 0001, 0010, 0100, and 1000, this should return the set {0111, 1011, 1101, 1110}.
158+
// Assumes that mapFlagNames contains all script verify flags.
159+
std::set<unsigned int> ExcludeIndividualFlags(unsigned int flags)
157160
{
158-
std::vector<unsigned int> flags_combos;
159-
for (unsigned int i = 0; i < mapFlagNames.size(); ++i) {
160-
const unsigned int flags_excluding_i = TrimFlags(flags & ~(1U << i));
161-
if (flags != flags_excluding_i && std::find(flags_combos.begin(), flags_combos.end(), flags_excluding_i) != flags_combos.end()) {
162-
flags_combos.push_back(flags_excluding_i);
161+
std::set<unsigned int> flags_combos;
162+
for (const auto& pair : mapFlagNames) {
163+
const unsigned int flags_excluding_one = TrimFlags(flags & ~(pair.second));
164+
if (flags != flags_excluding_one) {
165+
flags_combos.insert(flags_excluding_one);
163166
}
164167
}
165168
return flags_combos;

0 commit comments

Comments
 (0)