@@ -331,7 +331,7 @@ func TestVerifyBlockFee(t *testing.T) {
331331 txs []* types.Transaction
332332 receipts []* types.Receipt
333333 extraStateContribution * big.Int
334- shouldErr bool
334+ expectedErr error
335335 }{
336336 "tx only base fee" : {
337337 baseFee : big .NewInt (100 ),
@@ -344,7 +344,7 @@ func TestVerifyBlockFee(t *testing.T) {
344344 {GasUsed : 1000 },
345345 },
346346 extraStateContribution : nil ,
347- shouldErr : true ,
347+ expectedErr : ErrInsufficientBlockGas ,
348348 },
349349 "tx covers exactly block fee" : {
350350 baseFee : big .NewInt (100 ),
@@ -357,7 +357,6 @@ func TestVerifyBlockFee(t *testing.T) {
357357 {GasUsed : 100_000 },
358358 },
359359 extraStateContribution : nil ,
360- shouldErr : false ,
361360 },
362361 "txs share block fee" : {
363362 baseFee : big .NewInt (100 ),
@@ -372,7 +371,6 @@ func TestVerifyBlockFee(t *testing.T) {
372371 {GasUsed : 100_000 },
373372 },
374373 extraStateContribution : nil ,
375- shouldErr : false ,
376374 },
377375 "txs split block fee" : {
378376 baseFee : big .NewInt (100 ),
@@ -387,7 +385,6 @@ func TestVerifyBlockFee(t *testing.T) {
387385 {GasUsed : 100_000 },
388386 },
389387 extraStateContribution : nil ,
390- shouldErr : false ,
391388 },
392389 "split block fee with extra state contribution" : {
393390 baseFee : big .NewInt (100 ),
@@ -400,7 +397,6 @@ func TestVerifyBlockFee(t *testing.T) {
400397 {GasUsed : 100_000 },
401398 },
402399 extraStateContribution : big .NewInt (5_000_000 ),
403- shouldErr : false ,
404400 },
405401 "extra state contribution insufficient" : {
406402 baseFee : big .NewInt (100 ),
@@ -409,7 +405,7 @@ func TestVerifyBlockFee(t *testing.T) {
409405 txs : nil ,
410406 receipts : nil ,
411407 extraStateContribution : big .NewInt (9_999_999 ),
412- shouldErr : true ,
408+ expectedErr : ErrInsufficientBlockGas ,
413409 },
414410 "negative extra state contribution" : {
415411 baseFee : big .NewInt (100 ),
@@ -418,7 +414,7 @@ func TestVerifyBlockFee(t *testing.T) {
418414 txs : nil ,
419415 receipts : nil ,
420416 extraStateContribution : big .NewInt (- 1 ),
421- shouldErr : true ,
417+ expectedErr : errInvalidExtraStateChangeContribution ,
422418 },
423419 "extra state contribution covers block fee" : {
424420 baseFee : big .NewInt (100 ),
@@ -427,7 +423,6 @@ func TestVerifyBlockFee(t *testing.T) {
427423 txs : nil ,
428424 receipts : nil ,
429425 extraStateContribution : big .NewInt (10_000_000 ),
430- shouldErr : false ,
431426 },
432427 "extra state contribution covers more than block fee" : {
433428 baseFee : big .NewInt (100 ),
@@ -436,7 +431,6 @@ func TestVerifyBlockFee(t *testing.T) {
436431 txs : nil ,
437432 receipts : nil ,
438433 extraStateContribution : big .NewInt (10_000_001 ),
439- shouldErr : false ,
440434 },
441435 "tx only base fee after full time window" : {
442436 baseFee : big .NewInt (100 ),
@@ -449,7 +443,6 @@ func TestVerifyBlockFee(t *testing.T) {
449443 {GasUsed : 1000 },
450444 },
451445 extraStateContribution : nil ,
452- shouldErr : false ,
453446 },
454447 "tx only base fee after large time window" : {
455448 baseFee : big .NewInt (100 ),
@@ -462,7 +455,6 @@ func TestVerifyBlockFee(t *testing.T) {
462455 {GasUsed : 1000 },
463456 },
464457 extraStateContribution : nil ,
465- shouldErr : false ,
466458 },
467459 "zero block gas cost" : {
468460 baseFee : big .NewInt (100 ),
@@ -484,15 +476,8 @@ func TestVerifyBlockFee(t *testing.T) {
484476 )
485477 bigBlockGasCost := new (big.Int ).SetUint64 (blockGasCost )
486478
487- if err := VerifyBlockFee (test .baseFee , bigBlockGasCost , test .txs , test .receipts , test .extraStateContribution ); err != nil {
488- if ! test .shouldErr {
489- t .Fatalf ("Unexpected error: %s" , err )
490- }
491- } else {
492- if test .shouldErr {
493- t .Fatal ("Should have failed verification" )
494- }
495- }
479+ err := VerifyBlockFee (test .baseFee , bigBlockGasCost , test .txs , test .receipts , test .extraStateContribution )
480+ require .ErrorIs (t , err , test .expectedErr )
496481 })
497482 }
498483}
0 commit comments