0g-chain/tests/e2e
Draco 614d4e40fe
Update cosmos-sdk to v0.47.7 (#1811)
* Update cometbft, cosmos, ethermint, and ibc-go

* Replace github.com/tendermint/tendermint by github.com/cometbft/cometbft

* Replace github.com/tendermint/tm-db by github.com/cometbft/cometbft-db

* Replace gogo/protobuf with cosmos/gogoproto & simapp replacement

* Replace cosmos-sdk/simapp/helpers with cosmos-sdk/testutil/sims

* Remove no longer used simulations

* Replace ibchost with ibcexported
See https://github.com/cosmos/ibc-go/blob/v7.2.2/docs/migrations/v6-to-v7.md#ibc-module-constants

* Add new consensus params keeper

* Add consensus keeper to blockers

* Fix keeper and module issues in app.go

* Add IsSendEnabledCoins and update SetParams interface changes

* Fix protobuf build for cosmos 47 (#1800)

* fix cp errors by using -f; fix lint by only linting our proto dir;
and use proofs.proto directly from ics23 for ibc-go v7

* run proto-all; commit updated third party deps and swagger changes

* regenerate proto files

* use correct gocosmos build plugin for buf

* re-gen all protobuf files to update paths for new gocosmos plugin

* update protoc and buf to latest versions

* fix staking keeper issues in app.go

* update tally handler for gov changes

* chain id fix and flag fixes

* update deps for cometbft 47.7 upgrade

* remove all module legacy queriers

* update stakingKeeper to pointer

* Replace ModuleCdc from govv1beta1 to govcodec

* remove simulations

* abci.LastCommitInfo → abci.CommitInfo

* Remove unused code in keys.go

* simapp.MakeTestEncodingConfig -> moduletestutil.MakeTestEncodingConfi

* Fix chain id issues in tests

* Fix remaining unit test issues

* Update changelog for upgrade

* Fix e2e tests using updated kvtool

* Update protonet to v47 compatible genesis

* Bump cometbft-db to v0.9.1-kava.1

* Update kvtool

* Remove extra changelog

* Fix merged rocksdb issues

* go mod cleanup

* Bump cometbft-db to v9 and go to 1.21

* Bump rocksdb version to v8.10.0

* Update kvtool to latest version

* Update gin to v1.9.0

* Use ibctm.ModuleName in app_test

* Fallback to genesis chain id instead of client toml

* Remove all simulations

* Fix cdp migrations issue with v47

* Update dependencies to correct tags

---------

Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
2024-02-06 17:54:10 -05:00
..
contracts support initialization of evm state in e2e tests (#1524) 2023-04-03 09:58:45 -07:00
kvtool@99214e8b51 feat(x/cdp): update begin bloocker to run liquidations every X blocks based off params (#1818) 2024-02-02 13:21:11 -05:00
runner Update cosmos-sdk to v0.47.7 (#1811) 2024-02-06 17:54:10 -05:00
scripts Add IBC chain to E2E test suite (#1486) 2023-03-07 14:37:45 -08:00
testutil Update cosmos-sdk to v0.47.7 (#1811) 2024-02-06 17:54:10 -05:00
.env Update cosmos-sdk to v0.47.7 (#1811) 2024-02-06 17:54:10 -05:00
.env.live-network-example x/community events and e2e test improvements (#1766) 2023-10-31 16:37:40 -07:00
e2e_community_update_params_test.go Update cosmos-sdk to v0.47.7 (#1811) 2024-02-06 17:54:10 -05:00
e2e_convert_cosmos_coins_test.go Kava gRPC Client (#1784) 2023-12-13 12:17:37 -05:00
e2e_evm_contracts_test.go Kava gRPC Client (#1784) 2023-12-13 12:17:37 -05:00
e2e_grpc_client_query_test.go Kava gRPC Client (#1784) 2023-12-13 12:17:37 -05:00
e2e_grpc_client_util_test.go Kava gRPC Client (#1784) 2023-12-13 12:17:37 -05:00
e2e_min_fees_test.go x/community events and e2e test improvements (#1766) 2023-10-31 16:37:40 -07:00
e2e_test.go Update cosmos-sdk to v0.47.7 (#1811) 2024-02-06 17:54:10 -05:00
e2e_upgrade_handler_test.go Kava gRPC Client (#1784) 2023-12-13 12:17:37 -05:00
readme.md x/community events and e2e test improvements (#1766) 2023-10-31 16:37:40 -07:00

end-2-end tests for kava

These tests use kvtool to spin up a kava node configuration and then runs tests against the running network. It is a git sub-repository in this directory. If not present, you must initialize the subrepo: git submodule update --init.

Steps to run

  1. Ensure latest kvtool is installed: make update-kvtool
  2. Run the test suite: make test-e2e This will build a docker image tagged kava/kava:local that will be run by kvtool.

Note: The suite will use your locally installed kvtool if present. If not present, it will be installed. If the kvtool repo is updated, you must manually update your existing local binary: make update-kvtool

Configuration

The test suite uses env variables that can be set in .env. See that file for a complete list of options. The variables are parsed and imported into a SuiteConfig in testutil/config.go.

The variables in .env will not override variables that are already present in the environment. ie. Running E2E_INCLUDE_IBC_TESTS=false make test-e2e will disable the ibc tests regardless of how the variable is set in .env.

Running on Live Network

The end-to-end tests support being run on a live network. The primary toggle for setting up the suite to use a live network is the E2E_RUN_KVTOOL_NETWORKS flag. When set exactly to false, the configuration requires the following three environment variables:

  • 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. 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 SigningAccounts 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.

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.

Chains

A testutil.Chain is the abstraction around details, query clients, & signing accounts for interacting with a network. After networks are running, a Chain is initialized & attached to the main test suite testutil.E2eTestSuite.

The primary Kava network is accessible via suite.Kava.

Details about the chains can be found here.

SigningAccounts

Each Chain wraps a map of signing clients for that network. The SigningAccount contains clients for both the Kava EVM and Cosmos-Sdk co-chains.

The methods SignAndBroadcastKavaTx and SignAndBroadcastEvmTx are used to submit transactions to the sdk and evm chains, respectively.

Creating a new account

// create an account on the Kava network, initially funded with 10 KAVA
acc := suite.Kava.NewFundedAccount("account-name", sdk.NewCoins(sdk.NewCoin("ukava", 10e6)))

// you can also access accounts by the name with which they were registered to the suite
acc := suite.Kava.GetAccount("account-name")

Funds for new accounts are distributed from the account with the mnemonic from the E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC env variable. The account will be generated with HD coin type 60 & the ethsecp256k1 private key signing algorithm. The initial funding account is registered with the name "whale".

IBC tests

When IBC tests are enabled, an additional network is spun up with a different chain id & an IBC channel is opened between it and the primary Kava network.

The IBC network runs kava with a different chain id and staking denom (see runner/chain.go).

The IBC chain queriers & accounts are accessible via suite.Ibc.

IBC tests can be disabled by setting E2E_INCLUDE_IBC_TESTS to false.

Chain Upgrades

When a named upgrade handler is included in the current working repo of Kava, the e2e test suite can be configured to run all the tests on the upgraded chain. This includes the ability to add additional tests to verify and do acceptance on the post-upgrade chain.

This configuration is controlled by the following env variables:

  • E2E_INCLUDE_AUTOMATED_UPGRADE - toggles on the upgrade functionality. Must be set to true.
  • E2E_KAVA_UPGRADE_NAME - the named upgrade, likely defined in app/upgrades.go
  • E2E_KAVA_UPGRADE_HEIGHT - the height at which to run the upgrade
  • E2E_KAVA_UPGRADE_BASE_IMAGE_TAG - the kava docker image tag to base the upgrade on

When all these are set, the chain is started with the binary contained in the docker image tagged E2E_KAVA_UPGRADE_BASE_IMAGE_TAG. Then an upgrade proposal is submitted with the desired name and height. The chain runs until that height and then is shutdown due to needing the upgrade. The chain is restarted with the local repo's Kava code and the upgrade is run. Once completed, the whole test suite is run.

For a full example of how this looks, see this commit on the example/e2e-test-upgrade-handler branch.