txgraph: compare sequence numbers instead of Cluster* (bugfix)

This makes fuzz testing more deterministic, by avoiding the (arbitrary) pointer
value ordering in comparing transactions.
This commit is contained in:
Pieter Wuille
2025-04-01 14:05:56 -04:00
parent b2bb27f40c
commit c72c8d5d45
2 changed files with 61 additions and 26 deletions

View File

@@ -206,11 +206,14 @@ struct SimTxGraph
ret.push_back(ptr);
}
}
// Deduplicate.
std::sort(ret.begin(), ret.end());
ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
// Replace input.
arg = std::move(ret);
// Construct deduplicated version in input (do not use std::sort/std::unique for
// deduplication as it'd rely on non-deterministic pointer comparison).
arg.clear();
for (auto ptr : ret) {
if (std::find(arg.begin(), arg.end(), ptr) == arg.end()) {
arg.push_back(ptr);
}
}
}
};