From 6986feea53c873886ee1b77de42ad80968b1aaba Mon Sep 17 00:00:00 2001 From: Ashitaka <96790496+ashitakah@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:38:31 -0300 Subject: [PATCH] refactor: lint and remappings (#60) * feat: lint and remapping * fix: lint --- foundry.toml | 2 +- remappings.txt | 3 +- .../modules/dispute/BondEscalationModule.sol | 11 +- .../modules/dispute/BondedDisputeModule.sol | 9 +- .../modules/dispute/CircuitResolverModule.sol | 9 +- .../dispute/RootVerificationModule.sol | 9 +- .../modules/finality/CallbackModule.sol | 9 +- .../finality/MultipleCallbacksModule.sol | 9 +- .../request/ContractCallRequestModule.sol | 9 +- .../modules/request/HttpRequestModule.sol | 9 +- .../request/SparseMerkleTreeRequestModule.sol | 9 +- .../modules/resolution/ArbitratorModule.sol | 9 +- .../BondEscalationResolutionModule.sol | 12 +- .../resolution/ERC20ResolutionModule.sol | 9 +- .../PrivateERC20ResolutionModule.sol | 9 +- .../modules/response/BondedResponseModule.sol | 9 +- .../extensions/IBondEscalationAccounting.sol | 4 +- .../IBondEscalationResolutionModule.sol | 7 +- .../dispute/BondEscalationAccounting.t.sol | 7 +- .../dispute/BondEscalationModule.t.sol | 147 ++++++++++-------- .../BondEscalationResolutionModule.t.sol | 20 +-- solidity/test/utils/Helpers.sol | 7 +- 22 files changed, 196 insertions(+), 132 deletions(-) diff --git a/foundry.toml b/foundry.toml index 98f42687..59022016 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,7 +5,7 @@ bracket_spacing = false int_types = 'long' quote_style = 'single' number_underscore = 'thousands' -multiline_func_header = 'params_first' +multiline_func_header = 'params_first_multi' sort_imports = true [profile.default] diff --git a/remappings.txt b/remappings.txt index 609b06ae..e7c67f1f 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,3 +1,2 @@ ds-test/=node_modules/ds-test/src -forge-std/=node_modules/forge-std/src -solmate/=node_modules/solmate/src \ No newline at end of file +forge-std/=node_modules/forge-std/src \ No newline at end of file diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index b4917d60..e1cc5992 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol'; +import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol'; @@ -338,9 +338,12 @@ contract BondEscalationModule is Module, IBondEscalationModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && _params.bondSize != 0 && _params.bondEscalationDeadline != 0 && _params.maxNumberOfEscalations != 0 diff --git a/solidity/contracts/modules/dispute/BondedDisputeModule.sol b/solidity/contracts/modules/dispute/BondedDisputeModule.sol index 2f1a6700..527b3c07 100644 --- a/solidity/contracts/modules/dispute/BondedDisputeModule.sol +++ b/solidity/contracts/modules/dispute/BondedDisputeModule.sol @@ -104,9 +104,12 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && _params.bondSize != 0; diff --git a/solidity/contracts/modules/dispute/CircuitResolverModule.sol b/solidity/contracts/modules/dispute/CircuitResolverModule.sol index e7d0f391..bdd8e8f6 100644 --- a/solidity/contracts/modules/dispute/CircuitResolverModule.sol +++ b/solidity/contracts/modules/dispute/CircuitResolverModule.sol @@ -93,9 +93,12 @@ contract CircuitResolverModule is Module, ICircuitResolverModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external view override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + view + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && _params.bondSize != 0 && _targetHasBytecode(_params.verifier) && _params.callData.length != 0; diff --git a/solidity/contracts/modules/dispute/RootVerificationModule.sol b/solidity/contracts/modules/dispute/RootVerificationModule.sol index ae3dde97..dc05ae21 100644 --- a/solidity/contracts/modules/dispute/RootVerificationModule.sol +++ b/solidity/contracts/modules/dispute/RootVerificationModule.sol @@ -91,9 +91,12 @@ contract RootVerificationModule is Module, IRootVerificationModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && address(_params.treeVerifier) != address(0) && _params.bondSize != 0 && _params.treeData.length != 0 diff --git a/solidity/contracts/modules/finality/CallbackModule.sol b/solidity/contracts/modules/finality/CallbackModule.sol index 6e3e6403..0f0eb959 100644 --- a/solidity/contracts/modules/finality/CallbackModule.sol +++ b/solidity/contracts/modules/finality/CallbackModule.sol @@ -34,9 +34,12 @@ contract CallbackModule is Module, ICallbackModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external view override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + view + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = _params.data.length != 0 && _targetHasBytecode(_params.target); } diff --git a/solidity/contracts/modules/finality/MultipleCallbacksModule.sol b/solidity/contracts/modules/finality/MultipleCallbacksModule.sol index 2faa1071..75c29ae7 100644 --- a/solidity/contracts/modules/finality/MultipleCallbacksModule.sol +++ b/solidity/contracts/modules/finality/MultipleCallbacksModule.sol @@ -41,9 +41,12 @@ contract MultipleCallbacksModule is Module, IMultipleCallbacksModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external view override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + view + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = true; diff --git a/solidity/contracts/modules/request/ContractCallRequestModule.sol b/solidity/contracts/modules/request/ContractCallRequestModule.sol index f214419a..98e97667 100644 --- a/solidity/contracts/modules/request/ContractCallRequestModule.sol +++ b/solidity/contracts/modules/request/ContractCallRequestModule.sol @@ -60,9 +60,12 @@ contract ContractCallRequestModule is Module, IContractCallRequestModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0) && _params.target != address(0) && _params.paymentAmount != 0 && _params.functionSelector != bytes4(0); diff --git a/solidity/contracts/modules/request/HttpRequestModule.sol b/solidity/contracts/modules/request/HttpRequestModule.sol index 6f3cd9d2..8d26cd6a 100644 --- a/solidity/contracts/modules/request/HttpRequestModule.sol +++ b/solidity/contracts/modules/request/HttpRequestModule.sol @@ -60,9 +60,12 @@ contract HttpRequestModule is Module, IHttpRequestModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0) && _params.paymentAmount != 0 && bytes(_params.url).length != 0 && bytes(_params.body).length != 0; diff --git a/solidity/contracts/modules/request/SparseMerkleTreeRequestModule.sol b/solidity/contracts/modules/request/SparseMerkleTreeRequestModule.sol index de32c11e..bdaa8837 100644 --- a/solidity/contracts/modules/request/SparseMerkleTreeRequestModule.sol +++ b/solidity/contracts/modules/request/SparseMerkleTreeRequestModule.sol @@ -60,9 +60,12 @@ contract SparseMerkleTreeRequestModule is Module, ISparseMerkleTreeRequestModule } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0) && address(_params.treeVerifier) != address(0) && _params.paymentAmount != 0 && _params.treeData.length != 0 diff --git a/solidity/contracts/modules/resolution/ArbitratorModule.sol b/solidity/contracts/modules/resolution/ArbitratorModule.sol index 65772374..4dd8fe01 100644 --- a/solidity/contracts/modules/resolution/ArbitratorModule.sol +++ b/solidity/contracts/modules/resolution/ArbitratorModule.sol @@ -67,9 +67,12 @@ contract ArbitratorModule is Module, IArbitratorModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = _params.arbitrator != address(0); } diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index 6f5f3bdd..ca12c694 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -2,9 +2,10 @@ pragma solidity ^0.8.19; // solhint-disable-next-line no-unused-import + import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; -import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol'; +import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; @@ -339,9 +340,12 @@ contract BondEscalationResolutionModule is Module, IBondEscalationResolutionModu } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && _params.percentageDiff != 0 && _params.pledgeThreshold != 0 && _params.timeUntilDeadline != 0 diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index e623c3ac..b2bfad3f 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -131,9 +131,12 @@ contract ERC20ResolutionModule is Module, IERC20ResolutionModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.votingToken) != address(0) && _params.minVotesForQuorum != 0 && _params.timeUntilDeadline != 0; diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 74506a8e..f56dd714 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -158,9 +158,12 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.votingToken) != address(0) && _params.minVotesForQuorum != 0 && _params.committingTimeWindow != 0 && _params.revealingTimeWindow != 0; diff --git a/solidity/contracts/modules/response/BondedResponseModule.sol b/solidity/contracts/modules/response/BondedResponseModule.sol index a7d8d14f..635785c1 100644 --- a/solidity/contracts/modules/response/BondedResponseModule.sol +++ b/solidity/contracts/modules/response/BondedResponseModule.sol @@ -126,9 +126,12 @@ contract BondedResponseModule is Module, IBondedResponseModule { } /// @inheritdoc IModule - function validateParameters( - bytes calldata _encodedParameters - ) external pure override(Module, IModule) returns (bool _valid) { + function validateParameters(bytes calldata _encodedParameters) + external + pure + override(Module, IModule) + returns (bool _valid) + { RequestParameters memory _params = decodeRequestData(_encodedParameters); _valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0) && _params.bondSize != 0 && _params.disputeWindow != 0 && _params.deadline != 0; diff --git a/solidity/interfaces/extensions/IBondEscalationAccounting.sol b/solidity/interfaces/extensions/IBondEscalationAccounting.sol index d0714d2d..cf8f90ce 100644 --- a/solidity/interfaces/extensions/IBondEscalationAccounting.sol +++ b/solidity/interfaces/extensions/IBondEscalationAccounting.sol @@ -149,9 +149,7 @@ interface IBondEscalationAccounting is IAccountingExtension { * @return _amountPerPledger Amount of `_token` to be rewarded to each of the winning pledgers * @return _bondEscalationModule The address of the bond escalation module that was used */ - function escalationResults( - bytes32 _disputeId - ) + function escalationResults(bytes32 _disputeId) external returns (bytes32 _requestId, IERC20 _token, uint256 _amountPerPledger, IBondEscalationModule _bondEscalationModule); diff --git a/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol b/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol index a9c8e0b2..ea32729b 100644 --- a/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol +++ b/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol @@ -220,9 +220,10 @@ interface IBondEscalationResolutionModule is IResolutionModule { * @return _pledgesFor The amount of pledges in favor of the dispute. * @return _pledgesAgainst The amount of pledges against the dispute. */ - function escalations( - bytes32 _disputeId - ) external view returns (Resolution _resolution, uint128 _startTime, uint256 _pledgesFor, uint256 _pledgesAgainst); + function escalations(bytes32 _disputeId) + external + view + returns (Resolution _resolution, uint128 _startTime, uint256 _pledgesFor, uint256 _pledgesAgainst); /** * @notice Returns the inequality status and its last update time of a given dispute. diff --git a/solidity/test/unit/modules/dispute/BondEscalationAccounting.t.sol b/solidity/test/unit/modules/dispute/BondEscalationAccounting.t.sol index 4b9061dd..e4e4c139 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationAccounting.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationAccounting.t.sol @@ -82,9 +82,10 @@ contract BaseTest is Test, Helpers { bytes32 indexed _requestId, bytes32 indexed _disputeId, address indexed _pledger, IERC20 _token, uint256 _amount ); - function _createWinningPledgersArray( - uint256 _numWinningPledgers - ) internal returns (address[] memory _winningPledgers) { + function _createWinningPledgersArray(uint256 _numWinningPledgers) + internal + returns (address[] memory _winningPledgers) + { _winningPledgers = new address[](_numWinningPledgers); address _winningPledger; diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index fad1843a..ce72dd90 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -165,9 +165,10 @@ contract BondEscalationModule_Unit_ModuleData is BaseTest { /** * @notice Tests that decodeRequestData decodes the data correctly */ - function test_decodeRequestDataReturnTheCorrectData( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_decodeRequestDataReturnTheCorrectData(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { mockRequest.disputeModuleData = abi.encode(_params); IBondEscalationModule.RequestParameters memory _decodedParams = @@ -206,9 +207,10 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { * - The _requestId tied to the dispute tied to _disputeId must be valid (non-zero) * - The block.timestamp has to be <= bond escalation deadline */ - function test_revertEscalationDuringBondEscalation( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertEscalationDuringBondEscalation(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { // Set _bondEscalationDeadline to be the current timestamp to reach the second condition. _params.bondEscalationDeadline = block.timestamp; @@ -287,9 +289,10 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { * - The dispute has to have gone or be going through the bond escalation process * - The pledges must not be tied */ - function test_revertIfEscalatingDisputeIsNotTied( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfEscalatingDisputeIsNotTied(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { // Set a tying buffer to make the test more explicit _params.tyingBuffer = 1000; // Set bond escalation deadline to be the current timestamp. We will warp this. @@ -604,9 +607,10 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { /** * @notice Tests that onDisputeStatusChange pays the proposer if the disputer lost */ - function test_callPayIfNormalDisputeLost( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_callPayIfNormalDisputeLost(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.accountingExtension = IBondEscalationAccounting(makeAddr('BondEscalationAccounting')); mockRequest.disputeModuleData = abi.encode(_params); bytes32 _requestId = _getId(mockRequest); @@ -636,9 +640,10 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { /** * @notice Tests that onDisputeStatusChange pays the disputer if the disputer won */ - function test_callPayIfNormalDisputeWon( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_callPayIfNormalDisputeWon(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.accountingExtension = IBondEscalationAccounting(makeAddr('BondEscalationAccounting')); mockRequest.disputeModuleData = abi.encode(_params); bytes32 _requestId = _getId(mockRequest); @@ -674,9 +679,10 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { bondEscalationModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute); } - function test_emitsEvent( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_emitsEvent(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { IOracle.DisputeStatus _status = IOracle.DisputeStatus.Won; mockRequest.disputeModuleData = abi.encode(_params); @@ -719,9 +725,10 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { * @notice Tests that onDisputeStatusChange returns early if the dispute has gone through the bond * escalation mechanism but no one pledged */ - function test_earlyReturnIfBondEscalatedDisputeHashNoPledgers( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_earlyReturnIfBondEscalatedDisputeHashNoPledgers(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { mockRequest.disputeModuleData = abi.encode(_params); bytes32 _requestId = _getId(mockRequest); @@ -947,9 +954,10 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { /** * @notice Tests that pledgeForDispute reverts if someone tries to pledge after the tying buffer. */ - function test_revertIfTimestampBeyondTyingBuffer( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfTimestampBeyondTyingBuffer(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1; _params.maxNumberOfEscalations = 1; _params.bondEscalationDeadline = block.timestamp; @@ -972,9 +980,10 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { /** * @notice Tests that pledgeForDispute reverts if the maximum number of escalations has been reached. */ - function test_revertIfMaxNumberOfEscalationsReached( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfMaxNumberOfEscalationsReached(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1; _params.maxNumberOfEscalations = 2; _params.bondEscalationDeadline = block.timestamp - 1; @@ -1029,9 +1038,10 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { * @notice Tests that pledgeForDispute reverts if the timestamp is within the tying buffer and someone attempts * to pledge when the funds are tied, effectively breaking the tie */ - function test_revertIfAttemptToBreakTieDuringTyingBuffer( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfAttemptToBreakTieDuringTyingBuffer(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1; _params.maxNumberOfEscalations = 3; _params.bondEscalationDeadline = block.timestamp - 1; @@ -1057,9 +1067,10 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { /** * @notice Tests that pledgeForDispute is called successfully */ - function test_successfulCall( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_successfulCall(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1000; _params.maxNumberOfEscalations = 3; _params.bondEscalationDeadline = block.timestamp - 1; @@ -1127,9 +1138,10 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { /** * @notice Tests that pledgeAgainstDispute reverts if someone tries to pledge after the tying buffer. */ - function test_revertIfTimestampBeyondTyingBuffer( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfTimestampBeyondTyingBuffer(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1; _params.maxNumberOfEscalations = 1; _params.bondEscalationDeadline = block.timestamp; @@ -1153,9 +1165,10 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { /** * @notice Tests that pledgeAgainstDispute reverts if the maximum number of escalations has been reached. */ - function test_revertIfMaxNumberOfEscalationsReached( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfMaxNumberOfEscalationsReached(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1; _params.maxNumberOfEscalations = 2; _params.bondEscalationDeadline = block.timestamp - 1; @@ -1183,9 +1196,10 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { * @notice Tests that pledgeAgainstDispute reverts if someone tries to pledge in favor of the dispute when there are * more pledges against of the dispute than in favor of it */ - function test_revertIfThereIsMorePledgedAgainstDisputeThanFor( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfThereIsMorePledgedAgainstDisputeThanFor(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.tyingBuffer = bound(_params.tyingBuffer, 0, type(uint128).max); _params.bondSize = 1; _params.maxNumberOfEscalations = 3; @@ -1213,9 +1227,10 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { * @notice Tests that pledgeAgainstDispute reverts if the timestamp is within the tying buffer and someone attempts * to pledge when the funds are tied, effectively breaking the tie */ - function test_revertIfAttemptToBreakTieDuringTyingBuffer( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfAttemptToBreakTieDuringTyingBuffer(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { // Set mock request parameters _params.bondSize = 1; _params.maxNumberOfEscalations = 3; @@ -1242,9 +1257,10 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { /** * @notice Tests that pledgeAgainstDispute is called successfully */ - function test_successfulCall( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_successfulCall(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1000; _params.maxNumberOfEscalations = 3; _params.bondEscalationDeadline = block.timestamp - 1; @@ -1312,9 +1328,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { * @notice Tests that settleBondEscalation reverts if someone tries to settle the escalation before the tying buffer * has elapsed. */ - function test_revertIfTimestampLessThanEndOfTyingBuffer( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfTimestampLessThanEndOfTyingBuffer(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.tyingBuffer = bound(_params.tyingBuffer, 0, type(uint128).max); _params.bondEscalationDeadline = block.timestamp; mockRequest.disputeModuleData = abi.encode(_params); @@ -1330,9 +1347,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { * @notice Tests that settleBondEscalation reverts if someone tries to settle a bond-escalated dispute that * is not active. */ - function test_revertIfStatusOfBondEscalationIsNotActive( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfStatusOfBondEscalationIsNotActive(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondEscalationDeadline = block.timestamp; _params.tyingBuffer = 1000; mockRequest.disputeModuleData = abi.encode(_params); @@ -1353,9 +1371,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { * @notice Tests that settleBondEscalation reverts if someone tries to settle a bond-escalated dispute that * has the same number of pledgers. */ - function test_revertIfSameNumberOfPledgers( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_revertIfSameNumberOfPledgers(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondEscalationDeadline = block.timestamp; _params.tyingBuffer = 1000; mockRequest.disputeModuleData = abi.encode(_params); @@ -1382,9 +1401,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { /** * @notice Tests that settleBondEscalation is called successfully. */ - function test_successfulCallDisputerWon( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_successfulCallDisputerWon(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1000; _params.bondEscalationDeadline = block.timestamp; _params.tyingBuffer = 1000; @@ -1425,9 +1445,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { /** * @notice Tests that settleBondEscalation is called successfully. */ - function test_successfulCallDisputerLost( - IBondEscalationModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_successfulCallDisputerLost(IBondEscalationModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { _params.bondSize = 1000; _params.bondEscalationDeadline = block.timestamp; _params.tyingBuffer = 1000; diff --git a/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol b/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol index 163bbe66..3362cac0 100644 --- a/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol @@ -7,7 +7,7 @@ import {Helpers} from '../../../utils/Helpers.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; -import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol'; +import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; @@ -149,9 +149,10 @@ contract BaseTest is Test, Helpers { return (_pledgers, _pledgedAmounts); } - function _setResolutionModuleData( - IBondEscalationResolutionModule.RequestParameters memory _params - ) internal returns (bytes32 _requestId, bytes32 _responseId, bytes32 _disputeId) { + function _setResolutionModuleData(IBondEscalationResolutionModule.RequestParameters memory _params) + internal + returns (bytes32 _requestId, bytes32 _responseId, bytes32 _disputeId) + { mockRequest.resolutionModuleData = abi.encode(_params); _requestId = _getId(mockRequest); @@ -165,9 +166,7 @@ contract BaseTest is Test, Helpers { vm.mockCall(address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_disputeId)), abi.encode(block.timestamp)); } - function _getRequestResponseDispute( - IBondEscalationResolutionModule.RequestParameters memory _params - ) + function _getRequestResponseDispute(IBondEscalationResolutionModule.RequestParameters memory _params) internal view returns (IOracle.Request memory _request, IOracle.Response memory _response, IOracle.Dispute memory _dispute) @@ -837,9 +836,10 @@ contract BondEscalationResolutionModule_Unit_ResolveDispute is BaseTest { the disputer. */ - function test_resolveDisputeReverts( - IBondEscalationResolutionModule.RequestParameters memory _params - ) public assumeFuzzable(address(_params.accountingExtension)) { + function test_resolveDisputeReverts(IBondEscalationResolutionModule.RequestParameters memory _params) + public + assumeFuzzable(address(_params.accountingExtension)) + { // 1. BondEscalationResolutionModule_AlreadyResolved (bytes32 _requestId, bytes32 _responseId, bytes32 _disputeId) = _setResolutionModuleData(_params); diff --git a/solidity/test/utils/Helpers.sol b/solidity/test/utils/Helpers.sol index 0e12e549..6bfc6591 100644 --- a/solidity/test/utils/Helpers.sol +++ b/solidity/test/utils/Helpers.sol @@ -64,9 +64,10 @@ contract Helpers is DSTestPlus, TestConstants { }); } - function _getResponseAndDispute( - IOracle _oracle - ) internal returns (IOracle.Response memory _response, IOracle.Dispute memory _dispute) { + function _getResponseAndDispute(IOracle _oracle) + internal + returns (IOracle.Response memory _response, IOracle.Dispute memory _dispute) + { // Compute proper IDs _response = _getResponse(mockRequest, proposer); _dispute = _getDispute(mockRequest, _response);