-
Notifications
You must be signed in to change notification settings - Fork 375
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
test: proof of concept 2e2 test using anvil devchain #11020
Merged
arthurgousset
merged 18 commits into
master
from
arthurgousset/test/anvil-proof-of-concept-2e2-test
Jun 7, 2024
Merged
test: proof of concept 2e2 test using anvil devchain #11020
arthurgousset
merged 18 commits into
master
from
arthurgousset/test/anvil-proof-of-concept-2e2-test
Jun 7, 2024
Conversation
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
MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end.
arthurgousset
force-pushed
the
arthurgousset/test/anvil-proof-of-concept-2e2-test
branch
from
June 5, 2024 14:23
335a9c2
to
06416ac
Compare
Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain.
arthurgousset
commented
Jun 6, 2024
arthurgousset
force-pushed
the
arthurgousset/test/anvil-proof-of-concept-2e2-test
branch
from
June 6, 2024 09:55
082d130
to
b5dc987
Compare
Cleans up Adds `TODO` comments
I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ```
I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ```
In subsequent PRs, I'll rename this more accurately.
This was referenced Jun 6, 2024
pahor167
approved these changes
Jun 7, 2024
arthurgousset
deleted the
arthurgousset/test/anvil-proof-of-concept-2e2-test
branch
June 7, 2024 08:19
soloseng
added a commit
that referenced
this pull request
Jun 12, 2024
* test: proof of concept 2e2 test using anvil devchain (#11020) * chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..` * test(test-sol/FeeCurrencyDirectory)): MVP e2e test MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end. * chore(foundry.toml): adds `@test-sol` remapping * chore(test-sol/e2e): adds MVP `utils.sol` Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain. * test(FeeCurrencyDirectory): MVP test using `Devchain` class * chore(migrations_sol): adds MVP script to run e2e tests * style(test-sol/e2e): linting * refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/` * chore(migrations_sol): use `test-sol/e2e/*` path * chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test * style(test-sol/FeeCurrencyDirectory): linting * chore(e2e/utils): removes unused imports and more Cleans up Adds `TODO` comments * test(test-sol/e2e): renames contract with "E2E..." I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * chore(workflows/protocol_tests): excludes e2e test from workflow I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * style(test-sol/e2e): linting * chore(e2e): temporarily renames contract with "E2E..." In subsequent PRs, I'll rename this more accurately. * feat: add ReserveSpenderMultiSig to anvil migrations (#11028) * feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs * feat(migrations_sol): adds `migrateReserveSpenderMultiSig` Also adds contract calls in `migrateReserve` function. Not tested, and not sure this works yet. I might be missing some changes. * chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol` From the code comment: The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`. This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations script, but because it's on Solidity 0.5 it can't be imported there directly. If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without this file, this file can confidently be deleted. * feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig` The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function. * chore(migrations_sol): initialize `ReserveSpenderMultiSig` * chore(migrations_sol): adds code comment for readability * chore(migrations_sol): improves code comment, moves code block up * chore(migrations_sol): fix typo * style(migrations_sol): linting * 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. * Soloseng/CHORE-update-workflow (#11029) * update workflow to run on push to release branches * ++ mintgoldschedule to migration test constants * update GH WF --------- Co-authored-by: Arthur Gousset <[email protected]>
soloseng
added a commit
that referenced
this pull request
Jun 18, 2024
* test: proof of concept 2e2 test using anvil devchain (#11020) * chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..` * test(test-sol/FeeCurrencyDirectory)): MVP e2e test MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end. * chore(foundry.toml): adds `@test-sol` remapping * chore(test-sol/e2e): adds MVP `utils.sol` Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain. * test(FeeCurrencyDirectory): MVP test using `Devchain` class * chore(migrations_sol): adds MVP script to run e2e tests * style(test-sol/e2e): linting * refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/` * chore(migrations_sol): use `test-sol/e2e/*` path * chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test * style(test-sol/FeeCurrencyDirectory): linting * chore(e2e/utils): removes unused imports and more Cleans up Adds `TODO` comments * test(test-sol/e2e): renames contract with "E2E..." I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * chore(workflows/protocol_tests): excludes e2e test from workflow I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * style(test-sol/e2e): linting * chore(e2e): temporarily renames contract with "E2E..." In subsequent PRs, I'll rename this more accurately. * set EpochSize on L2 * allow voting and activating * move election test contract to vote dir * updated test to allow testing of L2 with no reward distribution * feat: add ReserveSpenderMultiSig to anvil migrations (#11028) * feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs * feat(migrations_sol): adds `migrateReserveSpenderMultiSig` Also adds contract calls in `migrateReserve` function. Not tested, and not sure this works yet. I might be missing some changes. * chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol` From the code comment: The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`. This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations script, but because it's on Solidity 0.5 it can't be imported there directly. If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without this file, this file can confidently be deleted. * feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig` The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function. * chore(migrations_sol): initialize `ReserveSpenderMultiSig` * chore(migrations_sol): adds code comment for readability * chore(migrations_sol): improves code comment, moves code block up * chore(migrations_sol): fix typo * style(migrations_sol): linting * 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. * lint: function order * Soloseng/CHORE-update-workflow (#11029) * update workflow to run on push to release branches * ++ mintgoldschedule to migration test constants * initial validators contract review * Remove block gas limit flag for `governance/voting` CI tests * bump version * ++ tests && format * removed comments * getValidatorGroupSlashingMultiplier allowed only on L1 * reverting changes to test contract size issue * minimal changes * allow slashing multiplier reset on L2 --------- Co-authored-by: Arthur Gousset <[email protected]>
soloseng
added a commit
that referenced
this pull request
Jun 18, 2024
* Yaml file drafts * Update COPUSD Config * Update KESUSD and rename USDKES.yaml to KESUSD.yaml * Rename USDCOP.yaml to COPUSD.yaml * Adding KESUSD data source * CELOKES and KESUSD config * chore: test USDTUSD config * fix: remove openexchangerates from kesusd * chore: add pair constants * chore: add alfajores & baklava kesusd and usdtusd addresses * fix: use pnpm instead of yarn * fix: update min oracles for CELOKES * chore: add mainnet kes hsms * USDTUSD config from Nadiem * test: proof of concept 2e2 test using anvil devchain (#11020) * chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..` * test(test-sol/FeeCurrencyDirectory)): MVP e2e test MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end. * chore(foundry.toml): adds `@test-sol` remapping * chore(test-sol/e2e): adds MVP `utils.sol` Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain. * test(FeeCurrencyDirectory): MVP test using `Devchain` class * chore(migrations_sol): adds MVP script to run e2e tests * style(test-sol/e2e): linting * refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/` * chore(migrations_sol): use `test-sol/e2e/*` path * chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test * style(test-sol/FeeCurrencyDirectory): linting * chore(e2e/utils): removes unused imports and more Cleans up Adds `TODO` comments * test(test-sol/e2e): renames contract with "E2E..." I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * chore(workflows/protocol_tests): excludes e2e test from workflow I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * style(test-sol/e2e): linting * chore(e2e): temporarily renames contract with "E2E..." In subsequent PRs, I'll rename this more accurately. * chore: latest deployed images * feat: add ReserveSpenderMultiSig to anvil migrations (#11028) * feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs * feat(migrations_sol): adds `migrateReserveSpenderMultiSig` Also adds contract calls in `migrateReserve` function. Not tested, and not sure this works yet. I might be missing some changes. * chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol` From the code comment: The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`. This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations script, but because it's on Solidity 0.5 it can't be imported there directly. If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without this file, this file can confidently be deleted. * feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig` The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function. * chore(migrations_sol): initialize `ReserveSpenderMultiSig` * chore(migrations_sol): adds code comment for readability * chore(migrations_sol): improves code comment, moves code block up * chore(migrations_sol): fix typo * style(migrations_sol): linting * 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. * Soloseng/CHORE-update-workflow (#11029) * update workflow to run on push to release branches * ++ mintgoldschedule to migration test constants * set celo-foundry to 0.5 * force CI test after changing PR base --------- Co-authored-by: Nadiem Sissouno <[email protected]> Co-authored-by: Nadiem Sissouno <[email protected]> Co-authored-by: Nelson Taveras <[email protected]> Co-authored-by: Arthur Gousset <[email protected]> Co-authored-by: soloseng <[email protected]>
soloseng
added a commit
that referenced
this pull request
Jul 16, 2024
* lint: function ordering * Deprecate L1 hotfix; Implement L2 hotfix; * BUMP version * prepare hotfix on L2 * cleanup * ++ setters and checks * ++ more test cases * PR feedback * PR feedback * PR feedback * resetHotfix is public * test: proof of concept 2e2 test using anvil devchain (#11020) * chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..` * test(test-sol/FeeCurrencyDirectory)): MVP e2e test MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end. * chore(foundry.toml): adds `@test-sol` remapping * chore(test-sol/e2e): adds MVP `utils.sol` Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain. * test(FeeCurrencyDirectory): MVP test using `Devchain` class * chore(migrations_sol): adds MVP script to run e2e tests * style(test-sol/e2e): linting * refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/` * chore(migrations_sol): use `test-sol/e2e/*` path * chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test * style(test-sol/FeeCurrencyDirectory): linting * chore(e2e/utils): removes unused imports and more Cleans up Adds `TODO` comments * test(test-sol/e2e): renames contract with "E2E..." I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * chore(workflows/protocol_tests): excludes e2e test from workflow I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run. In a separate PR, I'll refactor the tests into a directory structure like: ``` test-sol/unit/ test-sol/e2e/ test-sol/integration/ ``` That way we could run tests with something like this: ``` # unit tests forge test --match-path "*test-sol/unit/*" # e2e tests forge test --match-path "*test-sol/e2e/*" # integration tests forge test --match-path "*test-sol/integration/*" ``` * style(test-sol/e2e): linting * chore(e2e): temporarily renames contract with "E2E..." In subsequent PRs, I'll rename this more accurately. * feat: add ReserveSpenderMultiSig to anvil migrations (#11028) * feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs * feat(migrations_sol): adds `migrateReserveSpenderMultiSig` Also adds contract calls in `migrateReserve` function. Not tested, and not sure this works yet. I might be missing some changes. * chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol` From the code comment: The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`. This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations script, but because it's on Solidity 0.5 it can't be imported there directly. If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without this file, this file can confidently be deleted. * feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig` The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function. * chore(migrations_sol): initialize `ReserveSpenderMultiSig` * chore(migrations_sol): adds code comment for readability * chore(migrations_sol): improves code comment, moves code block up * chore(migrations_sol): fix typo * style(migrations_sol): linting * 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. * Soloseng/CHORE-update-workflow (#11029) * update workflow to run on push to release branches * ++ mintgoldschedule to migration test constants * fixed inheritance * added pretest check --------- Co-authored-by: Arthur Gousset <[email protected]> Co-authored-by: Leszek Stachowski <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Devchain
class (intest-sol/e2e/utils.sol
). This class can be inherited by e2e test files to have access to the deployed contracts on the devchain.FeeCurrencyDirectory.t.sol
(intest-sol/e2e/common/FeeCurrencyDirectory.t.sol
) that leverages theDevchain
class, and runs e2e tests against theFeeCurrencyDirectory
contract on the anvil devchainrun_e2e_tests_in_anvil.sh
) that can be used in CI workflows.Other changes
../..
with@celo-...
remapping inFeeCurrencyDirectory.t.sol
Note
I decided to keep this PR small, but in a subsequent PR, I'd like to refactor the
test-sol/
directory structure like:That way we could run tests on CI with a command structure like:
Here is an issue to track this:
Tested
Yes, tested locally ✅
Steps to reproduce e2e test locally:
Create and run anvil devchain (in a separate terminal)
cd packages/protocol ./migrations_sol/create_and_migrate_anvil_devchain.sh
Run e2e test against anvil devchain
Not tested on CI. I'll include e2e tests on CI after I refactor the
test-sol/
directory structure as described here:Related issues
Backwards compatibility
Yes, only adds tests.
Documentation
No, we'll need better documentation for Foundry tests in general once the directory structure is cleaner.