-
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
Governance integration tests #330
Conversation
…simpler testing all other related state vars are public so this seems to have been a minor oversight rather than intentional making it private
integration tests will be added in another branch
…ing SARIF report this should not change the fact that CI fails when slither complains. because the SARIF report should contain the same errors which then would make CI fail. But we'd keep the record of issues via SARIF files which currently is not the case.
replaced handmade copy/pasta interfaces with the real code from gnosis
Governance integration tests
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
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.
didn't manage to get through everything yet, will continue tomorrow but here's a few small comments already
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.
Very solid work!
Didn't find anything wrong, just some additional test ideas I'd like to align on if we want to add them or not
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.
Governance Test Plan has the following additional tests that we don't have integrations tests for yet:
- MentoGovernor - Defeat a proposal (majority votes NO)
- MentoToken - Send and burn tokens
- Emission - Correctness of calculation of emitted amounts (it's tested a little bit in
test_watchdog_cancel_shouldCancelQueuedProposal
as a drive by but we could add a more explicit test for it) - Airgrab - Reclaiming or claiming higher amount than allocated reverts
- Airgrab - Claiming with an invalid proof reverts (you have a
invalidClaimer
var inIntegration.sol
but it appears unused - Airgrab - Claiming with a random account reverts
- Airgrab - Draining after airgrab end should send remaining tokens to the Celo Community Fund (and maybe also show that draining before end of airgrab is not possible?)
- Governance Timelock - Change roles on timelock (proposer / executor / canceller)
- Mento Labs Treasury - Transfer ownership and verify new ownership
- Emission & MentoToken - Check that
MentoToken.emittedAmount
lines up withtotalEmittedAmount
- Airgrab - Claiming with a delegate delegates the voting power
I'm not saying we should write integration tests for all of these scenarios but as a basis for discussion which ones to add and which ones deliberately not to add.
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.
After a quick discusison we agreed most of the scenarios are covered by unit tests already, but the following should be evaluated more closely for additional tests:
- Governance Timelock - Change roles on timelock (proposer / executor / canceller)
- Mento Labs Treasury - Transfer ownership and verify new ownership
- Emission & MentoToken - Check that MentoToken.emittedAmount lines up with totalEmittedAmount
- Airgrab - Claiming with a delegate delegates the voting power
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.
Approving this already given I'll be off until February. We aligned on a call on open discussion points and I have full faith in @baroooo to bring it over the finish line.
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.
🚂 cho-chooo! Here come the integration tests! Great work!
I left some minor comments and a proposal for some quick refactoring around Utils and Proposal that I sketched here: https://github.com/mento-protocol/mento-core/pull/332/files - I'm not married to these but if you like it you can merge 'em.
targets = new address[](1); | ||
targets[0] = address(emission); |
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.
We have this Arrays
library that lets you do Arrays.addresses(emission)
here. It has overloaded methods for up to 6 items (IIRC) and for multiple types (uints, bytes, etc).
import { Test } from "forge-std-next/Test.sol"; | ||
|
||
contract Proposals is Test { |
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.
nit: If I didn't miss anything, this contract can be a Library, and it doesn't need to inherit from Test. I think I'd prefer that more.
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.
actually tried to sketch some changes in this proposal: https://github.com/mento-protocol/mento-core/pull/332/files
import { ECDSA } from "openzeppelin-contracts-next/contracts/utils/cryptography/ECDSA.sol"; | ||
import { Strings } from "openzeppelin-contracts-next/contracts/utils/Strings.sol"; | ||
|
||
contract Utils is Test { |
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 propose we turn this into a VmExtensions library as this seams to be useful in multiple places.
Here's a sketch of what I mean: https://github.com/mento-protocol/mento-core/pull/332/files
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.
looks great, yeah lets merge this
// create a transaction to transfer tokens from the multisig to the governanceTimelockAddress | ||
bytes memory transferCallData = abi.encodeWithSelector( | ||
mentoToken.transfer.selector, | ||
governanceTimelockAddress, | ||
10_000_000e18 | ||
); |
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.
This transaction transfers tokens from the MentoLabsTreasury
to the GovernanceTimelock
(or MentoProtocolTreasury
).
I would fix the comment for sure, but maybe change this so that we transfer tokens from MentoLabsTreasury
to the MentoLabsMultisig
. It's not a big deal, but that's the actual flow we would do, and I think it's less confusing then transferring to the protocol.
0, | ||
proposerRoleCallData, | ||
0, | ||
keccak256(bytes("Transfer tokens to governanceTimelockAddress")), |
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.
nit: "Grant proposal role to alice"
Description
Integration tests that cover functionality around new governance and token.
This branch is based on the governance factory branch. Once that is merged all the related changes should be contained in
/test/governance/IntegrationTests
Other changes
Utils.sol and Proposals.sol that is used by the tests
Removed the old comment on Airgrab.sol about the ownership of the contract.
Tested
Yes
Related issues