-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor foundry test directory into unit, e2e, and integration…
… tests (#11023) * chore(foundry.toml): adds `@mento-core/...` remapping Also moves existing mappings into groups for better readability * refactor(test-sol/common): moves files to `unit/common/` Also updates imports respectively using remappings. * refactor(test-sol/identity): moves files to `unit/identity/` Also updates imports using remappings where necessary. * refactor(test-sol/stability): moves files to `unit/stability/` Also updates imports using remappings where necessary. * refactor(test-sol/voting): moves files to `unit/voting/` Also updates imports using remappings where necessary. * refactor(test-sol/governance): moves files to `unit/governance/` Also updates imports using remappings where necessary. * chore(test-sol): update missing remappings With these changes all contracts compile and resolve correctly. * chore(workflows/protocol_tests): updates paths to `test-sol/unit` * chore(workflows/protocol_tests): adds integration and e2e tests * style(workflows/protocol_tests): refactors `forge test` for better readability * chore(migrations_sol): moves scripts to `scripts/foundry/ Moves all bash scripts from `migrations_sol` to `scripts/foundry/`, and updates paths where necessary. We already have a directory for `scripts/truffle/` and `scripts/bash/`, so this makes it easier to find foundry-related bash scripts. * test(governance/mock): move `MockGovernance` to `unit/` folder * refactor(foundry.toml): rename `migrations-sol/` remapping * refactor(workflows): refactor "run everything" step Runs all tests in the `unit/` directory instead of all test files in the repo. This makes sense from my perspective, because e2e tests (in the `e2e/` directory) and integration tests (in the `integration/` directory) require a connection to an anvil devchain serving at localhost. The intent of this command is to ensure that no unit tests are forgotten, since unit tests are run explicitly by going through the directories above. But, the intention is not to run all tests in the repo generally. * style(workflows/protocol-devchain-anvil): splits migration into 2 steps This helps the script becoming more readable, and ensure error logs are clearly associated with a workflow step rather than a single bash script. * chore(workflows): defines `ANVIL_PORT` env variable in workflow Previously, the `$ANVIL_PORT` variable was exported and passed around as an env variable in a bash script. But that required generating anvil migrations and running a devchain repeatedly. Instead, the workflow does that once and different steps can access the devchain. But, in that case the env variable is not passed around, so it has to be defined at the workflow level. Source: https://docs.github.com/en/actions/learn-github-actions/variables * chore(workflows/protocol_tests): removes code comment * feat(scripts/foundry): adds `stop_anvil.sh` * refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil * feat(protocol/package.json): adds `anvil-devchain:...` (`start` and `stop`) * refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil * refactor(migrations_sol): update `@migrations-sol` remapping Previous the remapping was called `@celo-migrations`. * docs(migrations_sol/README): renames README file Also changes title to match NPM package name. This is a matter of personal preference. IMO this is a small improvement in readability for 3rd party users. * docs(scripts/foundry): adds more links to `package.json` Adds `repository` and `directory` to `package.json`. This ensures npmjs.org displays hyperlinks to the github repository. * docs(migrations_sol/CONTRIBUTING): adds MVP dev docs We can complete this doc with additional information regarding the anvil devchain and migrations going forward. * docs(migrations_sol/README): adds "how we work" section This is helpful for 3rd party developers that found this package on npmjs.org. The links help developers take action and help improve the anvil devchain.
- Loading branch information
1 parent
adb51bd
commit 0822209
Showing
65 changed files
with
238 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Anvil migrations | ||
|
||
The "Anvil migrations" are a set of scripts that generate a local anvil-based devchain. | ||
This devchain is useful for testing and development of the Celo protocol. | ||
|
||
## Usage | ||
|
||
### Start devchain | ||
|
||
```sh | ||
$ yarn anvil-devchain:start | ||
``` | ||
|
||
Starts a new anvil devchain serving at localhost (default port 8546). | ||
|
||
For example: | ||
|
||
```sh | ||
$ yarn anvil-devchain:start | ||
|
||
yarn run v1.22.22 | ||
$ ./scripts/foundry/create_and_migrate_anvil_devchain.sh | ||
# ... | ||
Total elapsed time: 193 seconds | ||
✨ Done in 193.09s. | ||
``` | ||
|
||
You can now run commands against the local devchain. | ||
|
||
For example: | ||
|
||
```sh | ||
cast block-number \ | ||
--rpc-url http://127.0.0.1:8546 | ||
266 | ||
``` | ||
|
||
### Stop devchain | ||
|
||
```sh | ||
$ yarn anvil-devchain:stop | ||
``` | ||
|
||
Terminates any anvil nodes serving at localhost. | ||
|
||
For example: | ||
|
||
```sh | ||
# in packages/protocol/ directory | ||
$ yarn anvil-devchain:stop | ||
|
||
yarn run v1.22.22 | ||
$ ./scripts/foundry/stop_anvil.sh | ||
Connection to localhost port 8546 [tcp/*] succeeded! | ||
Killed Anvil | ||
✨ Done in 0.11s. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# @celo/devchain-anvil | ||
|
||
Anvil state with Celo core contracts for local testing and development. | ||
|
||
# Usage | ||
|
||
```bash | ||
npm install --save-dev @celo/devchain-anvil | ||
anvil --state <path_to_devchain.json> | ||
``` | ||
|
||
## How we work | ||
|
||
We are a GitHub-first team, which means we have a strong preference for communicating via GitHub. | ||
Please use GitHub to: | ||
|
||
🐞 [File a bug report](https://github.com/celo-org/celo-monorepo/issues/new/choose) | ||
|
||
💬 [Ask a question](https://github.com/celo-org/celo-monorepo/discussions) | ||
|
||
✨ [Suggest a feature](https://github.com/celo-org/celo-monorepo/issues/new/choose) | ||
|
||
🧑💻 [Contribute!](https://github.com/celo-org/celo-monorepo/tree/master/packages/protocol/migrations_sol/CONTRIBUTING.md) | ||
|
||
🚔 [Report a security vulnerability](https://github.com/celo-org/celo-monorepo/issues/new/choose) | ||
|
||
> [!TIP] | ||
> | ||
> Please avoid messaging us via Slack, Telegram, or email. We are more likely to respond to you on | ||
> GitHub than if you message us anywhere else. We actively monitor GitHub, and will get back to you shortly 🌟 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# A small script to terminate any instance of anvil currently serving at localhost. | ||
|
||
ANVIL_PORT=8546 | ||
|
||
if nc -z localhost $ANVIL_PORT; then | ||
kill $(lsof -i tcp:$ANVIL_PORT | tail -n 1 | awk '{print $2}') | ||
echo "Killed Anvil" | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.