diff --git a/tests/e2e/.env.live-network-example b/tests/e2e/.env.live-network-example index 7b8fe24714..273f3d8977 100644 --- a/tests/e2e/.env.live-network-example +++ b/tests/e2e/.env.live-network-example @@ -20,4 +20,5 @@ E2E_INCLUDE_IBC_TESTS=false # - the evmutil params must support conversion & deposits to mint in eip712 messages # # These requirements are verified on test startup in ./testutil/init_evm.go -E2E_KAVA_ERC20_ADDRESS=0xeA7100edA2f805356291B0E55DaD448599a72C6d +# This address is a USDT contract +E2E_KAVA_ERC20_ADDRESS=0x919c1c267bc06a7039e03fcc2ef738525769109c diff --git a/tests/e2e/e2e_convert_cosmos_coins_test.go b/tests/e2e/e2e_convert_cosmos_coins_test.go index fc88bc14b4..e7f86dbb64 100644 --- a/tests/e2e/e2e_convert_cosmos_coins_test.go +++ b/tests/e2e/e2e_convert_cosmos_coins_test.go @@ -198,8 +198,8 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() { suite.NoError(err) suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code) - _, err = util.WaitForSdkTxCommit(suite.Kava.Tx, res.TxResponse.TxHash, 6*time.Second) - suite.NoError(err) + _, err = util.WaitForSdkTxCommit(suite.Kava.Tx, res.TxResponse.TxHash, 12*time.Second) + suite.Require().NoError(err) // query for the deployed contract deployedContracts, err := suite.Kava.Evmutil.DeployedCosmosCoinContracts( @@ -394,7 +394,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() { Data: "bob transfers alice's funds, allowed because he's approved", } res = bob.SignAndBroadcastEvmTx(transferJustRightTx) - suite.NoError(res.Err) + suite.Require().NoError(res.Err) // alice should have amount deducted erc20Balance := suite.Kava.GetErc20Balance(contractAddress.Address, alice.EvmAddress) diff --git a/tests/e2e/e2e_min_fees_test.go b/tests/e2e/e2e_min_fees_test.go index 9d068690af..0ff51ce8a2 100644 --- a/tests/e2e/e2e_min_fees_test.go +++ b/tests/e2e/e2e_min_fees_test.go @@ -17,6 +17,8 @@ import ( ) func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() { + suite.SkipIfKvtoolDisabled() + // read expected min fee from app.toml minGasPrices, err := getMinFeeFromAppToml(util.KavaHomePath()) suite.NoError(err) @@ -32,6 +34,8 @@ func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() { } func (suite *IntegrationTestSuite) TestEvmRespectsMinFee() { + suite.SkipIfKvtoolDisabled() + // setup sender & receiver sender := suite.Kava.NewFundedAccount("evm-min-fee-test-sender", sdk.NewCoins(ukava(1e3))) randoReceiver := util.SdkToEvmAddress(app.RandomAddress()) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 0327aed2d8..8663b294bb 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -99,7 +99,7 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() { Data: "any ol' data to track this through the system", } res := acc.SignAndBroadcastEvmTx(req) - suite.NoError(res.Err) + suite.Require().NoError(res.Err) suite.Equal(ethtypes.ReceiptStatusSuccessful, res.Receipt.Status) // evm txs refund unused gas. so to know the expected balance we need to know how much gas was used. diff --git a/tests/e2e/e2e_upgrade_inflation_test.go b/tests/e2e/e2e_upgrade_inflation_test.go index 32b797dedf..df8786a9c1 100644 --- a/tests/e2e/e2e_upgrade_inflation_test.go +++ b/tests/e2e/e2e_upgrade_inflation_test.go @@ -22,6 +22,8 @@ import ( ) func (suite *IntegrationTestSuite) TestUpgradeInflation_Disable() { + suite.SkipIfUpgradeDisabled() + afterUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight) // Get x/community for switchover time @@ -370,6 +372,8 @@ func (suite *IntegrationTestSuite) TestUpgradeInflation_Disable() { // Staking rewards can still be claimed suite.Run("staking rewards claimable after switchover", func() { + suite.SkipIfKvtoolDisabled() + // Get the delegator of the only validator validators, err := suite.Kava.Staking.Validators( context.Background(), diff --git a/tests/e2e/readme.md b/tests/e2e/readme.md index 573e4d0f78..1c0c677454 100644 --- a/tests/e2e/readme.md +++ b/tests/e2e/readme.md @@ -27,12 +27,17 @@ The end-to-end tests support being run on a live network. The primary toggle for * `E2E_KAVA_RPC_URL` * `E2E_KAVA_GRPC_URL` * `E2E_KAVA_EVM_RPC_URL` +* `E2E_KAVA_UPGRADE_HEIGHT` - the height at which an existing upgrade was run See an example environment configuration with full description of all supported configurations in [`.env.live-network-example`](./.env.live-network-example). This example expects a local kvtool network to be running: `kvtool testnet bootstrap`. When run against a live network, the suite will automatically return all the sdk funds sent to `SigningAccount`s on the chain, and will return any ERC20 balance from those accounts if the ERC20 is registered via `Chain.RegisterERC20`. The pre-deployed ERC20 that is required for the tests is registered on setup. -At this time, live-network tests do not support `E2E_INCLUDE_IBC_TESTS=true` and they do not support automated upgrades. +At this time, live-network tests do not support `E2E_INCLUDE_IBC_TESTS=true`. + +`E2E_KAVA_UPGRADE_HEIGHT` is supported for an existing upgrade height, and can +be used to verify before / after upgrade state. This doesn't run automatically +any upgrades. ## `Chain`s diff --git a/tests/e2e/runner/live.go b/tests/e2e/runner/live.go index 317deb58ed..87134f427d 100644 --- a/tests/e2e/runner/live.go +++ b/tests/e2e/runner/live.go @@ -14,6 +14,8 @@ type LiveNodeRunnerConfig struct { KavaRpcUrl string KavaGrpcUrl string KavaEvmRpcUrl string + + UpgradeHeight int64 } // LiveNodeRunner implements NodeRunner for an already-running chain. diff --git a/tests/e2e/testutil/config.go b/tests/e2e/testutil/config.go index 6cf38d8161..bf78e7ecd3 100644 --- a/tests/e2e/testutil/config.go +++ b/tests/e2e/testutil/config.go @@ -56,6 +56,8 @@ type LiveNetworkConfig struct { KavaRpcUrl string KavaGrpcUrl string KavaEvmRpcUrl string + + UpgradeHeight int64 } // ParseSuiteConfig builds a SuiteConfig from environment variables. @@ -107,11 +109,23 @@ func ParseKvtoolConfig() KvtoolConfig { // ParseLiveNetworkConfig builds a LiveNetworkConfig from environment variables. func ParseLiveNetworkConfig() LiveNetworkConfig { - return LiveNetworkConfig{ + config := LiveNetworkConfig{ KavaRpcUrl: nonemptyStringEnv("E2E_KAVA_RPC_URL"), KavaGrpcUrl: nonemptyStringEnv("E2E_KAVA_GRPC_URL"), KavaEvmRpcUrl: nonemptyStringEnv("E2E_KAVA_EVM_RPC_URL"), } + + upgradeHeight := os.Getenv("E2E_KAVA_UPGRADE_HEIGHT") + if upgradeHeight != "" { + parsedHeight, err := strconv.ParseInt(upgradeHeight, 10, 64) + if err != nil { + panic(fmt.Sprintf("E2E_KAVA_UPGRADE_HEIGHT must be a number: %s", err)) + } + + config.UpgradeHeight = parsedHeight + } + + return config } // mustParseBool is a helper method that panics if the env variable `name` diff --git a/tests/e2e/testutil/init_evm.go b/tests/e2e/testutil/init_evm.go index 823992eeba..b159d927d9 100644 --- a/tests/e2e/testutil/init_evm.go +++ b/tests/e2e/testutil/init_evm.go @@ -20,7 +20,11 @@ func (suite *E2eTestSuite) InitKavaEvmData() { // ensure funded account has nonzero erc20 balance balance := suite.Kava.GetErc20Balance(suite.DeployedErc20.Address, whale.EvmAddress) if balance.Cmp(big.NewInt(0)) != 1 { - panic(fmt.Sprintf("expected funded account (%s) to have erc20 balance", whale.EvmAddress.Hex())) + panic(fmt.Sprintf( + "expected funded account (%s) to have erc20 balance of token %s", + whale.EvmAddress.Hex(), + suite.DeployedErc20.Address.Hex(), + )) } // expect the erc20 to be enabled for conversion to sdk.Coin diff --git a/tests/e2e/testutil/suite.go b/tests/e2e/testutil/suite.go index 9eb82137d1..5c0d93bb22 100644 --- a/tests/e2e/testutil/suite.go +++ b/tests/e2e/testutil/suite.go @@ -193,12 +193,16 @@ func (suite *E2eTestSuite) SetupLiveNetworkNodeRunner() *runner.LiveNodeRunner { if suite.config.IncludeIbcTests { panic("ibc tests not supported for live network configuration") } + + // Manually set upgrade height for live networks + suite.UpgradeHeight = suite.config.LiveNetwork.UpgradeHeight suite.enableRefunds = true runnerConfig := runner.LiveNodeRunnerConfig{ KavaRpcUrl: suite.config.LiveNetwork.KavaRpcUrl, KavaGrpcUrl: suite.config.LiveNetwork.KavaGrpcUrl, KavaEvmRpcUrl: suite.config.LiveNetwork.KavaEvmRpcUrl, + UpgradeHeight: suite.config.LiveNetwork.UpgradeHeight, } return runner.NewLiveNodeRunner(runnerConfig) @@ -217,6 +221,20 @@ func (suite *E2eTestSuite) SkipIfIbcDisabled() { // Note: automated upgrade tests are currently only enabled for Kvtool suite runs. func (suite *E2eTestSuite) SkipIfUpgradeDisabled() { if suite.config.Kvtool != nil && !suite.config.Kvtool.IncludeAutomatedUpgrade { + fmt.Println("skipping upgrade test, kvtool automated upgrade is disabled") + suite.T().SkipNow() + } + + // If there isn't a manual upgrade height set in the config, skip the test + if suite.config.LiveNetwork != nil && suite.config.LiveNetwork.UpgradeHeight == 0 { + fmt.Println("skipping upgrade test, live network upgrade height is not set") + suite.T().SkipNow() + } +} + +// SkipIfKvtoolDisabled should be called at the start of tests that require kvtool. +func (suite *E2eTestSuite) SkipIfKvtoolDisabled() { + if suite.config.Kvtool == nil { suite.T().SkipNow() } }