laconicd/encoding/config_test.go
Federico Kunze Küllmer a8722655bb
all: bump go-ethereum to v1.10.9 (#231)
* all: bump go-ethereum to v1.10.4

* build

* state transition and rpc

* wip rpc changes

* fix refund

* fixes

* no base fee param

* ante handler

* undo change

* fix test

* bump deps

* calculate base fee

* gRPC base fee query

* update RPC

* fix

* update'

* go.mod

* fix build

* fix panic

* rm changes in third_party

* json rpc changes

* reserved fields

* fixes fixes fixes

* rm no stringer

* fixes 2

* tests wip

* bump geth version

* update

* grpc traceTx

* rm fee market from ante

* fix TransactionArgs

* lint

* update proto

* update tx args

* changelog
2021-10-05 15:38:20 +00:00

45 lines
1.3 KiB
Go

package encoding_test
import (
"math/big"
"testing"
"github.com/stretchr/testify/require"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/tharsis/ethermint/app"
"github.com/tharsis/ethermint/encoding"
"github.com/tharsis/ethermint/tests"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
)
func TestTxEncoding(t *testing.T) {
addr, key := tests.NewAddrKey()
signer := tests.NewSigner(key)
msg := evmtypes.NewTxContract(big.NewInt(1), 1, big.NewInt(10), 100000, nil, big.NewInt(1), big.NewInt(1), []byte{}, nil)
msg.From = addr.Hex()
ethSigner := ethtypes.LatestSignerForChainID(big.NewInt(1))
err := msg.Sign(ethSigner, signer)
require.NoError(t, err)
cfg := encoding.MakeConfig(app.ModuleBasics)
bz, err := cfg.TxConfig.TxEncoder()(msg)
require.NoError(t, err, "encoding failed")
tx, err := cfg.TxConfig.TxDecoder()(bz)
require.NoError(t, err, "decoding failed")
require.IsType(t, &evmtypes.MsgEthereumTx{}, tx)
require.Equal(t, msg.Data, tx.(*evmtypes.MsgEthereumTx).Data)
// FIXME: transaction hashing is hardcoded on Terndermint:
// See https://github.com/tendermint/tendermint/issues/6539 for reference
// txHash := msg.AsTransaction().Hash()
// tmTx := tmtypes.Tx(bz)
// require.Equal(t, txHash.Bytes(), tmTx.Hash())
}