Skip to content

Commit

Permalink
test: gasRewards are negative if GasFeeCap too low
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZexiao committed Aug 25, 2023
1 parent 3dcd10c commit 530ae91
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/messagepool/messagepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,36 @@ func TestPruningSimple(t *testing.T) {
}
}

func TestGasRewardNegative(t *testing.T) {
var mp MessagePool

msg := types.SignedMessage{
Message: types.Message{
GasLimit: 1000,
GasFeeCap: tbig.NewInt(20000),
GasPremium: tbig.NewInt(15000),
},
}
baseFee := tbig.NewInt(30000)
// Over the GasPremium, but under the BaseFee
gr1 := mp.getGasReward(&msg, baseFee)

msg.Message.GasFeeCap = tbig.NewInt(15000)
// Equal to GasPremium, under the BaseFee
gr2 := mp.getGasReward(&msg, baseFee)

msg.Message.GasFeeCap = tbig.NewInt(10000)
// Under both GasPremium and BaseFee
gr3 := mp.getGasReward(&msg, baseFee)

assert.True(t, gr1.Sign() < 0)
assert.True(t, gr2.Sign() < 0)
assert.True(t, gr3.Sign() < 0)

assert.True(t, gr1.Cmp(gr2) > 0)
assert.True(t, gr2.Cmp(gr3) > 0)
}

func TestLoadLocal(t *testing.T) {
tf.UnitTest(t)

Expand Down

0 comments on commit 530ae91

Please sign in to comment.