Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Dec 13, 2023
1 parent 0980654 commit d42da20
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 18 deletions.
23 changes: 20 additions & 3 deletions src/governance/governor/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos
/// @param _proposalId The proposal id
/// @param _support The support value (0 = Against, 1 = For, 2 = Abstain)
/// @param _reason The vote reason
function castVoteWithReason(bytes32 _proposalId, uint256 _support, string memory _reason) external returns (uint256) {
function castVoteWithReason(
bytes32 _proposalId,
uint256 _support,
string memory _reason
) external returns (uint256) {
return _castVote(_proposalId, msg.sender, _support, _reason);
}

Expand Down Expand Up @@ -270,7 +274,12 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos
/// @param _proposalId The proposal id
/// @param _voter The voter address
/// @param _support The vote choice
function _castVote(bytes32 _proposalId, address _voter, uint256 _support, string memory _reason) internal returns (uint256) {
function _castVote(
bytes32 _proposalId,
address _voter,
uint256 _support,
string memory _reason
) internal returns (uint256) {
// Ensure voting is active
if (state(_proposalId) != ProposalState.Active) revert VOTING_NOT_STARTED();

Expand Down Expand Up @@ -518,7 +527,15 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos

/// @notice The vote counts for a proposal
/// @param _proposalId The proposal id
function proposalVotes(bytes32 _proposalId) external view returns (uint256, uint256, uint256) {
function proposalVotes(bytes32 _proposalId)
external
view
returns (
uint256,
uint256,
uint256
)
{
Proposal memory proposal = proposals[_proposalId];

return (proposal.againstVotes, proposal.forVotes, proposal.abstainVotes);
Expand Down
15 changes: 13 additions & 2 deletions src/governance/governor/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ interface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 {
/// @param proposalId The proposal id
/// @param support The support value (0 = Against, 1 = For, 2 = Abstain)
/// @param reason The vote reason
function castVoteWithReason(bytes32 proposalId, uint256 support, string memory reason) external returns (uint256);
function castVoteWithReason(
bytes32 proposalId,
uint256 support,
string memory reason
) external returns (uint256);

/// @notice Casts a signed vote
/// @param voter The voter address
Expand Down Expand Up @@ -245,7 +249,14 @@ interface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 {

/// @notice The vote counts for a proposal
/// @param proposalId The proposal id
function proposalVotes(bytes32 proposalId) external view returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
function proposalVotes(bytes32 proposalId)
external
view
returns (
uint256 againstVotes,
uint256 forVotes,
uint256 abstainVotes
);

/// @notice The timestamp valid to execute a proposal
/// @param proposalId The proposal id
Expand Down
24 changes: 21 additions & 3 deletions test/Gov.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 {
vm.warp(block.timestamp + 20);
}

function castVotes(bytes32 _proposalId, uint256 _numAgainst, uint256 _numFor, uint256 _numAbstain) internal {
function castVotes(
bytes32 _proposalId,
uint256 _numAgainst,
uint256 _numFor,
uint256 _numAbstain
) internal {
uint256 currentVoterIndex;

for (uint256 i = 0; i < _numAgainst; ++i) {
Expand All @@ -175,7 +180,15 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 {
}
}

function mockProposal() internal view returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas) {
function mockProposal()
internal
view
returns (
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas
)
{
targets = new address[](1);
values = new uint256[](1);
calldatas = new bytes[](1);
Expand All @@ -201,7 +214,12 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 {
proposalId = governor.propose(targets, values, calldatas, "");
}

function createProposal(address _proposer, address _target, uint256 _value, bytes memory _calldata) internal returns (bytes32 proposalId) {
function createProposal(
address _proposer,
address _target,
uint256 _value,
bytes memory _calldata
) internal returns (bytes32 proposalId) {
deployMock();

address[] memory targets = new address[](1);
Expand Down
43 changes: 36 additions & 7 deletions test/Token.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
}

/// Test that the percentages for founders all ends up as expected
function test_FounderShareAllocationFuzz(uint256 f1Percentage, uint256 f2Percentage, uint256 f3Percentage) public {
function test_FounderShareAllocationFuzz(
uint256 f1Percentage,
uint256 f2Percentage,
uint256 f3Percentage
) public {
address f1Wallet = address(0x1);
address f2Wallet = address(0x2);
address f3Wallet = address(0x3);
Expand Down Expand Up @@ -457,7 +461,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
assertEq(token.ownerOf(tokenId), newMinter);
}

function testRevert_OnlyMinterCanMintToRecipient(address newMinter, address nonMinter, address recipient) public {
function testRevert_OnlyMinterCanMintToRecipient(
address newMinter,
address nonMinter,
address recipient
) public {
deployMock();
vm.assume(
newMinter != nonMinter && newMinter != founder && newMinter != address(0) && newMinter != address(auction) && recipient != address(0)
Expand All @@ -478,7 +486,12 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
assertEq(token.ownerOf(tokenId), recipient);
}

function testRevert_OnlyMinterCanMintBatch(address newMinter, address nonMinter, address recipient, uint256 amount) public {
function testRevert_OnlyMinterCanMintBatch(
address newMinter,
address nonMinter,
address recipient,
uint256 amount
) public {
deployMock();

vm.assume(
Expand Down Expand Up @@ -649,7 +662,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
assertEq(token.getFounders().length, 1);
}

function test_UpdateFounderShareAllocationFuzz(uint256 f1Percentage, uint256 f2Percentage, uint256 f3Percentage) public {
function test_UpdateFounderShareAllocationFuzz(
uint256 f1Percentage,
uint256 f2Percentage,
uint256 f3Percentage
) public {
deployMock();

address f1Wallet = address(0x1);
Expand Down Expand Up @@ -830,7 +847,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
token.ownerOf(tokenId);
}

function test_MinterCanMintFromReserve(address _minter, uint256 _reservedUntilTokenId, uint256 _tokenId) public {
function test_MinterCanMintFromReserve(
address _minter,
uint256 _reservedUntilTokenId,
uint256 _tokenId
) public {
deployAltMock(_reservedUntilTokenId);

vm.assume(_minter != founder && _minter != address(0) && _minter != address(auction));
Expand All @@ -848,7 +869,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
assertEq(token.ownerOf(_tokenId), minters[0].minter);
}

function testRevert_MinterCannotMintPastReserve(address _minter, uint256 _reservedUntilTokenId, uint256 _tokenId) public {
function testRevert_MinterCannotMintPastReserve(
address _minter,
uint256 _reservedUntilTokenId,
uint256 _tokenId
) public {
deployAltMock(_reservedUntilTokenId);

vm.assume(_minter != founder && _minter != address(0) && _minter != address(auction));
Expand Down Expand Up @@ -890,7 +915,11 @@ contract TokenTest is NounsBuilderTest, TokenTypesV1 {
}
}

function test_BatchMintCannotMintReserves(address _minter, uint256 _reservedUntilTokenId, uint256 _amount) public {
function test_BatchMintCannotMintReserves(
address _minter,
uint256 _reservedUntilTokenId,
uint256 _amount
) public {
deployAltMock(_reservedUntilTokenId);

vm.assume(_minter != founder && _minter != address(0) && _minter != address(auction));
Expand Down
19 changes: 16 additions & 3 deletions test/utils/NounsBuilderTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ contract NounsBuilderTest is Test {
setFounderParams(wallets, percents, vestingEnds);
}

function setFounderParams(address[] memory _wallets, uint256[] memory _percents, uint256[] memory _vestingEnds) internal virtual {
function setFounderParams(
address[] memory _wallets,
uint256[] memory _percents,
uint256[] memory _vestingEnds
) internal virtual {
uint256 numFounders = _wallets.length;

require(numFounders == _percents.length && numFounders == _vestingEnds.length);
Expand Down Expand Up @@ -178,7 +182,12 @@ contract NounsBuilderTest is Test {
setAuctionParams(0.01 ether, 10 minutes, address(0), 0);
}

function setAuctionParams(uint256 _reservePrice, uint256 _duration, address _founderRewardRecipent, uint16 _founderRewardBps) internal virtual {
function setAuctionParams(
uint256 _reservePrice,
uint256 _duration,
address _founderRewardRecipent,
uint16 _founderRewardBps
) internal virtual {
auctionParams = IManager.AuctionParams({
reservePrice: _reservePrice,
duration: _duration,
Expand Down Expand Up @@ -247,7 +256,11 @@ contract NounsBuilderTest is Test {
setMockMetadata();
}

function deployWithCustomFounders(address[] memory _wallets, uint256[] memory _percents, uint256[] memory _vestExpirys) internal virtual {
function deployWithCustomFounders(
address[] memory _wallets,
uint256[] memory _percents,
uint256[] memory _vestExpirys
) internal virtual {
setFounderParams(_wallets, _percents, _vestExpirys);

setMockTokenParams();
Expand Down

0 comments on commit d42da20

Please sign in to comment.