@@ -748,6 +748,32 @@ FUZZ_TARGET(txgraph)
748
748
}
749
749
builder_data.done = new_done;
750
750
break ;
751
+ } else if (!main_sim.IsOversized () && command-- == 0 ) {
752
+ // GetWorstMainChunk.
753
+ auto [worst_chunk, worst_chunk_feerate] = real->GetWorstMainChunk ();
754
+ // Just do some sanity checks here. Consistency with GetBlockBuilder is checked
755
+ // below.
756
+ if (main_sim.GetTransactionCount () == 0 ) {
757
+ assert (worst_chunk.empty ());
758
+ assert (worst_chunk_feerate.IsEmpty ());
759
+ } else {
760
+ assert (!worst_chunk.empty ());
761
+ SimTxGraph::SetType done;
762
+ FeePerWeight sum;
763
+ for (TxGraph::Ref* ref : worst_chunk) {
764
+ // Each transaction in the chunk must exist in the main graph.
765
+ auto simpos = main_sim.Find (ref);
766
+ assert (simpos != SimTxGraph::MISSING);
767
+ sum += main_sim.graph .FeeRate (simpos);
768
+ // Make sure the chunk contains no duplicate transactions.
769
+ assert (!done[simpos]);
770
+ done.Set (simpos);
771
+ // All elements are preceded by all their descendants.
772
+ assert (main_sim.graph .Descendants (simpos).IsSubsetOf (done));
773
+ }
774
+ assert (sum == worst_chunk_feerate);
775
+ }
776
+ break ;
751
777
}
752
778
}
753
779
}
@@ -806,6 +832,8 @@ FUZZ_TARGET(txgraph)
806
832
// if nothing is skipped.
807
833
auto builder = real->GetBlockBuilder ();
808
834
std::vector<SimTxGraph::Pos> vec_builder;
835
+ std::vector<TxGraph::Ref*> last_chunk;
836
+ FeePerWeight last_chunk_feerate;
809
837
while (auto chunk = builder->GetCurrentChunk ()) {
810
838
FeePerWeight sum;
811
839
for (TxGraph::Ref* ref : chunk->first ) {
@@ -820,10 +848,18 @@ FUZZ_TARGET(txgraph)
820
848
vec_builder.push_back (simpos);
821
849
}
822
850
assert (sum == chunk->second );
851
+ last_chunk = std::move (chunk->first );
852
+ last_chunk_feerate = chunk->second ;
823
853
builder->Include ();
824
854
}
825
855
assert (vec_builder == vec1);
826
856
857
+ // The last chunk returned by the BlockBuilder must match GetWorstMainChunk, in reverse.
858
+ std::reverse (last_chunk.begin (), last_chunk.end ());
859
+ auto [worst_chunk, worst_chunk_feerate] = real->GetWorstMainChunk ();
860
+ assert (last_chunk == worst_chunk);
861
+ assert (last_chunk_feerate == worst_chunk_feerate);
862
+
827
863
// Check that the implied ordering gives rise to a combined diagram that matches the
828
864
// diagram constructed from the individual cluster linearization chunkings.
829
865
auto main_real_diagram = get_diagram_fn (/* main_only=*/ true );
0 commit comments