forked from cerc-io/laconicd-deprecated
keeper: StateDB unit tests (#47)
* keeper: statedb unit tests * evm: balance tests * evm: nonce and code tests * evm: refund test * evm: fix tx encoding * storage and access list tests
This commit is contained in:
+10
-6
@@ -7,9 +7,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/cosmos/ethermint/codec"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
)
|
||||
|
||||
// MakeEncodingConfig creates an EncodingConfig for testing
|
||||
@@ -49,9 +51,9 @@ func NewTxConfig(marshaler amino.ProtoCodecMarshaler) client.TxConfig {
|
||||
// TxEncoder overwrites sdk.TxEncoder to support MsgEthereumTx
|
||||
func (g txConfig) TxEncoder() sdk.TxEncoder {
|
||||
return func(tx sdk.Tx) ([]byte, error) {
|
||||
ethtx, ok := tx.(*evmtypes.MsgEthereumTx)
|
||||
msg, ok := tx.(*evmtypes.MsgEthereumTx)
|
||||
if ok {
|
||||
return g.cdc.MarshalBinaryBare(ethtx)
|
||||
return msg.AsTransaction().MarshalBinary()
|
||||
}
|
||||
return g.TxConfig.TxEncoder()(tx)
|
||||
}
|
||||
@@ -60,11 +62,13 @@ func (g txConfig) TxEncoder() sdk.TxEncoder {
|
||||
// TxDecoder overwrites sdk.TxDecoder to support MsgEthereumTx
|
||||
func (g txConfig) TxDecoder() sdk.TxDecoder {
|
||||
return func(txBytes []byte) (sdk.Tx, error) {
|
||||
var ethtx evmtypes.MsgEthereumTx
|
||||
tx := ðtypes.Transaction{}
|
||||
|
||||
err := g.cdc.UnmarshalBinaryBare(txBytes, ðtx)
|
||||
err := tx.UnmarshalBinary(txBytes)
|
||||
if err == nil {
|
||||
return ðtx, nil
|
||||
msg := &evmtypes.MsgEthereumTx{}
|
||||
msg.FromEthereumTx(tx)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
return g.TxConfig.TxDecoder()(txBytes)
|
||||
|
||||
Reference in New Issue
Block a user