mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-06 03:02:37 +02:00
clusterlin: add MergeLinearizations function + fuzz test + benchmark
This commit is contained in:
@@ -929,3 +929,29 @@ FUZZ_TARGET(clusterlin_postlinearize_moved_leaf)
|
||||
auto cmp = CompareChunks(new_chunking, old_chunking);
|
||||
assert(cmp >= 0);
|
||||
}
|
||||
|
||||
FUZZ_TARGET(clusterlin_merge)
|
||||
{
|
||||
// Construct an arbitrary graph from the fuzz input.
|
||||
SpanReader reader(buffer);
|
||||
DepGraph<TestBitSet> depgraph;
|
||||
try {
|
||||
reader >> Using<DepGraphFormatter>(depgraph);
|
||||
} catch (const std::ios_base::failure&) {}
|
||||
|
||||
// Retrieve two linearizations from the fuzz input.
|
||||
auto lin1 = ReadLinearization(depgraph, reader);
|
||||
auto lin2 = ReadLinearization(depgraph, reader);
|
||||
|
||||
// Merge the two.
|
||||
auto lin_merged = MergeLinearizations(depgraph, lin1, lin2);
|
||||
|
||||
// Compute chunkings and compare.
|
||||
auto chunking1 = ChunkLinearization(depgraph, lin1);
|
||||
auto chunking2 = ChunkLinearization(depgraph, lin2);
|
||||
auto chunking_merged = ChunkLinearization(depgraph, lin_merged);
|
||||
auto cmp1 = CompareChunks(chunking_merged, chunking1);
|
||||
assert(cmp1 >= 0);
|
||||
auto cmp2 = CompareChunks(chunking_merged, chunking2);
|
||||
assert(cmp2 >= 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user