Skip to content

Commit

Permalink
fix simulate
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed May 16, 2024
1 parent f6f3858 commit 0584e1c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/interface/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ interface IGovernor {
* {proposalDeadline}, this doesn't use the governor clock, and instead relies on the executor's clock which may be
* different. In most cases this will be a timestamp.
*/
function proposalEta(uint256 proposalId) external view returns (uint256);
function proposaleta(uint256 proposalId) external view returns (uint256);

/**
* @notice module:core
Expand Down
31 changes: 24 additions & 7 deletions src/proposals/GovernorOZProposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,36 @@ abstract contract GovernorOZProposal is Proposal {
? quorumVotes
: proposalThreshold;
deal(address(governanceToken), proposerAddress, votingPower);
vm.roll(block.number - 1);
// Delegate proposer's votes to itself
vm.prank(proposerAddress);
IVotes(governanceToken).delegate(proposerAddress);
vm.roll(block.number + 1);
vm.roll(block.number + 2);
}

bytes memory proposeCalldata = getCalldata();

// Register the proposal
vm.prank(proposerAddress);
bytes memory data = address(governor).functionCall(proposeCalldata);
uint256 proposalId = abi.decode(data, (uint256));

uint256 returnedProposalId = abi.decode(data, (uint256));

(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas
) = getProposalActions();

// Check that the proposal was registered correctly
uint256 proposalId = governor.hashProposal(
targets,
values,
calldatas,
keccak256(abi.encodePacked(description()))
);

require(returnedProposalId == proposalId, "Proposal id mismatch");

// Check proposal is in Pending state
require(
Expand All @@ -105,6 +123,7 @@ abstract contract GovernorOZProposal is Proposal {

// Roll to Active state (voting period)
vm.roll(block.number + governor.votingDelay() + 1);

require(
governor.state(proposalId) == IGovernor.ProposalState.Active
);
Expand All @@ -115,15 +134,13 @@ abstract contract GovernorOZProposal is Proposal {

// Roll to allow proposal state transitions
vm.roll(block.number + governor.votingPeriod());

require(
governor.state(proposalId) == IGovernor.ProposalState.Succeeded
);

(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas
) = getProposalActions();

vm.warp(block.timestamp + governor.proposalEta(proposalId) + 1);

// Queue the proposal
governor.queue(targets, values, calldatas, keccak256(abi.encodePacked(description())));
Expand Down
2 changes: 1 addition & 1 deletion src/proposals/IProposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ interface IProposal {
/// @notice set the Addresses contract
function setAddresses(Addresses _addresses) external;

/// @notice set primary fork id
/// @notice set the primary fork id
function setPrimaryForkId(uint256 _forkId) external;
}

0 comments on commit 0584e1c

Please sign in to comment.