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

Updates Test Suite To Execute Using Live Onchain Proposal Data #27

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion script/Propose.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
contract ProposeScript is Script {
IGovernorAlpha constant GOVERNOR_ALPHA =
IGovernorAlpha(0xDbD27635A534A3d3169Ef0498beB56Fb9c937489);
address constant PROPOSER = 0xc2E2B715d9e302947Ec7e312fd2384b5a1296099; // kbw.eth
address PROPOSER = 0xc2E2B715d9e302947Ec7e312fd2384b5a1296099; // kbw.eth

function propose(GitcoinGovernor _newGovernor) internal returns (uint256 _proposalId) {
address[] memory _targets = new address[](2);
Expand All @@ -33,6 +33,13 @@
);
}

/// @dev Used only in the context of testing in order to allow an alternate address to be the
/// proposer. This is needed when testing with live proposal data, because the Governor only
/// allows each proposer to have one live proposal at a time.
function overrideProposerForTests(address _testProposer) external {
Fixed Show fixed Hide fixed
PROPOSER = _testProposer;
}

/// @dev After the new Governor is deployed on mainnet, this can move from a parameter to a const
function run(GitcoinGovernor _newGovernor) public returns (uint256 _proposalId) {
// The expectation is the key loaded here corresponds to the address of the `proposer` above.
Expand Down
25 changes: 17 additions & 8 deletions test/GitcoinGovernor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract contract GitcoinGovernorTestHelper is Test, DeployInput {
function setUp() public virtual {
// The latest block when this test was written. If you update the fork block
// make sure to also update the top 6 delegates below.
uint256 _forkBlock = 17_814_028;
uint256 _forkBlock = 17_878_409;
vm.createSelectFork(vm.rpcUrl("mainnet"), _forkBlock);

// Taken from https://www.tally.xyz/gov/gitcoin/delegates?sort=voting_power_desc.
Expand All @@ -57,7 +57,7 @@ abstract contract GitcoinGovernorTestHelper is Test, DeployInput {
}

if (_useDeployedGovernorBravo()) {
// The GitcoinGovernor contract was deployed to mainnet on April 7th 2023
// The GitcoinGovernor contract was deployed to mainnet on July 31st, 2023
// using DeployScript in this repo.
governorBravo = GitcoinGovernor(payable(DEPLOYED_BRAVO_GOVERNOR));
} else {
Expand Down Expand Up @@ -117,10 +117,19 @@ abstract contract ProposalTestHelper is GitcoinGovernorTestHelper {
function setUp() public virtual override {
GitcoinGovernorTestHelper.setUp();

initialProposalCount = governorAlpha.proposalCount();

ProposeScript _proposeScript = new ProposeScript();
upgradeProposalId = _proposeScript.run(governorBravo);
if (_useDeployedGovernorBravo()) {
// The actual upgrade proposal submitted to Governor Alpha by kbw.eth on August 9th, 2023
upgradeProposalId = 65;
// Since the proposal was already submitted, the count before its submissions is one less
initialProposalCount = governorAlpha.proposalCount() - 1;
} else {
initialProposalCount = governorAlpha.proposalCount();
ProposeScript _proposeScript = new ProposeScript();
// We override the deployer to use kevinolsen.eth, because in this context, kbw.eth already
// has a live proposal
_proposeScript.overrideProposerForTests(0x4Be88f63f919324210ea3A2cCAD4ff0734425F91);
apbendi marked this conversation as resolved.
Show resolved Hide resolved
upgradeProposalId = _proposeScript.run(governorBravo);
}
}

//--------------- HELPERS ---------------//
Expand Down Expand Up @@ -327,7 +336,7 @@ abstract contract AlphaGovernorPostProposalTest is ProposalTestHelper {
bool isGovernorAlphaAdmin
) internal {
// Submit the new proposal
vm.prank(PROPOSER);
vm.prank(0x4Be88f63f919324210ea3A2cCAD4ff0734425F91);
apbendi marked this conversation as resolved.
Show resolved Hide resolved
uint256 _newProposalId =
governorAlpha.propose(_targets, _values, _signatures, _calldatas, "Proposal for old Governor");

Expand Down Expand Up @@ -1361,7 +1370,7 @@ abstract contract FlexVotingTest is GovernorBravoProposalHelper {
}
}

// Exercise the existing Bravo contract deployed on April 7th 2023.
// Exercise the existing Bravo contract deployed on July 31st, 2023.
contract BravoGovernorDeployTestWithExistingBravo is BravoGovernorDeployTest {
function _useDeployedGovernorBravo() internal pure override returns (bool) {
return true;
Expand Down
Loading