@@ -690,6 +690,36 @@ func TestPruningSimple(t *testing.T) {
690
690
}
691
691
}
692
692
693
+ func TestGasRewardNegative (t * testing.T ) {
694
+ var mp MessagePool
695
+
696
+ msg := types.SignedMessage {
697
+ Message : types.Message {
698
+ GasLimit : 1000 ,
699
+ GasFeeCap : tbig .NewInt (20000 ),
700
+ GasPremium : tbig .NewInt (15000 ),
701
+ },
702
+ }
703
+ baseFee := tbig .NewInt (30000 )
704
+ // Over the GasPremium, but under the BaseFee
705
+ gr1 := mp .getGasReward (& msg , baseFee )
706
+
707
+ msg .Message .GasFeeCap = tbig .NewInt (15000 )
708
+ // Equal to GasPremium, under the BaseFee
709
+ gr2 := mp .getGasReward (& msg , baseFee )
710
+
711
+ msg .Message .GasFeeCap = tbig .NewInt (10000 )
712
+ // Under both GasPremium and BaseFee
713
+ gr3 := mp .getGasReward (& msg , baseFee )
714
+
715
+ assert .True (t , gr1 .Sign () < 0 )
716
+ assert .True (t , gr2 .Sign () < 0 )
717
+ assert .True (t , gr3 .Sign () < 0 )
718
+
719
+ assert .True (t , gr1 .Cmp (gr2 ) > 0 )
720
+ assert .True (t , gr2 .Cmp (gr3 ) > 0 )
721
+ }
722
+
693
723
func TestLoadLocal (t * testing.T ) {
694
724
tf .UnitTest (t )
695
725
0 commit comments