fix base fee tests for different smoke heights

This commit is contained in:
Steven Allen 2020-10-06 13:12:16 -07:00
parent 256be285ba
commit b1818a1055

View File

@ -11,24 +11,27 @@ import (
func TestBaseFee(t *testing.T) { func TestBaseFee(t *testing.T) {
tests := []struct { tests := []struct {
basefee uint64 basefee uint64
limitUsed int64 limitUsed int64
noOfBlocks int noOfBlocks int
output uint64 preSmoke, postSmoke uint64
}{ }{
{100e6, 0, 1, 87.5e6}, {100e6, 0, 1, 87.5e6, 87.5e6},
{100e6, 0, 5, 87.5e6}, {100e6, 0, 5, 87.5e6, 87.5e6},
{100e6, build.BlockGasTarget, 1, 103.125e6}, {100e6, build.BlockGasTarget, 1, 103.125e6, 100e6},
{100e6, build.BlockGasTarget * 2, 2, 103.125e6}, {100e6, build.BlockGasTarget * 2, 2, 103.125e6, 100e6},
{100e6, build.BlockGasLimit * 2, 2, 112.5e6}, {100e6, build.BlockGasLimit * 2, 2, 112.5e6, 112.5e6},
{100e6, build.BlockGasLimit * 1.5, 2, 110937500}, {100e6, build.BlockGasLimit * 1.5, 2, 110937500, 106.250e6},
} }
for _, test := range tests { for _, test := range tests {
test := test test := test
t.Run(fmt.Sprintf("%v", test), func(t *testing.T) { t.Run(fmt.Sprintf("%v", test), func(t *testing.T) {
output := ComputeNextBaseFee(types.NewInt(test.basefee), test.limitUsed, test.noOfBlocks, 0) preSmoke := ComputeNextBaseFee(types.NewInt(test.basefee), test.limitUsed, test.noOfBlocks, build.UpgradeSmokeHeight-1)
assert.Equal(t, fmt.Sprintf("%d", test.output), output.String()) assert.Equal(t, fmt.Sprintf("%d", test.preSmoke), preSmoke.String())
postSmoke := ComputeNextBaseFee(types.NewInt(test.basefee), test.limitUsed, test.noOfBlocks, build.UpgradeSmokeHeight+1)
assert.Equal(t, fmt.Sprintf("%d", test.postSmoke), postSmoke.String())
}) })
} }
} }