From 141e8ac4503d11651165ddf3a22b31695f33115c Mon Sep 17 00:00:00 2001 From: Robert Pirtle Date: Tue, 6 Jun 2023 14:51:42 -0700 Subject: [PATCH] test(e2e): add Committee & Upgrade query clients (#1618) Also: - updates kvtool - adds helper comment to upgrade e2e file - adjusts e2e account funding logging - [testnets] enable eip712 signing of cosmos coin msgs - [testnets] enable cosmos coin conversion for HARD --- ci/env/kava-internal-testnet/genesis.json | 47 ++++++++++++++++++++++- ci/env/kava-protonet/genesis.json | 47 ++++++++++++++++++++++- tests/e2e/.env | 2 +- tests/e2e/e2e_upgrade_handler_test.go | 8 +++- tests/e2e/kvtool | 2 +- tests/e2e/testutil/chain.go | 13 ++++++- 6 files changed, 112 insertions(+), 7 deletions(-) diff --git a/ci/env/kava-internal-testnet/genesis.json b/ci/env/kava-internal-testnet/genesis.json index eb0a5dc7..f14d9013 100644 --- a/ci/env/kava-internal-testnet/genesis.json +++ b/ci/env/kava-internal-testnet/genesis.json @@ -1964,6 +1964,44 @@ } ], "nested_types": [] + }, + { + "msg_type_url": "/kava.evmutil.v1beta1.MsgConvertCosmosCoinToERC20", + "msg_value_type_name": "MsgConvertCosmosCoinToERC20", + "value_types": [ + { + "name": "initiator", + "type": "string" + }, + { + "name": "receiver", + "type": "string" + }, + { + "name": "amount", + "type": "Coin" + } + ], + "nested_types": [] + }, + { + "msg_type_url": "/kava.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20", + "msg_value_type_name": "MsgConvertCosmosCoinFromERC20", + "value_types": [ + { + "name": "initiator", + "type": "string" + }, + { + "name": "receiver", + "type": "string" + }, + { + "name": "amount", + "type": "Coin" + } + ], + "nested_types": [] } ], "allow_unprotected_txs": false @@ -1972,7 +2010,14 @@ "evmutil": { "accounts": [], "params": { - "allowed_cosmos_denoms": [], + "allowed_cosmos_denoms": [ + { + "cosmos_denom": "hard", + "name": "HARD", + "symbol": "HARD", + "decimals": 6 + } + ], "enabled_conversion_pairs": [ { "kava_erc20_address": "0xBb304f44b7EFD865361F2AD973d8ebA433893ABC", diff --git a/ci/env/kava-protonet/genesis.json b/ci/env/kava-protonet/genesis.json index 26bef994..fba045c3 100644 --- a/ci/env/kava-protonet/genesis.json +++ b/ci/env/kava-protonet/genesis.json @@ -1996,6 +1996,44 @@ } ], "nested_types": [] + }, + { + "msg_type_url": "/kava.evmutil.v1beta1.MsgConvertCosmosCoinToERC20", + "msg_value_type_name": "MsgConvertCosmosCoinToERC20", + "value_types": [ + { + "name": "initiator", + "type": "string" + }, + { + "name": "receiver", + "type": "string" + }, + { + "name": "amount", + "type": "Coin" + } + ], + "nested_types": [] + }, + { + "msg_type_url": "/kava.evmutil.v1beta1.MsgConvertCosmosCoinFromERC20", + "msg_value_type_name": "MsgConvertCosmosCoinFromERC20", + "value_types": [ + { + "name": "initiator", + "type": "string" + }, + { + "name": "receiver", + "type": "string" + }, + { + "name": "amount", + "type": "Coin" + } + ], + "nested_types": [] } ], "allow_unprotected_txs": false @@ -2004,7 +2042,14 @@ "evmutil": { "accounts": [], "params": { - "allowed_cosmos_denoms": [], + "allowed_cosmos_denoms": [ + { + "cosmos_denom": "hard", + "name": "HARD", + "symbol": "HARD", + "decimals": 6 + } + ], "enabled_conversion_pairs": [ { "kava_erc20_address": "0xBb304f44b7EFD865361F2AD973d8ebA433893ABC", diff --git a/tests/e2e/.env b/tests/e2e/.env index d89c606b..8c6d63bc 100644 --- a/tests/e2e/.env +++ b/tests/e2e/.env @@ -19,7 +19,7 @@ E2E_INCLUDE_AUTOMATED_UPGRADE=false # E2E_KAVA_UPGRADE_NAME is the name of the upgrade that must be in the current local image. E2E_KAVA_UPGRADE_NAME= # E2E_KAVA_UPGRADE_HEIGHT is the height at which the upgrade will be applied. -# If IBC tests are enabled this should be >50. Otherwise, this should be >10. +# If IBC tests are enabled this should be >30. Otherwise, this should be >10. E2E_KAVA_UPGRADE_HEIGHT= # E2E_KAVA_UPGRADE_BASE_IMAGE_TAG is the tag of the docker image the chain should upgrade from. E2E_KAVA_UPGRADE_BASE_IMAGE_TAG= diff --git a/tests/e2e/e2e_upgrade_handler_test.go b/tests/e2e/e2e_upgrade_handler_test.go index a081efd1..044c5b9c 100644 --- a/tests/e2e/e2e_upgrade_handler_test.go +++ b/tests/e2e/e2e_upgrade_handler_test.go @@ -1,6 +1,8 @@ package e2e_test -import "fmt" +import ( + "fmt" +) // TestUpgradeHandler can be used to run tests post-upgrade. If an upgrade is enabled, all tests // are run against the upgraded chain. However, this file is a good place to consolidate all @@ -9,4 +11,8 @@ func (suite *IntegrationTestSuite) TestUpgradeHandler() { suite.SkipIfUpgradeDisabled() fmt.Println("An upgrade has run!") suite.True(true) + + // Uncomment & use these contexts to compare chain state before & after the upgrade occurs. + // beforeUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight - 1) + // afterUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight) } diff --git a/tests/e2e/kvtool b/tests/e2e/kvtool index 98d25c9b..40f6311b 160000 --- a/tests/e2e/kvtool +++ b/tests/e2e/kvtool @@ -1 +1 @@ -Subproject commit 98d25c9b659eaee465c72198f387268ce763400c +Subproject commit 40f6311b6e92aa5b716d029da6047c2f3f22c882 diff --git a/tests/e2e/testutil/chain.go b/tests/e2e/testutil/chain.go index b10e6777..5444c7e4 100644 --- a/tests/e2e/testutil/chain.go +++ b/tests/e2e/testutil/chain.go @@ -6,22 +6,27 @@ import ( "math/big" "testing" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/crypto/hd" sdk "github.com/cosmos/cosmos-sdk/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" + evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/stretchr/testify/require" "github.com/kava-labs/kava/app" kavaparams "github.com/kava-labs/kava/app/params" "github.com/kava-labs/kava/tests/e2e/runner" "github.com/kava-labs/kava/tests/util" + committeetypes "github.com/kava-labs/kava/x/committee/types" communitytypes "github.com/kava-labs/kava/x/community/types" earntypes "github.com/kava-labs/kava/x/earn/types" evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" @@ -42,12 +47,14 @@ type Chain struct { Auth authtypes.QueryClient Bank banktypes.QueryClient + Committee committeetypes.QueryClient Community communitytypes.QueryClient Earn earntypes.QueryClient Evm evmtypes.QueryClient Evmutil evmutiltypes.QueryClient Tm tmservice.ServiceClient Tx txtypes.ServiceClient + Upgrade upgradetypes.QueryClient } // NewChain creates the query clients & signing account management for a chain run on a set of ports. @@ -76,12 +83,14 @@ func NewChain(t *testing.T, details *runner.ChainDetails, fundedAccountMnemonic chain.Auth = authtypes.NewQueryClient(grpcConn) chain.Bank = banktypes.NewQueryClient(grpcConn) + chain.Committee = committeetypes.NewQueryClient(grpcConn) chain.Community = communitytypes.NewQueryClient(grpcConn) chain.Earn = earntypes.NewQueryClient(grpcConn) chain.Evm = evmtypes.NewQueryClient(grpcConn) chain.Evmutil = evmutiltypes.NewQueryClient(grpcConn) chain.Tm = tmservice.NewServiceClient(grpcConn) chain.Tx = txtypes.NewServiceClient(grpcConn) + chain.Upgrade = upgradetypes.NewQueryClient(grpcConn) // initialize accounts map chain.accounts = make(map[string]*SigningAccount) @@ -94,7 +103,7 @@ func NewChain(t *testing.T, details *runner.ChainDetails, fundedAccountMnemonic ) // check that funded account is actually funded. - fmt.Printf("account used for funding (%s) address: %s\n", FundedAccountName, whale.SdkAddress) + fmt.Printf("[%s] account used for funding (%s) address: %s\n", chain.ChainId, FundedAccountName, whale.SdkAddress) whaleFunds := chain.QuerySdkForBalances(whale.SdkAddress) if whaleFunds.IsZero() { chain.t.Fatal("funded account mnemonic is for account with no funds")