Other minor updates

This commit is contained in:
Aleksandr Bezobchuk 2018-10-24 10:23:12 -04:00
parent 7cd5e47eea
commit 9a076e9526
5 changed files with 4 additions and 32 deletions

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
PACKAGES=$(shell go list ./... | grep -v '/vendor/') PACKAGES=$(shell go list ./... | grep -Ev 'vendor|importer')
COMMIT_HASH := $(shell git rev-parse --short HEAD) COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_FLAGS = -tags netgo -ldflags "-X github.com/cosmos/ethermint/version.GitCommit=${COMMIT_HASH}" BUILD_FLAGS = -tags netgo -ldflags "-X github.com/cosmos/ethermint/version.GitCommit=${COMMIT_HASH}"
DOCKER_TAG = unstable DOCKER_TAG = unstable

View File

@ -105,11 +105,6 @@ func handleEthTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper) (s
// TODO: Investigate gas consumption models as the EVM instruction set has its // TODO: Investigate gas consumption models as the EVM instruction set has its
// own and we should probably not charge for additional gas where we don't have // own and we should probably not charge for additional gas where we don't have
// to. // to.
//
// err = acc.SetSequence(seq + 1)
// if err != nil {
// return sdkCtx, sdk.ErrInternal(err.Error()).Result(), true
// }
accMapper.SetAccount(sdkCtx, acc) accMapper.SetAccount(sdkCtx, acc)
return sdkCtx, sdk.Result{GasWanted: int64(ethTx.Data().GasLimit)}, false return sdkCtx, sdk.Result{GasWanted: int64(ethTx.Data().GasLimit)}, false
@ -135,7 +130,6 @@ func handleEmbeddedTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMappe
signer := ethcmn.BytesToAddress(signerAddrs[i].Bytes()) signer := ethcmn.BytesToAddress(signerAddrs[i].Bytes())
acc, err := validateSignature(sdkCtx, stdTx, signer, sig, accMapper) acc, err := validateSignature(sdkCtx, stdTx, signer, sig, accMapper)
// err.Code() != sdk.CodeOK
if err != nil { if err != nil {
return sdkCtx, err.Result(), true return sdkCtx, err.Result(), true
} }

View File

@ -16,6 +16,8 @@ import (
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
) )
// TODO: These tests will radically change as the ante handler develops
func TestEthTxBadSig(t *testing.T) { func TestEthTxBadSig(t *testing.T) {
tx := types.NewTransaction(uint64(0), types.TestAddr1, big.NewInt(10), 1000, big.NewInt(100), []byte{}) tx := types.NewTransaction(uint64(0), types.TestAddr1, big.NewInt(10), 1000, big.NewInt(100), []byte{})
@ -68,29 +70,6 @@ func TestEthTxIncorrectNonce(t *testing.T) {
require.Equal(t, sdk.ABCICodeType(0x10003), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) require.Equal(t, sdk.ABCICodeType(0x10003), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log))
} }
func TestEthTxValidTx(t *testing.T) {
tx := types.NewTransaction(0, types.TestAddr1, big.NewInt(50), 1000, big.NewInt(1000), []byte{})
tx.Sign(types.TestChainID, types.TestPrivKey1)
ms, key := createTestMultiStore()
ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil)
accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount)
// set account in accountMapper
acc := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes())
accMapper.SetAccount(ctx, acc)
handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{})
_, res, abort := handler(ctx, *tx)
require.False(t, abort, "expected ante handler to not abort")
require.True(t, res.IsOK(), fmt.Sprintf("result not OK on valid Tx: %s", res.Log))
// ensure account state updated correctly
seq, _ := accMapper.GetSequence(ctx, types.TestAddr1[:])
require.Equal(t, int64(1), seq, "account nonce did not increment correctly")
}
func TestEmbeddedTxBadSig(t *testing.T) { func TestEmbeddedTxBadSig(t *testing.T) {
testCodec := types.NewTestCodec() testCodec := types.NewTestCodec()
testFee := types.NewTestStdFee() testFee := types.NewTestStdFee()

View File

@ -67,6 +67,7 @@ func newTestCodec() *wire.Codec {
codec := wire.NewCodec() codec := wire.NewCodec()
types.RegisterWire(codec) types.RegisterWire(codec)
auth.RegisterWire(codec)
wire.RegisterCrypto(codec) wire.RegisterCrypto(codec)
return codec return codec

View File

@ -3,7 +3,6 @@ package types
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
) )
var typesCodec = wire.NewCodec() var typesCodec = wire.NewCodec()
@ -16,7 +15,6 @@ func init() {
// codec. // codec.
func RegisterWire(codec *wire.Codec) { func RegisterWire(codec *wire.Codec) {
sdk.RegisterWire(codec) sdk.RegisterWire(codec)
codec.RegisterInterface((*auth.Account)(nil), nil)
codec.RegisterConcrete(&Transaction{}, "types/Transaction", nil) codec.RegisterConcrete(&Transaction{}, "types/Transaction", nil)
codec.RegisterConcrete(&Account{}, "types/Account", nil) codec.RegisterConcrete(&Account{}, "types/Account", nil)
} }