-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add hardhat and viem based E2E test suite #2016
Conversation
This adds a tests/e2e-evm hardhat based e2e test suite for testing EVM and EVM<>Cosmos workflows. This will be used to drive and test the implementation of precompiles with a focus on e2e workflows. The hardhat and kvtool networks are configured to run in CI to ensure continuous support for both networks is not broken. The hardhat network is used to ensure compatibility between Kava and other EVM's, as well as offer better support for unit testing supporting and example contracts. The kvtool network runs a Kava network for testing the EVM implementation on Kava and testing stateful precompiles.
We add correct solidity compiler settings for the kava network, add kvtool funded accounts, and match the accounts & balances on the hardhat network. The consistency of accounts across networks will be important for testing.
This adds customizations to the hardhat-viem extension to allow connections with kvtool (or other custom chains) and allow default values to be set when using viem from the hardhat runtime interface (hre).
This adds two exported addresses matching the hardhat account configuration for the hardhat and kvtool network. In addition, we assert that both these addresses can sign and successfully send transactions which ensures the private keys and balances are correctly configured.
This adds a test-hardhat and test-kvtool command that selects the proper network and runs typechecks. In addition, npm test is updated to run test-hardhat, then test-kvtool. The hardhat tests are run first to fail fast, and the test-kvtool tests are run after as tests that pass hardhat should pass on kvtool. However, kvtool will target additional tests that will not be run on the hardhat network.
This brings in a docker-compose.yaml update that removes the obsolete version field.
This removes the meta and setup toolbox package in favor of specifying major depdencies explicitly which allows finer grain control of dependency management in addition to removing dependencies that are not required for this project.
This updates the lib, target, and module configuration for the most up to date native support when compiling and running javascript against node 20.
This adds and configures eslint with typescript and type checking support in addition to resolving all lint errors.
This adds a prettier config and npm run commands to check and fix formatting issues.
This adds solhint for linting future contracts used for testing.
Prettier requires a plugin with configuration to format sol files.
This refactors the e2e-evm tests to run in a single job with the hardhat network running first to fail fast and trigger any type errors. In addition, contracts used to test against kvtool may be unit testing only in the hardhat network, etc. In addition, a curl check is added to ensure the EVM JSON-RPC is serving requests. This endpoint can take ~30 seconds to come online after the kvtool server starts. Curl is configured to check every 5 seconds and retry 12 times over 60 seconds if the first request is not successful. Linting and formatting checks are also added via eslint, typescript-eslint with advanced type check rules, and prettier. Solhint is installed, but errors without any files so is not configured to run in CI yet.
The e2e tests have not yet been updated for the latest kvtool oops.
Adding this ignore allows expressions like expect(foo).to.be.defined to pass linting that is common is chai assertions. We only ignore **/*.test.ts files since non-test files should not have assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as others alluded to, you could consider consolidating accounts
in the hardhat config with whaleAddress
& userAddress
in addresses.ts
but fine to wait to it becomes more useful.
a similar thing could be said for networks (ex. expectedChainId()
is coupled and redundant with configurations in hardhat config.)
nothing blocking though. love the CI setup and the commitment to run these tests against both kvtool (testing for us) and hardhat (testing for most evm users) networks 👍 tests will serve as a great reference for js/ts kava interaction
Ty @boodyvo @pirtleshell @downing034 for feedback, filed a ticket for the config refactoring and addresses all other feedback in the next PR. |
This adds a E2E test suite using hardhat and viem for testing EVM compatibility, precompiles, and integrations with smart contracts.
Hardhat is chosen for it's familiarity and great tooling/dev experience. Viem is chosen due to it's excellent typescript support, clean and modular API, and it's extensibility. It's also a project that is extensively tested.
The test suite is written to run on both hardhat and kvtool networks in order to make assertions about compatibility and use hardhat's advanced features when necessary for unit testing supporting contracts. The EVM based accounts are set up to be the same on both networks and the configuration is tested by signing transactions to ensure each environment is set up correctly.
CI is fully integrated to run both hardhat and kvtool networks with the test suite as well as ensure linting and formatting has been run.
Github action changes have been tested locally by:
The
--bind
flag is required for kvtool to correctly mount the kava chain config.