From 6695a655be290cc7ff702930bc79bf5382e239bf Mon Sep 17 00:00:00 2001 From: 0xtekgrinder <0xtekgrinder@protonmail.com> Date: Mon, 18 Dec 2023 01:40:58 -0500 Subject: [PATCH] style: prettier contracts --- test/invariant/BasicInvariants.t.sol | 12 ++++---- .../invariant/MainnetGovernorInvariants.t.sol | 24 +++++++-------- test/invariant/actors/BadVoter.t.sol | 25 ++++++++++------ test/invariant/actors/BaseActor.t.sol | 10 +++---- test/invariant/actors/Proposer.t.sol | 30 ++++++++++++------- test/invariant/actors/Voter.t.sol | 25 ++++++++++------ test/invariant/stores/ProposalStore.sol | 29 +++++++++++------- 7 files changed, 93 insertions(+), 62 deletions(-) diff --git a/test/invariant/BasicInvariants.t.sol b/test/invariant/BasicInvariants.t.sol index d2cd729..86f97a3 100644 --- a/test/invariant/BasicInvariants.t.sol +++ b/test/invariant/BasicInvariants.t.sol @@ -2,15 +2,15 @@ pragma solidity ^0.8.19; -import {IERC20} from "oz/token/ERC20/IERC20.sol"; -import {IERC20Metadata} from "oz/token/ERC20/extensions/IERC20Metadata.sol"; +import { IERC20 } from "oz/token/ERC20/IERC20.sol"; +import { IERC20Metadata } from "oz/token/ERC20/extensions/IERC20Metadata.sol"; import "oz/utils/Strings.sol"; -import {Voter} from "./actors/Voter.t.sol"; -import {Fixture, AngleGovernor} from "../Fixture.t.sol"; -import {ProposalStore} from "./stores/ProposalStore.sol"; +import { Voter } from "./actors/Voter.t.sol"; +import { Fixture, AngleGovernor } from "../Fixture.t.sol"; +import { ProposalStore } from "./stores/ProposalStore.sol"; //solhint-disable -import {console} from "forge-std/console.sol"; +import { console } from "forge-std/console.sol"; contract BasicInvariants is Fixture { uint256 internal constant _NUM_VOTER = 10; diff --git a/test/invariant/MainnetGovernorInvariants.t.sol b/test/invariant/MainnetGovernorInvariants.t.sol index 85f4e0c..07c3cfe 100644 --- a/test/invariant/MainnetGovernorInvariants.t.sol +++ b/test/invariant/MainnetGovernorInvariants.t.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.19; -import {IERC20} from "oz/token/ERC20/IERC20.sol"; -import {IERC20Metadata} from "oz/token/ERC20/extensions/IERC20Metadata.sol"; +import { IERC20 } from "oz/token/ERC20/IERC20.sol"; +import { IERC20Metadata } from "oz/token/ERC20/extensions/IERC20Metadata.sol"; import "oz/utils/Strings.sol"; -import {Voter} from "./actors/Voter.t.sol"; -import {Proposer} from "./actors/Proposer.t.sol"; -import {BadVoter} from "./actors/BadVoter.t.sol"; -import {Fixture, AngleGovernor} from "../Fixture.t.sol"; -import {ProposalStore} from "./stores/ProposalStore.sol"; +import { Voter } from "./actors/Voter.t.sol"; +import { Proposer } from "./actors/Proposer.t.sol"; +import { BadVoter } from "./actors/BadVoter.t.sol"; +import { Fixture, AngleGovernor } from "../Fixture.t.sol"; +import { ProposalStore } from "./stores/ProposalStore.sol"; //solhint-disable -import {console} from "forge-std/console.sol"; +import { console } from "forge-std/console.sol"; contract MainnetGovernorInvariants is Fixture { uint256 internal constant _NUM_VOTER = 10; @@ -33,7 +33,7 @@ contract MainnetGovernorInvariants is Fixture { _badVoterHandler = new BadVoter(angleGovernor, ANGLE, _NUM_VOTER, _proposalStore); // Label newly created addresses - vm.label({account: address(_proposalStore), newLabel: "ProposalStore"}); + vm.label({ account: address(_proposalStore), newLabel: "ProposalStore" }); for (uint256 i; i < _NUM_VOTER; i++) { vm.label(_voterHandler.actors(i), string.concat("Voter ", Strings.toString(i))); _setupDealAndLockANGLE(_voterHandler.actors(i), 100000000e18, 4 * 365 days); @@ -54,7 +54,7 @@ contract MainnetGovernorInvariants is Fixture { { bytes4[] memory selectors = new bytes4[](1); selectors[0] = Voter.vote.selector; - targetSelector(FuzzSelector({addr: address(_voterHandler), selectors: selectors})); + targetSelector(FuzzSelector({ addr: address(_voterHandler), selectors: selectors })); } { bytes4[] memory selectors = new bytes4[](4); @@ -62,12 +62,12 @@ contract MainnetGovernorInvariants is Fixture { selectors[1] = Proposer.execute.selector; selectors[2] = Proposer.skipVotingDelay.selector; selectors[3] = Proposer.shortCircuit.selector; - targetSelector(FuzzSelector({addr: address(_proposerHandler), selectors: selectors})); + targetSelector(FuzzSelector({ addr: address(_proposerHandler), selectors: selectors })); } { bytes4[] memory selectors = new bytes4[](1); selectors[0] = BadVoter.vote.selector; - targetSelector(FuzzSelector({addr: address(_badVoterHandler), selectors: selectors})); + targetSelector(FuzzSelector({ addr: address(_badVoterHandler), selectors: selectors })); } } diff --git a/test/invariant/actors/BadVoter.t.sol b/test/invariant/actors/BadVoter.t.sol index 976452d..8e17464 100644 --- a/test/invariant/actors/BadVoter.t.sol +++ b/test/invariant/actors/BadVoter.t.sol @@ -1,18 +1,21 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.19; -import {BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage} from "./BaseActor.t.sol"; -import {console} from "forge-std/console.sol"; -import {ProposalStore, Proposal} from "../stores/ProposalStore.sol"; -import {IGovernor} from "oz/governance/IGovernor.sol"; +import { BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage } from "./BaseActor.t.sol"; +import { console } from "forge-std/console.sol"; +import { ProposalStore, Proposal } from "../stores/ProposalStore.sol"; +import { IGovernor } from "oz/governance/IGovernor.sol"; contract BadVoter is BaseActor { AngleGovernor internal _angleGovernor; ProposalStore public proposalStore; - constructor(AngleGovernor angleGovernor, IERC20 _agToken, uint256 nbrVoter, ProposalStore _proposalStore) - BaseActor(nbrVoter, "BadVoter", _agToken) - { + constructor( + AngleGovernor angleGovernor, + IERC20 _agToken, + uint256 nbrVoter, + ProposalStore _proposalStore + ) BaseActor(nbrVoter, "BadVoter", _agToken) { _angleGovernor = angleGovernor; proposalStore = _proposalStore; } @@ -24,8 +27,12 @@ contract BadVoter is BaseActor { Proposal[] memory proposals = proposalStore.getProposals(); for (uint256 i; i < proposals.length; i++) { Proposal memory proposal = proposals[i]; - uint256 proposalHash = - _angleGovernor.hashProposal(proposal.target, proposal.value, proposal.data, proposal.description); + uint256 proposalHash = _angleGovernor.hashProposal( + proposal.target, + proposal.value, + proposal.data, + proposal.description + ); if (proposalHash != proposalId || proposalStore.doesOldProposalExists(proposalHash)) { return; } diff --git a/test/invariant/actors/BaseActor.t.sol b/test/invariant/actors/BaseActor.t.sol index e530c9b..a3237c9 100644 --- a/test/invariant/actors/BaseActor.t.sol +++ b/test/invariant/actors/BaseActor.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.19; -import {IERC20} from "oz/token/ERC20/IERC20.sol"; -import {IERC20Metadata} from "oz/token/ERC20/extensions/IERC20Metadata.sol"; -import {Test, stdMath, StdStorage, stdStorage} from "forge-std/Test.sol"; -import {IVotes} from "oz/governance/utils/IVotes.sol"; -import {AngleGovernor} from "contracts/AngleGovernor.sol"; +import { IERC20 } from "oz/token/ERC20/IERC20.sol"; +import { IERC20Metadata } from "oz/token/ERC20/extensions/IERC20Metadata.sol"; +import { Test, stdMath, StdStorage, stdStorage } from "forge-std/Test.sol"; +import { IVotes } from "oz/governance/utils/IVotes.sol"; +import { AngleGovernor } from "contracts/AngleGovernor.sol"; import "contracts/utils/Errors.sol"; struct TestStorage { diff --git a/test/invariant/actors/Proposer.t.sol b/test/invariant/actors/Proposer.t.sol index 3b118c0..f79d8c6 100644 --- a/test/invariant/actors/Proposer.t.sol +++ b/test/invariant/actors/Proposer.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.19; -import {BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage} from "./BaseActor.t.sol"; -import {console} from "forge-std/console.sol"; -import {IGovernor} from "oz/governance/IGovernor.sol"; -import {ProposalStore, Proposal} from "../stores/ProposalStore.sol"; -import {IERC5805} from "oz/interfaces/IERC5805.sol"; +import { BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage } from "./BaseActor.t.sol"; +import { console } from "forge-std/console.sol"; +import { IGovernor } from "oz/governance/IGovernor.sol"; +import { ProposalStore, Proposal } from "../stores/ProposalStore.sol"; +import { IERC5805 } from "oz/interfaces/IERC5805.sol"; contract Proposer is BaseActor { AngleGovernor internal _angleGovernor; @@ -55,8 +55,12 @@ contract Proposer is BaseActor { return; } Proposal memory proposal = proposalStore.getRandomProposal(proposalId); - uint256 proposalHash = - _angleGovernor.hashProposal(proposal.target, proposal.value, proposal.data, proposal.description); + uint256 proposalHash = _angleGovernor.hashProposal( + proposal.target, + proposal.value, + proposal.data, + proposal.description + ); IGovernor.ProposalState currentState = _angleGovernor.state(proposalHash); if (currentState != IGovernor.ProposalState.Active) { return; @@ -81,8 +85,12 @@ contract Proposer is BaseActor { return; } Proposal memory proposal = proposalStore.getRandomProposal(proposalId); - uint256 proposalHash = - _angleGovernor.hashProposal(proposal.target, proposal.value, proposal.data, proposal.description); + uint256 proposalHash = _angleGovernor.hashProposal( + proposal.target, + proposal.value, + proposal.data, + proposal.description + ); uint256 proposalSnapshot = _angleGovernor.proposalSnapshot(proposalHash); vm.warp(_angleGovernor.proposalDeadline(proposalHash) + 1); vm.roll(_angleGovernor.$snapshotTimestampToSnapshotBlockNumber(proposalSnapshot) + 1); @@ -93,8 +101,8 @@ contract Proposer is BaseActor { IGovernor.GovernorUnexpectedProposalState.selector, proposalHash, currentState, - bytes32(1 << uint8(IGovernor.ProposalState.Succeeded)) - | bytes32(1 << uint8(IGovernor.ProposalState.Queued)) + bytes32(1 << uint8(IGovernor.ProposalState.Succeeded)) | + bytes32(1 << uint8(IGovernor.ProposalState.Queued)) ) ); } diff --git a/test/invariant/actors/Voter.t.sol b/test/invariant/actors/Voter.t.sol index 8b2c5a1..53e0ead 100644 --- a/test/invariant/actors/Voter.t.sol +++ b/test/invariant/actors/Voter.t.sol @@ -1,18 +1,21 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.19; -import {BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage} from "./BaseActor.t.sol"; -import {console} from "forge-std/console.sol"; -import {ProposalStore, Proposal} from "../stores/ProposalStore.sol"; -import {IGovernor} from "oz/governance/IGovernor.sol"; +import { BaseActor, IERC20, IERC20Metadata, AngleGovernor, TestStorage } from "./BaseActor.t.sol"; +import { console } from "forge-std/console.sol"; +import { ProposalStore, Proposal } from "../stores/ProposalStore.sol"; +import { IGovernor } from "oz/governance/IGovernor.sol"; contract Voter is BaseActor { AngleGovernor internal _angleGovernor; ProposalStore public proposalStore; - constructor(AngleGovernor angleGovernor, IERC20 _agToken, uint256 nbrVoter, ProposalStore _proposalStore) - BaseActor(nbrVoter, "Voter", _agToken) - { + constructor( + AngleGovernor angleGovernor, + IERC20 _agToken, + uint256 nbrVoter, + ProposalStore _proposalStore + ) BaseActor(nbrVoter, "Voter", _agToken) { _angleGovernor = angleGovernor; proposalStore = _proposalStore; } @@ -22,8 +25,12 @@ contract Voter is BaseActor { return; } Proposal memory proposal = proposalStore.getRandomProposal(proposalSeed); - uint256 proposalHash = - _angleGovernor.hashProposal(proposal.target, proposal.value, proposal.data, proposal.description); + uint256 proposalHash = _angleGovernor.hashProposal( + proposal.target, + proposal.value, + proposal.data, + proposal.description + ); IGovernor.ProposalState currentState = _angleGovernor.state(proposalHash); if (currentState != IGovernor.ProposalState.Active) { vm.expectRevert( diff --git a/test/invariant/stores/ProposalStore.sol b/test/invariant/stores/ProposalStore.sol index 43fec32..9cff46c 100644 --- a/test/invariant/stores/ProposalStore.sol +++ b/test/invariant/stores/ProposalStore.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.19 <0.9.0; -import {StdUtils} from "forge-std/StdUtils.sol"; +import { StdUtils } from "forge-std/StdUtils.sol"; struct Proposal { address[] target; @@ -18,16 +18,22 @@ contract ProposalStore is StdUtils { constructor() {} - function addProposal(address[] memory target, uint256[] memory value, bytes[] memory data, bytes32 description) - external - { - proposals.push(Proposal({target: target, value: value, data: data, description: description})); + function addProposal( + address[] memory target, + uint256[] memory value, + bytes[] memory data, + bytes32 description + ) external { + proposals.push(Proposal({ target: target, value: value, data: data, description: description })); } - function addOldProposal(address[] memory target, uint256[] memory value, bytes[] memory data, bytes32 description) - external - { - oldProposals.push(Proposal({target: target, value: value, data: data, description: description})); + function addOldProposal( + address[] memory target, + uint256[] memory value, + bytes[] memory data, + bytes32 description + ) external { + oldProposals.push(Proposal({ target: target, value: value, data: data, description: description })); } function removeProposal(uint256 proposalHash) external { @@ -62,7 +68,10 @@ contract ProposalStore is StdUtils { uint256 proposalId = uint256( keccak256( abi.encode( - oldProposals[i].target, oldProposals[i].value, oldProposals[i].data, oldProposals[i].description + oldProposals[i].target, + oldProposals[i].value, + oldProposals[i].data, + oldProposals[i].description ) ) );