Skip to content

Commit

Permalink
Test governor upgrade, closes #5 (#12)
Browse files Browse the repository at this point in the history
* Set up and run one end-to-end test with the new Governor

Create test harness for testing that the new Governor can execute
proposals after the upgrade has completed. Write one test demonstrating
the Governor's ability to send GTC already held by the timelock.

* Add fuzz seed to .env template to reduce RPC calls

* Generalize governorBravo token send test

* Test that proposals can be defeated for the new governor

* passQueueAndExecuteUpgradeProposal --> upgradeToBravoGovernor

* Test that settings can be updated by new governor

* Test mixed voting results

* Test that alpha votes don't affect bravo votes

* s/governor/governorBravo/g

* scopelint

* Cache fork requests

https://twitter.com/ultrasecreth/status/1603430600442101761/photo/1

* Add a seed to fuzz deterministically in CI

* scopelint

* Troubleshoot CI

* Cycle CI fuzz seeds each week

* Bump fuzz tests in CI

* Remove fuzz seed from .env.template

* Modify based on PR feedback

* Foundry toolchain caches fork requests for us

* ci: test if manually creating cache dir solves the issue

* Fix coverage workflow

* Fix coverage workflow

* Revert "ci: test if manually creating cache dir solves the issue"

This reverts commit adffed2.

* Revert "Foundry toolchain caches fork requests for us"

This reverts commit d7b4570.

* Use cached fork requests on coverage

* Modify based on PR feedback

* Update comment

Co-authored-by: Ben DiFrancesco <ben@scopelift.co>
Co-authored-by: Matt Solomon <matt@mattsolomon.dev>
  • Loading branch information
3 people authored Jan 17, 2023
1 parent db53917 commit 350ec8d
Show file tree
Hide file tree
Showing 4 changed files with 597 additions and 83 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,29 @@ jobs:
with:
version: nightly

- name: Cache fork requests
uses: actions/cache@v3
with:
path: ~/.foundry/cache
key: ${{ runner.os }}-foundry-network-fork-${{ github.sha }}
restore-keys: |
${{ runner.os }}-foundry-network-fork-
# https://twitter.com/PaulRBerg/status/1611116650664796166
- name: Generate fuzz seed with 1 week TTL
run: >
echo "FOUNDRY_FUZZ_SEED=$(
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800))
)" >> $GITHUB_ENV
- name: Run tests
run: forge test

coverage:
env:
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
PROPOSER_PRIVATE_KEY: ${{ secrets.PROPOSER_PRIVATE_KEY }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -53,6 +72,21 @@ jobs:
with:
version: nightly

- name: Cache fork requests
uses: actions/cache@v3
with:
path: ~/.foundry/cache
key: ${{ runner.os }}-foundry-network-fork-${{ github.sha }}
restore-keys: |
${{ runner.os }}-foundry-network-fork-
# https://twitter.com/PaulRBerg/status/1611116650664796166
- name: Recycle the fuzz seed from the test run
run: >
echo "FOUNDRY_FUZZ_SEED=$(
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800))
)" >> $GITHUB_ENV
- name: Run coverage
run: forge coverage --report summary --report lcov

Expand Down
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
verbosity = 3

[profile.ci]
fuzz = { runs = 5000 }
invariant = { runs = 1000 }
fuzz = { runs = 500 }
invariant = { runs = 500 }

[profile.lite]
fuzz = { runs = 50 }
fuzz = { runs = 50, seed = 1673481600 }
invariant = { runs = 10 }
# Speed up compilation and tests during development.
optimizer = false
Expand Down
12 changes: 6 additions & 6 deletions src/GitcoinGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract GitcoinGovernor is
public
view
virtual
override (Governor, GovernorTimelockCompound)
override(Governor, GovernorTimelockCompound)
returns (bool)
{
return GovernorTimelockCompound.supportsInterface(interfaceId);
Expand All @@ -65,7 +65,7 @@ contract GitcoinGovernor is
public
view
virtual
override (Governor, GovernorSettings)
override(Governor, GovernorSettings)
returns (uint256)
{
return GovernorSettings.proposalThreshold();
Expand All @@ -76,7 +76,7 @@ contract GitcoinGovernor is
public
view
virtual
override (Governor, GovernorTimelockCompound)
override(Governor, GovernorTimelockCompound)
returns (ProposalState)
{
return GovernorTimelockCompound.state(proposalId);
Expand All @@ -96,7 +96,7 @@ contract GitcoinGovernor is
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override (Governor, GovernorTimelockCompound) {
) internal virtual override(Governor, GovernorTimelockCompound) {
return
GovernorTimelockCompound._execute(proposalId, targets, values, calldatas, descriptionHash);
}
Expand All @@ -107,7 +107,7 @@ contract GitcoinGovernor is
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override (Governor, GovernorTimelockCompound) returns (uint256) {
) internal virtual override(Governor, GovernorTimelockCompound) returns (uint256) {
return GovernorTimelockCompound._cancel(targets, values, calldatas, descriptionHash);
}

Expand All @@ -116,7 +116,7 @@ contract GitcoinGovernor is
internal
view
virtual
override (Governor, GovernorTimelockCompound)
override(Governor, GovernorTimelockCompound)
returns (address)
{
return GovernorTimelockCompound._executor();
Expand Down
Loading

0 comments on commit 350ec8d

Please sign in to comment.