All of our latest updates are from our
The Synthetix ecosystem relies on automated testing as much as possible to enable a high-frequency of updates while maintaining security and reliability.
Check out a copy of the
synthetix repo and run
npm install to install dependencies.
Even though our project uses hardhat, the integration and deploy tests require
anvil is used because it provides superior performance and has earliest support for certain commands within
Foundry/anvil can be installed with the following command sequence:
1 2 3
For more information about Foundry, see their book.
We rely primarily on CircleCI for our builds.
We currently have over 3000 individual test specs for all contracts under
/contracts running on
hardhat-network. The tests are hosted under the
test/contracts folder, and the setup is under
test/contracts/setup.js. The tests make use of EVM snapshot and restores to quickly restore state between tests.
To run the contract/unit tests on a local machine:
To run a subset of the tests, use
For the contract tests, we have code coverage configured to instrument our sources. So, whenever changes are detected in PRs, coverage reports are compiled and appended to PRs. The default branch for coverage reports is
Our current sunburst graph for contract line coverage from our
Publisher Integration Tests¶
Our custom publisher scripts do all the heavy lifting in deployment. As such, we've got a slew of integration tests that build, deploy and test various scenarios. These are hosted under
To run the publish tests, ensure you have
anvil installed and run:
Deployment Live Tests¶
Every time we deploy updates to Synthetix, we mutate our
deployment.json files under
publish/deploys. This means that all contract addresses, ABI and synths can be loaded without needing any internet connection at all. In order to ensure that our JSON files match the deployed reality on-chain, we run the tests under
test/deployments to verify, in particular, that our ABIs match those on-chain.
Finally, under the
test/integration folder are tests which verify integrity of important flows within the system. These tests can be run in either standalone or forked mode--the latter useful in verifying that features will work with existing system settings after a release .This script is used after each deployment to a testnet to ensure health of the system. We also run Etherscan ABI tests to assert what's been verified in Etherscan matches that in our
To run the integration tests, ensure you have
anvil installed and run:
--compileflag is needed for the first run and can be omitted for subsequent runs with same contracts
1 2 3 4 5
For fork mode, you will need to set your provider URL in
.env. Then run:
1 2 3 4 5 6 7 8 9