Skip to content

Commit

Permalink
Added test for setting quorum numerator
Browse files Browse the repository at this point in the history
  • Loading branch information
jferas committed Dec 7, 2023
1 parent c594e01 commit f4ac9a3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/RadworksGovernor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IGovernor} from "@openzeppelin/contracts/governance/IGovernor.sol";
import {IGovernorAlpha} from "src/interfaces/IGovernorAlpha.sol";
import {RadworksGovernorTest} from "test/helpers/RadworksGovernorTest.sol";
import {ProposalTest} from "test/helpers/ProposalTest.sol";
import {ProposalBuilder} from "test/helpers/Proposal.sol";
import "../script/DeployInput.sol";

abstract contract Constructor is RadworksGovernorTest {
Expand Down Expand Up @@ -405,7 +406,8 @@ abstract contract Propose is ProposalTest {
function testFuzz_NewGovernorCanUpdateSettingsViaSuccessfulProposal(
uint256 _newDelay,
uint256 _newVotingPeriod,
uint256 _newProposalThreshold
uint256 _newProposalThreshold,
uint256 _newQuorumNumerator
) public {
vm.assume(_newDelay != governorBravo.votingDelay());
vm.assume(_newVotingPeriod != governorBravo.votingPeriod());
Expand All @@ -415,12 +417,13 @@ abstract contract Propose is ProposalTest {
_newDelay = bound(_newDelay, 0, 50_000); // about a week at 1 block per 12s
_newVotingPeriod = bound(_newVotingPeriod, 1, 200_000); // about a month
_newProposalThreshold = bound(_newProposalThreshold, 0, 42 ether);
_newQuorumNumerator = bound(_newQuorumNumerator, 0, 99);

_upgradeToBravoGovernor();

address[] memory _targets = new address[](3);
uint256[] memory _values = new uint256[](3);
bytes[] memory _calldatas = new bytes[](3);
address[] memory _targets = new address[](4);
uint256[] memory _values = new uint256[](4);
bytes[] memory _calldatas = new bytes[](4);
string memory _description = "Update governance settings";

_targets[0] = address(governorBravo);
Expand All @@ -433,6 +436,10 @@ abstract contract Propose is ProposalTest {
_calldatas[2] =
_buildProposalData("setProposalThreshold(uint256)", abi.encode(_newProposalThreshold));

_targets[3] = address(governorBravo);
_calldatas[3] =
_buildProposalData("updateQuorumNumerator(uint256)", abi.encode(_newQuorumNumerator));

// Submit the new proposal
vm.prank(PROPOSER);
uint256 _newProposalId = governorBravo.propose(_targets, _values, _calldatas, _description);
Expand Down Expand Up @@ -470,6 +477,11 @@ abstract contract Propose is ProposalTest {
assertEq(governorBravo.votingDelay(), _newDelay);
assertEq(governorBravo.votingPeriod(), _newVotingPeriod);
assertEq(governorBravo.proposalThreshold(), _newProposalThreshold);
assertEq(governorBravo.quorumNumerator(block.number), _newQuorumNumerator);
assertEq(
governorBravo.quorum(block.number),
(governorBravo.token().totalSupply() * _newQuorumNumerator) / 100
);
}

function testFuzz_NewGovernorCanPassMixedProposal(
Expand Down

0 comments on commit f4ac9a3

Please sign in to comment.