diff --git a/solidity/test/mocks/MockArbitrator.sol b/solidity/test/mocks/MockArbitrator.sol index 828e1dda..3a64de98 100644 --- a/solidity/test/mocks/MockArbitrator.sol +++ b/solidity/test/mocks/MockArbitrator.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; + import {IArbitrator, IOracle} from '../../interfaces/IArbitrator.sol'; contract MockArbitrator is IArbitrator { @@ -13,7 +15,8 @@ contract MockArbitrator is IArbitrator { function resolve( IOracle.Request memory, IOracle.Response memory, - IOracle.Dispute memory + IOracle.Dispute memory, + IAccessController.AccessControl memory AccessControl ) external pure returns (bytes memory _result) { _result = new bytes(0); } diff --git a/solidity/test/mocks/MockAtomicArbitrator.sol b/solidity/test/mocks/MockAtomicArbitrator.sol index 94323d0e..368df66a 100644 --- a/solidity/test/mocks/MockAtomicArbitrator.sol +++ b/solidity/test/mocks/MockAtomicArbitrator.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.19; import {IArbitrator} from '../../interfaces/IArbitrator.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; contract MockAtomicArbitrator is IArbitrator { @@ -15,11 +16,12 @@ contract MockAtomicArbitrator is IArbitrator { function resolve( IOracle.Request memory _request, IOracle.Response memory _response, - IOracle.Dispute memory _dispute + IOracle.Dispute memory _dispute, + IAccessController.AccessControl memory _accessControl ) external returns (bytes memory _result) { _result = new bytes(0); answer = IOracle.DisputeStatus.Won; - oracle.resolveDispute(_request, _response, _dispute); + oracle.resolveDispute(_request, _response, _dispute, _accessControl); } function getAnswer(bytes32 /* _dispute */ ) external view returns (IOracle.DisputeStatus _answer) { diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 219cb8f6..4a70c7a3 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -980,7 +980,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { function test_revertIfInvalidDisputeBody() public { // Check: does it revert if the dispute body is invalid? vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(address(this))); } /** @@ -991,7 +991,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the dispute is not escalated yet? vm.expectRevert(IBondEscalationModule.BondEscalationModule_InvalidDispute.selector); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1017,7 +1017,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the bond escalation is over? vm.expectRevert(IBondEscalationModule.BondEscalationModule_BondEscalationOver.selector); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1046,7 +1046,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the maximum number of escalations is reached? vm.expectRevert(IBondEscalationModule.BondEscalationModule_MaxNumberOfEscalationsReached.selector); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1074,7 +1074,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if trying to pledge in a dispute that is already surpassed? vm.expectRevert(IBondEscalationModule.BondEscalationModule_CanOnlySurpassByOnePledge.selector); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1107,7 +1107,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if trying to tie outside of the tying buffer? vm.expectRevert(IBondEscalationModule.BondEscalationModule_CannotBreakTieDuringTyingBuffer.selector); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1148,7 +1148,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { vm.expectEmit(true, true, true, true, address(bondEscalationModule)); emit PledgedForDispute(_disputeId, address(this), _params.bondSize); - bondEscalationModule.pledgeForDispute(mockRequest, _dispute); + bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_requestId).amountOfPledgesForDispute; // Check: is the number of pledges for the dispute properly updated? @@ -1167,7 +1167,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { function test_revertIfInvalidDisputeBody() public { // Check: does it revert if the dispute body is invalid? vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(address(this))); } /** @@ -1178,7 +1178,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the dispute is not escalated yet? vm.expectRevert(IBondEscalationModule.BondEscalationModule_InvalidDispute.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1204,7 +1204,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the bond escalation is over? vm.expectRevert(IBondEscalationModule.BondEscalationModule_BondEscalationOver.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1234,7 +1234,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the maximum number of escalations is reached? vm.expectRevert(IBondEscalationModule.BondEscalationModule_MaxNumberOfEscalationsReached.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1265,7 +1265,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if trying to pledge in a dispute that is already surpassed? vm.expectRevert(IBondEscalationModule.BondEscalationModule_CanOnlySurpassByOnePledge.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1298,7 +1298,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if trying to tie outside of the tying buffer? vm.expectRevert(IBondEscalationModule.BondEscalationModule_CannotBreakTieDuringTyingBuffer.selector); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); } /** @@ -1337,7 +1337,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { vm.expectEmit(true, true, true, true, address(bondEscalationModule)); emit PledgedAgainstDispute(_disputeId, address(this), _params.bondSize); - bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute); + bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_requestId).amountOfPledgesAgainstDispute; // Check: is the number of pledges for the dispute properly updated? @@ -1489,7 +1489,16 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, _response, _dispute, IOracle.DisputeStatus.Won)), + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + _response, + _dispute, + IOracle.DisputeStatus.Won, + _createAccessControl(address(bondEscalationModule)) + ) + ), abi.encode(true) ); @@ -1534,7 +1543,16 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, _response, _dispute, IOracle.DisputeStatus.Lost)), + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + _response, + _dispute, + IOracle.DisputeStatus.Lost, + _createAccessControl(address(bondEscalationModule)) + ) + ), abi.encode(true) ); diff --git a/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol b/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol index 7d071dfd..691b87d7 100644 --- a/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol +++ b/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol @@ -159,9 +159,19 @@ contract CircuitResolverModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Won, + _createAccessControl(address(circuitResolverModule)) + ) ), + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, + // ), abi.encode(true) ); @@ -201,8 +211,18 @@ contract CircuitResolverModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + // ), + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Won, + _createAccessControl(address(circuitResolverModule)) + ) ), abi.encode(true) ); @@ -254,9 +274,19 @@ contract CircuitResolverModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Lost, + _createAccessControl(address(circuitResolverModule)) + ) ), + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost + // ), abi.encode(true) ); @@ -377,7 +407,9 @@ contract CircuitResolverModule_Unit_OnDisputeStatusChange is BaseTest { // Mock and expect the call to the oracle, proposing the correct response _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.proposeResponse, (mockRequest, _newResponse)), + abi.encodeCall( + IOracle.proposeResponse, (mockRequest, _newResponse, _createAccessControl(address(circuitResolverModule))) + ), abi.encode(_getId(_newResponse)) ); diff --git a/solidity/test/unit/modules/dispute/RootVerificationModule.t.sol b/solidity/test/unit/modules/dispute/RootVerificationModule.t.sol index bf74e3bb..40bd66af 100644 --- a/solidity/test/unit/modules/dispute/RootVerificationModule.t.sol +++ b/solidity/test/unit/modules/dispute/RootVerificationModule.t.sol @@ -207,8 +207,18 @@ contract RootVerificationModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + // ), + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Won, + _createAccessControl(address(rootVerificationModule)) + ) ), abi.encode(true) ); @@ -250,9 +260,19 @@ contract RootVerificationModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Won, + _createAccessControl(address(rootVerificationModule)) + ) ), + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won + // ), abi.encode(true) ); @@ -305,9 +325,19 @@ contract RootVerificationModule_Unit_DisputeResponse is BaseTest { // Mock and expect the call the oracle, updating the dispute's status _mockAndExpect( address(oracle), - abi.encodeWithSelector( - oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost + abi.encodeCall( + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.Lost, + _createAccessControl(address(rootVerificationModule)) + ) ), + // abi.encodeWithSelector( + // oracle.updateDisputeStatus.selector, mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost + // ), abi.encode(true) ); diff --git a/solidity/test/unit/modules/resolution/ArbitratorModule.t.sol b/solidity/test/unit/modules/resolution/ArbitratorModule.t.sol index ef030191..79ba3296 100644 --- a/solidity/test/unit/modules/resolution/ArbitratorModule.t.sol +++ b/solidity/test/unit/modules/resolution/ArbitratorModule.t.sol @@ -116,7 +116,13 @@ contract ArbitratorModule_Unit_StartResolution is BaseTest { // Mock and expect the callback to the arbitrator _mockAndExpect( - _arbitrator, abi.encodeCall(arbitrator.resolve, (mockRequest, mockResponse, mockDispute)), abi.encode(bytes('')) + _arbitrator, + abi.encodeCall( + arbitrator.resolve, + // review + (mockRequest, mockResponse, mockDispute, _createAccessControl(address(arbitratorModule))) + ), + abi.encode(bytes('')) ); vm.prank(address(oracle)); @@ -135,7 +141,13 @@ contract ArbitratorModule_Unit_StartResolution is BaseTest { // Mock and expect the callback to the arbitrator _mockAndExpect( - _arbitrator, abi.encodeCall(arbitrator.resolve, (mockRequest, mockResponse, mockDispute)), abi.encode(bytes('')) + _arbitrator, + abi.encodeCall( + arbitrator.resolve, + // review + (mockRequest, mockResponse, mockDispute, _createAccessControl(address(arbitratorModule))) + ), + abi.encode(bytes('')) ); // Check: is the event emitted? @@ -196,7 +208,10 @@ contract ArbitratorModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(oracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, _arbitratorStatus)), + abi.encodeCall( + oracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, _arbitratorStatus, _createAccessControl(address(arbitratorModule))) + ), abi.encode() ); @@ -251,7 +266,10 @@ contract ArbitratorModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(oracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, _arbitratorStatus)), + abi.encodeCall( + oracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, _arbitratorStatus, _createAccessControl(address(arbitratorModule))) + ), abi.encode() ); diff --git a/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol b/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol index 3362cac0..93cd7cb4 100644 --- a/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/BondEscalationResolutionModule.t.sol @@ -272,7 +272,8 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + vm.prank(pledgerFor); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); // 1. BondEscalationResolutionModule_NotEscalated (_requestId,, _disputeId) = _setResolutionModuleData(_params); @@ -282,7 +283,8 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the dispute is not escalated? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_NotEscalated.selector); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + vm.prank(pledgerFor); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); // 2. BondEscalationResolutionModule_PledgingPhaseOver _params.timeUntilDeadline = block.timestamp - 1; @@ -293,7 +295,8 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if the pledging phase is over? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_PledgingPhaseOver.selector); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + vm.prank(pledgerFor); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); // 3. BondEscalationResolutionModule_MustBeResolved _params.timeUntilDeadline = 10_000; @@ -313,7 +316,8 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if inequality timer has passed? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_MustBeResolved.selector); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + vm.prank(pledgerFor); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); // 4. BondEscalationResolutionModule_AgainstTurnToEqualize vm.warp(block.timestamp - _params.timeToBreakInequality - 1); // Not past the deadline anymore @@ -331,7 +335,7 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { // Check: does it revert if status == AgainstTurnToEqualize? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_AgainstTurnToEqualize.selector); vm.prank(pledgerFor); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); } function test_earlyReturnIfThresholdNotSurpassed( @@ -373,7 +377,7 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { emit PledgedForDispute(pledgerFor, _requestId, _disputeId, _pledgeAmount); vm.startPrank(pledgerFor); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); (,, uint256 _realPledgesFor,) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status,) = module.inequalityData(_disputeId); @@ -421,7 +425,7 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { emit PledgedForDispute(pledgerFor, _requestId, _disputeId, _pledgeAmount); vm.startPrank(pledgerFor); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); (,, uint256 _realPledgesFor,) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -472,7 +476,7 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { emit PledgedForDispute(pledgerFor, _requestId, _disputeId, _pledgeAmount); vm.prank(pledgerFor); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); (,, uint256 _realPledgesFor,) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -520,7 +524,7 @@ contract BondEscalationResolutionModule_Unit_PledgeForDispute is BaseTest { emit PledgedForDispute(pledgerFor, _requestId, _disputeId, _pledgeAmount); vm.prank(pledgerFor); - module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeForDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerFor)); (,, uint256 _realPledgesFor,) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -558,7 +562,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(address(this))); // 1. BondEscalationResolutionModule_NotEscalated (_requestId,, _disputeId) = _setResolutionModuleData(_params); @@ -568,7 +572,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the dispute is not escalated? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_NotEscalated.selector); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(address(this))); // 2. BondEscalationResolutionModule_PledgingPhaseOver _params.timeUntilDeadline = block.timestamp - 1; @@ -578,7 +582,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if the pledging phase is over? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_PledgingPhaseOver.selector); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(address(this))); // 3. BondEscalationResolutionModule_MustBeResolved _params.timeUntilDeadline = 10_000; @@ -599,7 +603,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if inequality timer has passed? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_MustBeResolved.selector); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(address(this))); // 4. BondEscalationResolutionModule_AgainstTurnToEqualize vm.warp(block.timestamp - _params.timeToBreakInequality - 1); // Not past the deadline anymore @@ -617,7 +621,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { // Check: does it revert if status == AgainstTurnToEqualize? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_ForTurnToEqualize.selector); vm.prank(pledgerAgainst); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerAgainst)); } function test_earlyReturnIfThresholdNotSurpassed(uint256 _pledgeAmount) public { @@ -658,7 +662,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { emit PledgedAgainstDispute(pledgerAgainst, _requestId, _disputeId, _pledgeAmount); vm.startPrank(pledgerAgainst); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerAgainst)); (,,, uint256 _realPledgesAgainst) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status,) = module.inequalityData(_disputeId); @@ -706,7 +710,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { emit PledgedAgainstDispute(pledgerAgainst, _requestId, _disputeId, _pledgeAmount); vm.startPrank(pledgerAgainst); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerAgainst)); (,,, uint256 _realPledgesAgainst) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -757,7 +761,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { emit PledgedAgainstDispute(pledgerAgainst, _requestId, _disputeId, _pledgeAmount); vm.prank(pledgerAgainst); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerAgainst)); (,,, uint256 _realPledgesAgainst) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -805,7 +809,7 @@ contract BondEscalationResolutionModule_Unit_PledgeAgainstDispute is BaseTest { emit PledgedAgainstDispute(pledgerAgainst, _requestId, _disputeId, _pledgeAmount); vm.prank(pledgerAgainst); - module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount); + module.pledgeAgainstDispute(mockRequest, mockDispute, _pledgeAmount, _createAccessControl(pledgerAgainst)); (,, uint256 _realPledgesAgainst,) = module.escalations(_disputeId); (IBondEscalationResolutionModule.InequalityStatus _status, uint256 _timer) = module.inequalityData(_disputeId); @@ -895,7 +899,14 @@ contract BondEscalationResolutionModule_Unit_ResolveDispute is BaseTest { _mockAndExpect( address(oracle), abi.encodeCall( - IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.NoResolution) + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.NoResolution, + _createAccessControl(address(module)) + ) ), abi.encode() ); @@ -925,7 +936,14 @@ contract BondEscalationResolutionModule_Unit_ResolveDispute is BaseTest { _mockAndExpect( address(oracle), abi.encodeCall( - IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.NoResolution) + IOracle.updateDisputeStatus, + ( + mockRequest, + mockResponse, + mockDispute, + IOracle.DisputeStatus.NoResolution, + _createAccessControl(address(module)) + ) ), abi.encode() ); @@ -966,7 +984,10 @@ contract BondEscalationResolutionModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won)), + abi.encodeCall( + IOracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Won, _createAccessControl(address(module))) + ), abi.encode() ); @@ -1002,7 +1023,10 @@ contract BondEscalationResolutionModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost)), + abi.encodeCall( + IOracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, IOracle.DisputeStatus.Lost, _createAccessControl(address(module))) + ), abi.encode() ); @@ -1032,7 +1056,7 @@ contract BondEscalationResolutionModule_Unit_ClaimPledge is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.claimPledge(mockRequest, mockDispute); + module.claimPledge(mockRequest, mockDispute, _createAccessControl(address(this))); (,, bytes32 _disputeId) = _setResolutionModuleData(_params); @@ -1046,7 +1070,7 @@ contract BondEscalationResolutionModule_Unit_ClaimPledge is BaseTest { // Check: does it revert if trying to claim a pledge of a not resolved escalation? vm.expectRevert(IBondEscalationResolutionModule.BondEscalationResolutionModule_NotResolved.selector); - module.claimPledge(mockRequest, mockDispute); + module.claimPledge(mockRequest, mockDispute, _createAccessControl(address(this))); } function test_disputerWon( @@ -1097,7 +1121,7 @@ contract BondEscalationResolutionModule_Unit_ClaimPledge is BaseTest { ); vm.prank(_randomPledger); - module.claimPledge(mockRequest, mockDispute); + module.claimPledge(mockRequest, mockDispute, _createAccessControl(_randomPledger)); // Check: are the pledges for dispute for the dispute and pledger set to 0? assertEq(module.pledgesForDispute(_disputeId, _randomPledger), 0); @@ -1151,7 +1175,7 @@ contract BondEscalationResolutionModule_Unit_ClaimPledge is BaseTest { ); vm.prank(_randomPledger); - module.claimPledge(mockRequest, mockDispute); + module.claimPledge(mockRequest, mockDispute, _createAccessControl(_randomPledger)); // Check: is the pledges against dispute for this dispute and pledger set to 0? assertEq(module.pledgesAgainstDispute(_disputeId, _randomPledger), 0); @@ -1217,7 +1241,7 @@ contract BondEscalationResolutionModule_Unit_ClaimPledge is BaseTest { ); vm.prank(_randomPledger); - module.claimPledge(mockRequest, mockDispute); + module.claimPledge(mockRequest, mockDispute, _createAccessControl(address(_randomPledger))); // Check: is the pledges against dispute for this dispute and pledger set to 0? assertEq(module.pledgesAgainstDispute(_disputeId, _randomPledger), 0); diff --git a/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol b/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol index 1ea5bba7..53305658 100644 --- a/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol @@ -199,7 +199,7 @@ contract ERC20ResolutionModule_Unit_CastVote is BaseTest { emit VoteCast(_voter, _disputeId, _amountOfVotes); vm.prank(_voter); - module.castVote(mockRequest, _dispute, _amountOfVotes); + module.castVote(mockRequest, _dispute, _amountOfVotes, _createAccessControl(_voter)); (, uint256 _totalVotes) = module.escalations(_disputeId); // Check: totalVotes is updated? @@ -216,7 +216,7 @@ contract ERC20ResolutionModule_Unit_CastVote is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.castVote(mockRequest, mockDispute, _numberOfVotes); + module.castVote(mockRequest, mockDispute, _numberOfVotes, _createAccessControl(address(this))); } /** @@ -233,7 +233,7 @@ contract ERC20ResolutionModule_Unit_CastVote is BaseTest { // Check: reverts if called with `_disputeId` of a non-escalated dispute? vm.expectRevert(IERC20ResolutionModule.ERC20ResolutionModule_DisputeNotEscalated.selector); - module.castVote(mockRequest, _dispute, _numberOfVotes); + module.castVote(mockRequest, _dispute, _numberOfVotes, _createAccessControl(address(this))); } /** @@ -265,7 +265,7 @@ contract ERC20ResolutionModule_Unit_CastVote is BaseTest { // Check: reverts if dispute is already resolved? vm.expectRevert(IERC20ResolutionModule.ERC20ResolutionModule_AlreadyResolved.selector); - module.castVote(mockRequest, _dispute, _amountOfVotes); + module.castVote(mockRequest, _dispute, _amountOfVotes, _createAccessControl(address(this))); } /** @@ -303,7 +303,7 @@ contract ERC20ResolutionModule_Unit_CastVote is BaseTest { // Check: reverts if trying to cast vote after voting phase? vm.expectRevert(IERC20ResolutionModule.ERC20ResolutionModule_VotingPhaseOver.selector); - module.castVote(mockRequest, _dispute, _numberOfVotes); + module.castVote(mockRequest, _dispute, _numberOfVotes, _createAccessControl(address(this))); } } @@ -358,7 +358,10 @@ contract ERC20ResolutionModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, _newStatus)), + abi.encodeCall( + IOracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, _newStatus, _createAccessControl(address(module))) + ), abi.encode() ); @@ -417,7 +420,7 @@ contract ERC20ResolutionModule_Unit_ClaimVote is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.claimVote(mockRequest, mockDispute); + module.claimVote(mockRequest, mockDispute, _createAccessControl(address(this))); } /** @@ -447,7 +450,7 @@ contract ERC20ResolutionModule_Unit_ClaimVote is BaseTest { // Claim the refund vm.prank(_voter); - module.claimVote(mockRequest, _dispute); + module.claimVote(mockRequest, _dispute, _createAccessControl(address(_voter))); } /** @@ -488,7 +491,7 @@ contract ERC20ResolutionModule_Unit_ClaimVote is BaseTest { // Claim the refund vm.prank(_voter); - module.claimVote(mockRequest, _dispute); + module.claimVote(mockRequest, _dispute, _createAccessControl(address(_voter))); } } diff --git a/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol b/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol index 09cb0530..7a54b3a8 100644 --- a/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol @@ -93,7 +93,7 @@ contract BaseTest is Test, Helpers { abi.encodeCall(IOracle.disputeStatus, (_disputeId)), abi.encode(IOracle.DisputeStatus.Escalated) ); - module.commitVote(_request, _dispute, _commitment); + module.commitVote(_request, _dispute, _commitment, _createAccessControl()); vm.warp(140_001); @@ -102,7 +102,7 @@ contract BaseTest is Test, Helpers { abi.encodeCall(IERC20.transferFrom, (vm.addr(_i), address(module), _amountOfVotes)), abi.encode() ); - module.revealVote(_request, _dispute, _amountOfVotes, bytes32(_i)); + module.revealVote(_request, _dispute, _amountOfVotes, bytes32(_i), _createAccessControl()); vm.stopPrank(); _totalVotesCast += _amountOfVotes; unchecked { @@ -205,21 +205,21 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if no commitment is given? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_EmptyCommitment.selector); - module.commitVote(mockRequest, mockDispute, bytes32('')); + module.commitVote(mockRequest, mockDispute, bytes32(''), _createAccessControl()); // Compute and store commitment - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl()); // Check: reverts if empty commitment is given? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_EmptyCommitment.selector); - module.commitVote(mockRequest, mockDispute, bytes32('')); + module.commitVote(mockRequest, mockDispute, bytes32(''), _createAccessControl()); // Check: is the commitment stored? IPrivateERC20ResolutionModule.VoterData memory _voterData = module.forTest_getVoterData(_disputeId, _voter); assertEq(_voterData.commitment, _commitment); bytes32 _newCommitment = module.computeCommitment(_disputeId, uint256(_salt), bytes32(_amountOfVotes)); - module.commitVote(mockRequest, mockDispute, _newCommitment); + module.commitVote(mockRequest, mockDispute, _newCommitment, _createAccessControl()); vm.stopPrank(); // Check: is voters data updated with new commitment? @@ -234,7 +234,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } /** @@ -251,7 +251,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if no dispute exists? vm.expectRevert(IValidator.Validator_InvalidDispute.selector); - module.commitVote(mockRequest, _dispute, _commitment); + module.commitVote(mockRequest, _dispute, _commitment, _createAccessControl(address(this))); } /** @@ -272,7 +272,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the dispute is already resolved? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_AlreadyResolved.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } /** @@ -295,7 +295,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the dispute is already resolved? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_AlreadyResolved.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } /** @@ -316,7 +316,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the dispute is already resolved? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_AlreadyResolved.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } /** @@ -337,7 +337,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the dispute is already resolved? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_AlreadyResolved.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } /** @@ -358,7 +358,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: reverts if dispute is not escalated? == no escalation data vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_DisputeNotEscalated.selector); - module.commitVote(mockRequest, _dispute, _commitment); + module.commitVote(mockRequest, _dispute, _commitment, _createAccessControl(address(this))); } /** @@ -398,7 +398,7 @@ contract PrivateERC20ResolutionModule_Unit_CommitVote is BaseTest { // Check: does it revert if the committing phase is over? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_CommittingPhaseOver.selector); - module.commitVote(mockRequest, mockDispute, _commitment); + module.commitVote(mockRequest, mockDispute, _commitment, _createAccessControl(address(this))); } } @@ -449,7 +449,7 @@ contract PrivateERC20ResolutionModule_Unit_RevealVote is BaseTest { emit VoteRevealed(_voter, _disputeId, _amountOfVotes); vm.prank(_voter); - module.revealVote(mockRequest, _dispute, _amountOfVotes, _salt); + module.revealVote(mockRequest, _dispute, _amountOfVotes, _salt, _createAccessControl(address(_voter))); (, uint256 _totalVotes) = module.escalations(_disputeId); // Check: is totalVotes updated? @@ -467,7 +467,7 @@ contract PrivateERC20ResolutionModule_Unit_RevealVote is BaseTest { // Check: does it revert if the dispute body is invalid? mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - module.revealVote(mockRequest, mockDispute, _numberOfVotes, _salt); + module.revealVote(mockRequest, mockDispute, _numberOfVotes, _salt, _createAccessControl(address(this))); } /** @@ -484,7 +484,7 @@ contract PrivateERC20ResolutionModule_Unit_RevealVote is BaseTest { // Check: does it revert if the dispute is not escalated? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_DisputeNotEscalated.selector); - module.revealVote(mockRequest, mockDispute, _numberOfVotes, _salt); + module.revealVote(mockRequest, mockDispute, _numberOfVotes, _salt, _createAccessControl(address(this))); } /** @@ -519,11 +519,11 @@ contract PrivateERC20ResolutionModule_Unit_RevealVote is BaseTest { if (_timestamp <= 140_000) { // Check: does it revert if trying to reveal during the committing phase? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_OnGoingCommittingPhase.selector); - module.revealVote(mockRequest, _dispute, _numberOfVotes, _salt); + module.revealVote(mockRequest, _dispute, _numberOfVotes, _salt, _createAccessControl(address(this))); } else { // Check: does it revert if trying to reveal after the revealing phase? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_RevealingPhaseOver.selector); - module.revealVote(mockRequest, _dispute, _numberOfVotes, _salt); + module.revealVote(mockRequest, _dispute, _numberOfVotes, _salt, _createAccessControl(address(this))); } } @@ -574,18 +574,18 @@ contract PrivateERC20ResolutionModule_Unit_RevealVote is BaseTest { // Check: does it revert if the commitment is not valid? (wrong salt) vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_WrongRevealData.selector); - module.revealVote(mockRequest, _dispute, _amountOfVotes, _wrongSalt); + module.revealVote(mockRequest, _dispute, _amountOfVotes, _wrongSalt, _createAccessControl()); // Check: does it revert if the commitment is not valid? (wrong amount of votes) vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_WrongRevealData.selector); - module.revealVote(mockRequest, _dispute, _wrongAmountOfVotes, _salt); + module.revealVote(mockRequest, _dispute, _wrongAmountOfVotes, _salt, _createAccessControl()); vm.stopPrank(); // Check: does it revert if the commitment is not valid? (wrong voter) vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_WrongRevealData.selector); vm.prank(_wrongVoter); - module.revealVote(mockRequest, _dispute, _amountOfVotes, _salt); + module.revealVote(mockRequest, _dispute, _amountOfVotes, _salt, _createAccessControl(_wrongVoter)); } } @@ -648,7 +648,10 @@ contract PrivateERC20ResolutionModule_Unit_ResolveDispute is BaseTest { // Mock and expect IOracle.updateDisputeStatus to be called _mockAndExpect( address(oracle), - abi.encodeCall(IOracle.updateDisputeStatus, (mockRequest, mockResponse, mockDispute, _newStatus)), + abi.encodeCall( + IOracle.updateDisputeStatus, + (mockRequest, mockResponse, mockDispute, _newStatus, _createAccessControl(address(module))) + ), abi.encode() ); @@ -701,6 +704,7 @@ contract PrivateERC20ResolutionModule_Unit_ResolveDispute is BaseTest { // Jump to timestamp vm.warp(_timestamp); + // fixme : refactor this test if (_timestamp <= 500_000) { // Check: does it revert if trying to resolve during the committing phase? vm.expectRevert(IPrivateERC20ResolutionModule.PrivateERC20ResolutionModule_OnGoingCommittingPhase.selector); diff --git a/solidity/test/unit/modules/response/BondedResponseModule.t.sol b/solidity/test/unit/modules/response/BondedResponseModule.t.sol index 5fb16cc0..ed64e1c1 100644 --- a/solidity/test/unit/modules/response/BondedResponseModule.t.sol +++ b/solidity/test/unit/modules/response/BondedResponseModule.t.sol @@ -513,7 +513,7 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest { emit UnutilizedResponseReleased(_requestId, _responseId); // Test: does it release the bond? - bondedResponseModule.releaseUnutilizedResponse(mockRequest, mockResponse); + bondedResponseModule.releaseUnutilizedResponse(mockRequest, mockResponse, _createAccessControl(address(this))); } /** @@ -546,7 +546,7 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest { // Check: reverts? vm.expectRevert(IBondedResponseModule.BondedResponseModule_InvalidReleaseParameters.selector); - bondedResponseModule.releaseUnutilizedResponse(mockRequest, _response); + bondedResponseModule.releaseUnutilizedResponse(mockRequest, _response, _createAccessControl(address(this))); } /** @@ -605,7 +605,10 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest { vm.expectRevert(IBondedResponseModule.BondedResponseModule_InvalidReleaseParameters.selector); } - bondedResponseModule.releaseUnutilizedResponse(mockRequest, _response); + // todo: use `_anyone` + address _notTheProposer = makeAddr('not-the-proposer'); + vm.prank(_notTheProposer); + bondedResponseModule.releaseUnutilizedResponse(mockRequest, _response, _createAccessControl(_notTheProposer)); } } } diff --git a/solidity/test/utils/Helpers.sol b/solidity/test/utils/Helpers.sol index 44462aba..e56478cc 100644 --- a/solidity/test/utils/Helpers.sol +++ b/solidity/test/utils/Helpers.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.19; import {TestConstants} from './TestConstants.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {DSTestPlus} from '@defi-wonderland/solidity-utils/solidity/test/DSTestPlus.sol'; @@ -12,6 +13,7 @@ contract Helpers is DSTestPlus, TestConstants { // Mock objects IOracle.Request public mockRequest = IOracle.Request({ + accessControlModule: address(0), requestModule: address(0), responseModule: address(0), disputeModule: address(0), @@ -25,6 +27,10 @@ contract Helpers is DSTestPlus, TestConstants { requester: address(this), nonce: 1 }); + + IAccessController.AccessControl public mockAccessControl = + IAccessController.AccessControl({user: address(0), data: bytes('')}); + bytes32 internal _mockRequestId = keccak256(abi.encode(mockRequest)); IOracle.Response public mockResponse = @@ -158,4 +164,12 @@ contract Helpers is DSTestPlus, TestConstants { function _expectEmit(address _contract) internal { vm.expectEmit(true, true, true, true, _contract); } + + function _createAccessControl() internal returns (IAccessController.AccessControl memory _accessControl) { + _accessControl = _createAccessControl(msg.sender); + } + + function _createAccessControl(address _user) internal returns (IAccessController.AccessControl memory _accessControl) { + _accessControl = IAccessController.AccessControl({user: _user, data: bytes('')}); + } }