Skip to content

Commit 530ae91

Browse files
committed
test: gasRewards are negative if GasFeeCap too low
1 parent 3dcd10c commit 530ae91

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pkg/messagepool/messagepool_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,36 @@ func TestPruningSimple(t *testing.T) {
690690
}
691691
}
692692

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+
693723
func TestLoadLocal(t *testing.T) {
694724
tf.UnitTest(t)
695725

0 commit comments

Comments
 (0)