clusterlin tests: verify that chunks are minimal

This commit is contained in:
Pieter Wuille 2025-03-03 13:40:42 -05:00
parent 379a6506d0
commit c8d2a330b6

View file

@ -967,6 +967,10 @@ FUZZ_TARGET(clusterlin_simple_linearize)
auto perm_chunking = ChunkLinearization(depgraph, perm_linearization);
auto cmp = CompareChunks(simple_chunking, perm_chunking);
assert(cmp >= 0);
// If perm_chunking is diagram-optimal, it cannot have more chunks than
// simple_chunking (as simple_chunking claims to be optimal, which implies minimal
// chunks.
if (cmp == 0) assert(simple_chunking.size() >= perm_chunking.size());
} else {
// Otherwise, fast forward to the last permutation with the same non-topological
// prefix.
@ -1061,6 +1065,9 @@ FUZZ_TARGET(clusterlin_linearize)
// If SimpleLinearize finds the optimal result too, they must be equal (if not,
// SimpleLinearize is broken).
if (simple_optimal) assert(cmp == 0);
// If simple_chunking is diagram-optimal, it cannot have more chunks than chunking (as
// chunking is claimed to be optimal, which implies minimal chunks.
if (cmp == 0) assert(chunking.size() >= simple_chunking.size());
// Compare with a linearization read from the fuzz input.
auto read = ReadLinearization(depgraph, reader);