-
Notifications
You must be signed in to change notification settings - Fork 2
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: ACL unit tests with foundry #235
Conversation
03bcc28
to
4389f62
Compare
contracts/hardhat.config.ts
Outdated
@@ -1,3 +1,4 @@ | |||
import '@nomicfoundation/hardhat-foundry'; |
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.
why is this import needed?
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.
7e35d1d
to
8a0aa3e
Compare
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: cp ./contracts/.env.example ./contracts/.env | ||
- run: npm --prefix ./contracts ci --include=optional | ||
- run: npm --prefix ./contracts run prettier:check | ||
- name: "npm CI test" | ||
- name: Prettier check |
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.
I think the prettier check should be its own workflow
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.
Can be done in another PR, it is similar in other repos (prettier checks being part of the test workflow)
contracts/test/acl/acl.t.sol
Outdated
import {tfheExecutorAdd} from "../../addresses/TFHEExecutorAddress.sol"; | ||
|
||
/// @dev It is used for checking that _authorizeUpgrade() is gatekept. | ||
contract ACLWithUpgrade is ACL { |
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.
why is this new contract needed?
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.
Remove it and replace it by a call to upgradeToAndCall from the inherited UUPS.
Please remove the ACLWithUpgrade contract in your test, you don't need it and it makes the code less readable. |
8a0aa3e
to
35a991e
Compare
35a991e
to
9a63076
Compare
I just tested the deployment script of this branch and I noticed it breaks on linux VM without foundry installed with "Error in plugin hardhat-foundry". This is really bad. Please don't use this hardhat plugin anymore and put the foundry tests elsewhere in a separate folder inside contracts/. We really don't want to clutter deployment scripts with unnecessary dependencies to make ZWS team job easier. |
contracts/test/acl/acl.t.sol
Outdated
acl.allowForDecryption(handlesList); | ||
} | ||
|
||
function testFail_OnlyOwnerCanAuthorizeUpgrade(address randomAccount) public { |
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.
it would be better here to test the specific error of wrong owner.
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.
I was able to fix your test with an external call to this
as explained on Slack. Weird that you did not manage to make it work on your machine.
forge coverage --report lcov && genhtml lcov.info -o report --branch-coverage