laconicd-deprecated/x/feemarket/keeper/grpc_query_test.go
crypto-facs 620f6a6770
imp(feemarket): update BaseFee based on GasWanted (#1105)
* add gasWanted transient store keys

* add gasWanted transient store keeper functions

* add gasWanted transient store tracker

* add comment

* remove unncesary comment

* remove unnecesary function

* fix tests

* fix bad comment

* remove unnecesary comment

* update comment

* update changelog

* Update CHANGELOG.md

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* add GasWantedDecorator

* remove unnecesary comments

* gasWanted decorator test

* fix tests

* fix tests and build

* fix lint

* updated end block event

* Update app/ante/fee_market.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* fix undeclared variable

* Update app/ante/fee_market_test.go

* remove unnecesary line

* migrate MinGasMultiplier to FeeMarket module

* set limited gas wanted

* remove old newKeeper param

* update proto comment

* fix test

* update comments

* Update x/feemarket/keeper/abci.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* address comments from review

* tidy

* tests

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
2022-06-05 09:22:33 +00:00

101 lines
2.2 KiB
Go

package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ethparams "github.com/ethereum/go-ethereum/params"
"github.com/tharsis/ethermint/x/feemarket/types"
)
func (suite *KeeperTestSuite) TestQueryParams() {
testCases := []struct {
name string
expPass bool
}{
{
"pass",
true,
},
}
for _, tc := range testCases {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
exp := &types.QueryParamsResponse{Params: params}
res, err := suite.queryClient.Params(suite.ctx.Context(), &types.QueryParamsRequest{})
if tc.expPass {
suite.Require().Equal(exp, res, tc.name)
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
}
}
func (suite *KeeperTestSuite) TestQueryBaseFee() {
var (
aux sdk.Int
expRes *types.QueryBaseFeeResponse
)
testCases := []struct {
name string
malleate func()
expPass bool
}{
{
"pass - default Base Fee",
func() {
initialBaseFee := sdk.NewInt(ethparams.InitialBaseFee)
expRes = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee}
},
true,
},
{
"pass - non-nil Base Fee",
func() {
baseFee := sdk.OneInt().BigInt()
suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee)
aux = sdk.NewIntFromBigInt(baseFee)
expRes = &types.QueryBaseFeeResponse{BaseFee: &aux}
},
true,
},
}
for _, tc := range testCases {
tc.malleate()
res, err := suite.queryClient.BaseFee(suite.ctx.Context(), &types.QueryBaseFeeRequest{})
if tc.expPass {
suite.Require().NotNil(res)
suite.Require().Equal(expRes, res, tc.name)
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
}
}
func (suite *KeeperTestSuite) TestQueryBlockGas() {
testCases := []struct {
name string
expPass bool
}{
{
"pass",
true,
},
}
for _, tc := range testCases {
gas := suite.app.FeeMarketKeeper.GetBlockGasWanted(suite.ctx)
exp := &types.QueryBlockGasResponse{Gas: int64(gas)}
res, err := suite.queryClient.BlockGas(suite.ctx.Context(), &types.QueryBlockGasRequest{})
if tc.expPass {
suite.Require().Equal(exp, res, tc.name)
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
}
}