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

Governance integration tests #330

Merged
merged 63 commits into from
Dec 19, 2023
Merged

Conversation

baroooo
Copy link
Contributor

@baroooo baroooo commented Dec 18, 2023

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

bowd and others added 30 commits November 8, 2023 09:55
…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
Copy link

openzeppelin-code bot commented Dec 18, 2023

Governance integration tests

Generated at commit: 8fe3e73a0923ceb5b93c7867f80043753e486d54

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
1
0
16
38
56
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@baroooo baroooo changed the title Feat/factory integration tests Governance integration tests Dec 18, 2023
@baroooo baroooo marked this pull request as ready for review December 18, 2023 13:41
@baroooo baroooo requested review from bowd and chapati23 December 18, 2023 13:42
Copy link
Contributor

@chapati23 chapati23 left a 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

Copy link
Contributor

@chapati23 chapati23 left a 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

Copy link
Contributor

@chapati23 chapati23 Dec 19, 2023

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 in Integration.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 with totalEmittedAmount
  • 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.

Copy link
Contributor

@chapati23 chapati23 Dec 19, 2023

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

Copy link
Contributor

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

Copy link
Contributor

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

Comment on lines 29 to 30
targets = new address[](1);
targets[0] = address(emission);
Copy link
Contributor

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).

Comment on lines 12 to 14
import { Test } from "forge-std-next/Test.sol";

contract Proposals is Test {
Copy link
Contributor

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.

Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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

Comment on lines 665 to 670
// create a transaction to transfer tokens from the multisig to the governanceTimelockAddress
bytes memory transferCallData = abi.encodeWithSelector(
mentoToken.transfer.selector,
governanceTimelockAddress,
10_000_000e18
);
Copy link
Contributor

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")),
Copy link
Contributor

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"

@baroooo baroooo merged commit 61eb278 into feat/tokenWork Dec 19, 2023
3 of 15 checks passed
@baroooo baroooo deleted the feat/factory-integration-tests branch December 19, 2023 17:55
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.

3 participants