chore: address the pr comments
This commit is contained in:
parent
d0fba5b727
commit
b34e83a29a
@ -1,7 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
|
@ -16,10 +16,6 @@ import (
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
func nextFn(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
func (suite MiddlewareTestSuite) TestEthSigVerificationDecorator() {
|
||||
txHandler := middleware.ComposeMiddlewares(noopTxHandler, ante.NewEthSigVerificationMiddleware(suite.app.EvmKeeper))
|
||||
addr, privKey := tests.NewAddrKey()
|
||||
@ -288,26 +284,22 @@ func (suite MiddlewareTestSuite) TestEthGasConsumeDecorator() {
|
||||
if tc.expPanic {
|
||||
suite.Require().Panics(func() {
|
||||
_, _, _ = txHandler.CheckTx(sdk.WrapSDKContext(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewGasMeter(1))), txtypes.Request{Tx: tc.tx}, txtypes.RequestCheckTx{})
|
||||
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
_, _, err := txHandler.CheckTx(sdk.WrapSDKContext(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewInfiniteGasMeter())), txtypes.Request{Tx: tc.tx}, txtypes.RequestCheckTx{})
|
||||
|
||||
// ctx, err := t.AnteHandle(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewInfiniteGasMeter()), tc.tx, false, nextFn)
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
// suite.Require().Equal(tc.gasLimit, ctx.GasMeter().Limit())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite MiddlewareTestSuite) TestCanTransferDecorator() {
|
||||
// dec := ante.NewCanTransferMiddleware(suite.app.EvmKeeper)
|
||||
txHandler := middleware.ComposeMiddlewares(noopTxHandler, ante.NewCanTransferMiddleware(suite.app.EvmKeeper))
|
||||
|
||||
addr, privKey := tests.NewAddrKey()
|
||||
|
@ -1,7 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
@ -66,10 +66,7 @@ func (txh txRouter) route(req tx.Request) (tx.Handler, error) {
|
||||
return next, nil
|
||||
}
|
||||
}
|
||||
// // handle as totally normal Cosmos SDK tx
|
||||
// if _, ok = reqTx.(sdk.Tx); !ok {
|
||||
// return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid transaction type: %T", reqTx)
|
||||
// }
|
||||
// handle as totally normal Cosmos SDK tx
|
||||
return txh.cosmos, nil
|
||||
}
|
||||
|
||||
@ -100,7 +97,7 @@ func (txh txRouter) SimulateTx(ctx context.Context, req tx.Request) (res tx.Resp
|
||||
return next.SimulateTx(ctx, req)
|
||||
}
|
||||
|
||||
var _ authmiddleware.SignatureVerificationGasConsumer = DefaultSigVerificationGasConsumer
|
||||
var _ = DefaultSigVerificationGasConsumer
|
||||
|
||||
// DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas
|
||||
// for signature verification based upon the public key type. The cost is fetched from the given params and is matched
|
||||
|
@ -7,14 +7,12 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
// authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
// authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
ethermint "github.com/tharsis/ethermint/types"
|
||||
"github.com/tharsis/ethermint/x/evm/types"
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
)
|
||||
|
||||
func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) {
|
||||
@ -65,12 +63,12 @@ func DoBenchmark(b *testing.B, txBuilder TxBuilder) {
|
||||
ctx, _ := suite.ctx.CacheContext()
|
||||
|
||||
// deduct fee first
|
||||
// txData, err := types.UnpackTxData(msg.Data)
|
||||
// require.NoError(b, err)
|
||||
txData, err := types.UnpackTxData(msg.Data)
|
||||
require.NoError(b, err)
|
||||
|
||||
// fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
|
||||
// err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
// require.NoError(b, err)
|
||||
fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
|
||||
err = authmiddleware.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
require.NoError(b, err)
|
||||
|
||||
rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
||||
require.NoError(b, err)
|
||||
|
@ -467,7 +467,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
// suite.SetupTest() // reset
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user