@@ -1088,6 +1088,9 @@ func (suite *BuilderSuite) TestBuildOn_MaxCollectionSizeRateLimiting() {
10881088 // start with an empty mempool
10891089 suite .ClearPool ()
10901090
1091+ cfg := updatable_configs .DefaultBySealingLagRateLimiterConfigs ()
1092+ suite .Require ().NoError (cfg .SetMinSealingLag (50 )) // set min sealing lag to 50 blocks so we can hit rate limiting
1093+ suite .Require ().NoError (cfg .SetMaxSealingLag (50 )) // set max sealing lag to 50 blocks so we can hit rate limiting
10911094 suite .builder , _ = builder .NewBuilder (
10921095 suite .db ,
10931096 trace .NewNoopTracer (),
@@ -1100,7 +1103,7 @@ func (suite *BuilderSuite) TestBuildOn_MaxCollectionSizeRateLimiting() {
11001103 suite .pool ,
11011104 unittest .Logger (),
11021105 suite .epochCounter ,
1103- updatable_configs . DefaultBySealingLagRateLimiterConfigs () ,
1106+ cfg ,
11041107 builder .WithMaxCollectionSize (100 ),
11051108 )
11061109
@@ -1125,27 +1128,36 @@ func (suite *BuilderSuite) TestBuildOn_MaxCollectionSizeRateLimiting() {
11251128 // build a long chain of blocks that were finalized but not sealed
11261129 // this will lead to a big sealing lag.
11271130 for i := 0 ; i < 100 ; i ++ {
1128- block := unittest .BlockWithParentFixture (head )
1129- block .SetPayload (unittest .PayloadFixture (unittest .WithProtocolStateID (protocolStateID )))
1130- err = suite .protoState .ExtendCertified (context .Background (), block , unittest .CertifyBlock (block .Header ))
1131+ block := unittest .BlockWithParentAndPayload (head , unittest .PayloadFixture (unittest .WithProtocolStateID (protocolStateID )))
1132+ err = suite .protoState .ExtendCertified (context .Background (), unittest .NewCertifiedBlock (block ))
11311133 suite .Require ().NoError (err )
11321134 err = suite .protoState .Finalize (context .Background (), block .ID ())
11331135 suite .Require ().NoError (err )
1134- head = block .Header
1136+ head = block .ToHeader ()
11351137 }
11361138
11371139 rateLimiterCfg := updatable_configs .DefaultBySealingLagRateLimiterConfigs ()
11381140
11391141 // rate-limiting should be applied, resulting in minimum collection size.
11401142 parentID := suite .genesis .ID ()
1143+ setter := func (h * flow.HeaderBodyBuilder ) error {
1144+ h .WithChainID (flow .Emulator ).
1145+ WithParentID (parentID ).
1146+ WithView (1337 ).
1147+ WithParentView (1336 ).
1148+ WithParentVoterIndices (unittest .SignerIndicesFixture (4 )).
1149+ WithParentVoterSigData (unittest .QCSigDataFixture ()).
1150+ WithProposerID (unittest .IdentifierFixture ())
1151+ return nil
1152+ }
11411153 for i := 0 ; i < 10 ; i ++ {
1142- header , err := suite .builder .BuildOn (parentID , noopSetter , noopSigner )
1154+ header , err := suite .builder .BuildOn (parentID , setter , signer )
11431155 suite .Require ().NoError (err )
1144- parentID = header .ID ()
1156+ parentID = header .Header . ID ()
11451157
1146- // each collection should be half-full with 5 transactions
1158+ // each collection should be equal to the minimum collection size
11471159 var built model.Block
1148- err = suite .db .View (procedure .RetrieveClusterBlock (header .ID (), & built ))
1160+ err = suite .db .View (procedure .RetrieveClusterBlock (header .Header . ID (), & built ))
11491161 suite .Assert ().NoError (err )
11501162 suite .Assert ().Len (built .Payload .Collection .Transactions , int (rateLimiterCfg .MinCollectionSize ()))
11511163 }
@@ -1382,11 +1394,11 @@ func (suite *BuilderSuite) TestBuildOn_SystemTxAlwaysIncluded() {
13821394
13831395 // rate-limiting should not be applied, since the payer is marked as unlimited
13841396 parentID := suite .genesis .ID ()
1385- header , err := suite .builder .BuildOn (parentID , noopSetter , noopSigner )
1397+ header , err := suite .builder .BuildOn (parentID , setter , signer )
13861398 suite .Require ().NoError (err )
13871399
13881400 var built model.Block
1389- err = suite .db .View (procedure .RetrieveClusterBlock (header .ID (), & built ))
1401+ err = suite .db .View (procedure .RetrieveClusterBlock (header .Header . ID (), & built ))
13901402 suite .Assert ().NoError (err )
13911403 suite .Assert ().Len (built .Payload .Collection .Transactions , 2 )
13921404 for _ , tx := range built .Payload .Collection .Transactions {
0 commit comments