2021-11-01 00:24:26 +00:00
|
|
|
//stm: #unit
|
2020-09-09 10:03:02 +00:00
|
|
|
package full
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMedian(t *testing.T) {
|
2021-03-03 15:05:21 +00:00
|
|
|
require.Equal(t, types.NewInt(5), medianGasPremium([]GasMeta{
|
2020-09-09 10:03:02 +00:00
|
|
|
{big.NewInt(5), build.BlockGasTarget},
|
|
|
|
}, 1))
|
|
|
|
|
2021-03-03 15:05:21 +00:00
|
|
|
require.Equal(t, types.NewInt(10), medianGasPremium([]GasMeta{
|
2020-09-09 10:03:02 +00:00
|
|
|
{big.NewInt(5), build.BlockGasTarget},
|
|
|
|
{big.NewInt(10), build.BlockGasTarget},
|
|
|
|
}, 1))
|
|
|
|
|
2021-03-03 15:05:21 +00:00
|
|
|
require.Equal(t, types.NewInt(15), medianGasPremium([]GasMeta{
|
2020-09-09 10:03:02 +00:00
|
|
|
{big.NewInt(10), build.BlockGasTarget / 2},
|
|
|
|
{big.NewInt(20), build.BlockGasTarget / 2},
|
|
|
|
}, 1))
|
|
|
|
|
2021-03-03 15:05:21 +00:00
|
|
|
require.Equal(t, types.NewInt(25), medianGasPremium([]GasMeta{
|
2020-09-09 10:03:02 +00:00
|
|
|
{big.NewInt(10), build.BlockGasTarget / 2},
|
|
|
|
{big.NewInt(20), build.BlockGasTarget / 2},
|
|
|
|
{big.NewInt(30), build.BlockGasTarget / 2},
|
|
|
|
}, 1))
|
|
|
|
|
2021-03-03 15:05:21 +00:00
|
|
|
require.Equal(t, types.NewInt(15), medianGasPremium([]GasMeta{
|
2020-09-09 10:03:02 +00:00
|
|
|
{big.NewInt(10), build.BlockGasTarget / 2},
|
|
|
|
{big.NewInt(20), build.BlockGasTarget / 2},
|
|
|
|
{big.NewInt(30), build.BlockGasTarget / 2},
|
|
|
|
}, 2))
|
|
|
|
}
|