Skip to content
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

Merged
merged 5 commits into from
Jan 9, 2025
Merged

test: ACL unit tests with foundry #235

merged 5 commits into from
Jan 9, 2025

Conversation

PacificYield
Copy link
Contributor

@PacificYield PacificYield commented Jan 8, 2025

forge coverage --report lcov && genhtml lcov.info -o report --branch-coverage

Feature Total Hit
Lines 100.0% 68/68
Functions 100.0% 15/15
Branches 100.0% 6/6

@@ -1,3 +1,4 @@
import '@nomicfoundation/hardhat-foundry';
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PacificYield PacificYield force-pushed the acl-foundry branch 2 times, most recently from 7e35d1d to 8a0aa3e Compare January 8, 2025 09:28
@PacificYield PacificYield marked this pull request as ready for review January 8, 2025 09:32
- 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
Copy link
Contributor Author

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

Copy link
Contributor Author

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)

import {tfheExecutorAdd} from "../../addresses/TFHEExecutorAddress.sol";

/// @dev It is used for checking that _authorizeUpgrade() is gatekept.
contract ACLWithUpgrade is ACL {
Copy link
Member

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?

Copy link
Member

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.

@jatZama
Copy link
Member

jatZama commented Jan 8, 2025

Please remove the ACLWithUpgrade contract in your test, you don't need it and it makes the code less readable.
Use the already existing UUPS function for upgrading instead https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/UUPSUpgradeable.sol#L86

@PacificYield PacificYield marked this pull request as draft January 8, 2025 11:30
@PacificYield PacificYield changed the title test: ACL unit tests with foundry test: ACL unit tests with foundry (WIP) Jan 8, 2025
contracts/README.md Outdated Show resolved Hide resolved
@PacificYield PacificYield marked this pull request as ready for review January 9, 2025 11:16
@PacificYield PacificYield requested a review from jatZama January 9, 2025 11:16
@PacificYield PacificYield changed the title test: ACL unit tests with foundry (WIP) test: ACL unit tests with foundry Jan 9, 2025
@jatZama
Copy link
Member

jatZama commented Jan 9, 2025

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.

acl.allowForDecryption(handlesList);
}

function testFail_OnlyOwnerCanAuthorizeUpgrade(address randomAccount) public {
Copy link
Member

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.

@PacificYield PacificYield requested a review from jatZama January 9, 2025 15:53
Copy link
Member

@jatZama jatZama left a 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.

@PacificYield PacificYield merged commit a56ed6e into main Jan 9, 2025
3 checks passed
@PacificYield PacificYield deleted the acl-foundry branch January 9, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants