From ed39f02e1c9e82cef9060fb8eb65fa2db1f0bc87 Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 23 Oct 2024 16:13:03 -0400 Subject: [PATCH] test: update integration tests --- solidity/test/integration/Arbitration.t.sol | 12 +-- .../test/integration/BondEscalation.t.sol | 77 +++++++++++-------- .../test/integration/CallbackModule.t.sol | 2 +- .../integration/ContractCallRequest.t.sol | 2 +- .../test/integration/EscalateDispute.t.sol | 20 +++-- solidity/test/integration/HttpRequest.t.sol | 2 +- solidity/test/integration/IntegrationBase.sol | 7 +- .../integration/MultipleCallbacksModule.t.sol | 2 +- .../test/integration/ResponseDispute.t.sol | 14 ++-- .../test/integration/ResponseProposal.t.sol | 16 ++-- .../test/integration/RootVerification.t.sol | 10 +-- 11 files changed, 92 insertions(+), 72 deletions(-) diff --git a/solidity/test/integration/Arbitration.t.sol b/solidity/test/integration/Arbitration.t.sol index d0732b69..9a838ee6 100644 --- a/solidity/test/integration/Arbitration.t.sol +++ b/solidity/test/integration/Arbitration.t.sol @@ -25,14 +25,14 @@ contract Integration_Arbitration is IntegrationBase { // First step: escalating the dispute vm.prank(disputer); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status active after starting the resolution? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Active)); // Second step: resolving the dispute vm.prank(disputer); - oracle.resolveDispute(mockRequest, mockResponse, mockDispute); + oracle.resolveDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status resolved after calling resolve? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Resolved)); @@ -58,7 +58,7 @@ contract Integration_Arbitration is IntegrationBase { // First step: escalating the dispute vm.prank(disputer); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status resolved after calling resolve? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Resolved)); @@ -83,7 +83,7 @@ contract Integration_Arbitration is IntegrationBase { // First step: escalating the dispute vm.prank(disputer); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status active after starting the resolution? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Active)); @@ -97,7 +97,7 @@ contract Integration_Arbitration is IntegrationBase { // Second step: resolving the dispute vm.prank(disputer); - oracle.resolveDispute(mockRequest, mockResponse, mockDispute); + oracle.resolveDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status resolved after calling resolve? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Resolved)); @@ -130,7 +130,7 @@ contract Integration_Arbitration is IntegrationBase { // First step: escalating and resolving the dispute vm.prank(disputer); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: is the dispute status resolved after calling escalate? assertEq(uint256(_arbitratorModule.getStatus(_disputeId)), uint256(IArbitratorModule.ArbitrationStatus.Resolved)); diff --git a/solidity/test/integration/BondEscalation.t.sol b/solidity/test/integration/BondEscalation.t.sol index f68c5d55..d95c8912 100644 --- a/solidity/test/integration/BondEscalation.t.sol +++ b/solidity/test/integration/BondEscalation.t.sol @@ -101,29 +101,29 @@ contract Integration_BondEscalation is IntegrationBase { // Proposer proposes a response _deposit(_bondEscalationAccounting, proposer, usdc, _expectedBondSize); vm.prank(proposer); - _responseId = oracle.proposeResponse(mockRequest, mockResponse); + _responseId = oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl(proposer)); // Disputer disputes the response _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } function test_proposerWins() public { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doubles down _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(disputer)); // Step 3: Proposer doubles down _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 4: Disputer runs out of capital // Step 5: External parties see that Disputer's dispute was wrong so they don't join to escalate @@ -173,17 +173,17 @@ contract Integration_BondEscalation is IntegrationBase { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doubles down _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(disputer)); // Step 3: Another party joins the dispute _deposit(_bondEscalationAccounting, _secondDisputer, usdc, _pledgeSize); vm.prank(_secondDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_secondDisputer)); // Step 4: Proposer runs out of capital and doesn't pledge anymore // External parties see that Proposer's proposal was wrong so they don't join to escalate @@ -225,27 +225,27 @@ contract Integration_BondEscalation is IntegrationBase { IOracle.Response({proposer: _secondProposer, requestId: _requestId, response: abi.encode('second response')}); _deposit(_bondEscalationAccounting, _secondProposer, usdc, _pledgeSize); vm.prank(_secondProposer); - _responseId = oracle.proposeResponse(mockRequest, _secondResponse); + _responseId = oracle.proposeResponse(mockRequest, _secondResponse, _createAccessControl(_secondProposer)); // Step 8: Disputer disputes Another proposer's answer // _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); IOracle.Dispute memory _secondDispute = IOracle.Dispute({disputer: disputer, responseId: _responseId, requestId: _requestId, proposer: _secondProposer}); vm.prank(disputer); - _disputeId = oracle.disputeResponse(mockRequest, _secondResponse, _secondDispute); + _disputeId = oracle.disputeResponse(mockRequest, _secondResponse, _secondDispute, _createAccessControl(disputer)); // Step 9: Shouldn't be able to pledge for or against the dispute due to the bond escalation deadline being over _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.expectRevert(IBondEscalationModule.BondEscalationModule_InvalidDispute.selector); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, _secondDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, _secondDispute, _createAccessControl(disputer)); // Step 10: Because Another proposer's answer is disputed, a third party can propose a new answer IOracle.Response memory _thirdResponse = IOracle.Response({proposer: _thirdProposer, requestId: _requestId, response: abi.encode('third response')}); _deposit(_bondEscalationAccounting, _thirdProposer, usdc, _expectedBondSize); vm.prank(_thirdProposer); - _responseId = oracle.proposeResponse(mockRequest, _thirdResponse); + _responseId = oracle.proposeResponse(mockRequest, _thirdResponse, _createAccessControl(_thirdProposer)); // Step 11: It goes undisputed for three days, therefore it's deemed correct and final vm.warp(block.timestamp + _expectedDeadline + 1); @@ -285,7 +285,7 @@ contract Integration_BondEscalation is IntegrationBase { // So Another proposer gets paid Disputer's bond vm.warp(block.timestamp + _expectedDeadline + 2 days); _mockArbitrator.setAnswer(IOracle.DisputeStatus.Lost); - oracle.resolveDispute(mockRequest, _secondResponse, _secondDispute); + oracle.resolveDispute(mockRequest, _secondResponse, _secondDispute, mockAccessControl); // Test: The requester still has nothing assertEq(_bondEscalationAccounting.balanceOf(requester, usdc), 0, 'Mismatch: Requester balance'); @@ -326,17 +326,17 @@ contract Integration_BondEscalation is IntegrationBase { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doubles down _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(disputer)); // Step 3: Proposer doubles down _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 4: Disputer runs out of capital // Step 5: The tying buffer kicks in @@ -345,21 +345,24 @@ contract Integration_BondEscalation is IntegrationBase { // Step 6: An external party sees that Proposer's response is incorrect, so they bond the required WETH _deposit(_bondEscalationAccounting, _secondDisputer, usdc, _pledgeSize); vm.prank(_secondDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_secondDisputer)); // Step 7: They go into the dispute resolution module - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + // review: we could use a global address `_anyone` + address _escalator = makeAddr('escalator'); + vm.prank(_escalator); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_escalator)); // Step 8: At this point, new answers can be proposed IOracle.Response memory _secondResponse = IOracle.Response({proposer: _secondProposer, requestId: _requestId, response: abi.encode('second response')}); _deposit(_bondEscalationAccounting, _secondProposer, usdc, _expectedBondSize); vm.prank(_secondProposer); - _responseId = oracle.proposeResponse(mockRequest, _secondResponse); + _responseId = oracle.proposeResponse(mockRequest, _secondResponse, _createAccessControl(_secondProposer)); // Step 9: After some time, the resolution module deems Disputer's dispute as correct _mineBlocks(100); - oracle.resolveDispute(mockRequest, mockResponse, mockDispute); + oracle.resolveDispute(mockRequest, mockResponse, mockDispute, mockAccessControl); IOracle.DisputeStatus _disputeStatus = oracle.disputeStatus(_disputeId); assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Won), 'Mismatch: Dispute status'); @@ -400,29 +403,35 @@ contract Integration_BondEscalation is IntegrationBase { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doesn't have money // Step 3: External actor sees that Proposer's answer was incorrect so they pledge in favor of the dispute _deposit(_bondEscalationAccounting, _secondDisputer, usdc, _pledgeSize); vm.prank(_secondDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_secondDisputer)); // Step 4: Proposer doubles down _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 5: External actor sees that Proposer's answer was incorrect so they pledge in favor of the dispute, tying the bond escalation address _thirdDisputer = makeAddr('thirdDisputer'); _deposit(_bondEscalationAccounting, _thirdDisputer, usdc, _pledgeSize); vm.prank(_thirdDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_thirdDisputer)); // Step 6: Proposer loses in resolution + address _escalator = makeAddr('escalator'); + address _resolver = makeAddr('resolver'); + vm.warp(block.timestamp + _bondEscalationDeadline + 1); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); - oracle.resolveDispute(mockRequest, mockResponse, mockDispute); + + vm.prank(_escalator); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_escalator)); + vm.prank(_resolver); + oracle.resolveDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_resolver)); IOracle.DisputeStatus _disputeStatus = oracle.disputeStatus(_disputeId); assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Won), 'Mismatch: Dispute status'); @@ -456,17 +465,17 @@ contract Integration_BondEscalation is IntegrationBase { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doubles down _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(disputer)); // Step 3: Proposer doubles down _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 4: Disputer runs out of capital // Step 5: The tying buffer kicks in @@ -475,7 +484,7 @@ contract Integration_BondEscalation is IntegrationBase { // Step 6: An external party sees that Proposer's response is incorrect, so they bond the required WETH _deposit(_bondEscalationAccounting, _secondDisputer, usdc, _pledgeSize); vm.prank(_secondDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_secondDisputer)); ////////////////// NEW MALICIOUS REQUEST //////////////////////// @@ -517,17 +526,17 @@ contract Integration_BondEscalation is IntegrationBase { // Step 1: Proposer pledges against the dispute _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 2: Disputer doubles down _deposit(_bondEscalationAccounting, disputer, usdc, _pledgeSize); vm.prank(disputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(disputer)); // Step 3: Proposer doubles down _deposit(_bondEscalationAccounting, proposer, usdc, _pledgeSize); vm.prank(proposer); - _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl(proposer)); // Step 4: Disputer runs out of capital // Step 5: The tying buffer kicks in @@ -536,7 +545,7 @@ contract Integration_BondEscalation is IntegrationBase { // Step 6: An external party sees that Proposer's response is incorrect, so they bond the required WETH _deposit(_bondEscalationAccounting, _secondDisputer, usdc, _pledgeSize); vm.prank(_secondDisputer); - _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute); + _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl(_secondDisputer)); ////////////////// NEW MALICIOUS REQUEST //////////////////////// diff --git a/solidity/test/integration/CallbackModule.t.sol b/solidity/test/integration/CallbackModule.t.sol index b285db6d..9e78a952 100644 --- a/solidity/test/integration/CallbackModule.t.sol +++ b/solidity/test/integration/CallbackModule.t.sol @@ -54,7 +54,7 @@ contract Integration_CallbackModule is IntegrationBase { vm.startPrank(proposer); _accountingExtension.approveModule(address(_responseModule)); mockResponse.response = abi.encode(proposer, _requestId, bytes('')); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl()); vm.stopPrank(); } } diff --git a/solidity/test/integration/ContractCallRequest.t.sol b/solidity/test/integration/ContractCallRequest.t.sol index bbaf8ee5..41de2a01 100644 --- a/solidity/test/integration/ContractCallRequest.t.sol +++ b/solidity/test/integration/ContractCallRequest.t.sol @@ -71,7 +71,7 @@ contract Integration_ContractCallRequest is IntegrationBase { vm.startPrank(proposer); _accountingExtension.approveModule(address(_responseModule)); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl()); vm.stopPrank(); // expect call to accounting to pay the proposer diff --git a/solidity/test/integration/EscalateDispute.t.sol b/solidity/test/integration/EscalateDispute.t.sol index 569d574b..a58e9fcf 100644 --- a/solidity/test/integration/EscalateDispute.t.sol +++ b/solidity/test/integration/EscalateDispute.t.sol @@ -59,21 +59,23 @@ contract Integration_EscalateDispute is IntegrationBase { _deposit(_bondEscalationAccounting, proposer, usdc, _expectedBondSize); vm.startPrank(proposer); _bondEscalationAccounting.approveModule(address(_responseModule)); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl(proposer)); vm.stopPrank(); _deposit(_bondEscalationAccounting, disputer, usdc, _expectedBondSize); vm.startPrank(disputer); _bondEscalationAccounting.approveModule(address(_bondEscalationModule)); - _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); vm.stopPrank(); } function test_escalateDispute() public { + address _escalator = makeAddr('escalator'); // Escalate dispute reverts if dispute does not exist mockDispute.requestId = bytes32(0); vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + vm.prank(_escalator); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_escalator)); mockDispute.requestId = _requestId; @@ -91,12 +93,17 @@ contract Integration_EscalateDispute is IntegrationBase { // The arbitrator module should call the arbitrator vm.expectCall( - address(_mockArbitrator), abi.encodeCall(MockArbitrator.resolve, (mockRequest, mockResponse, mockDispute)) + address(_mockArbitrator), + abi.encodeCall( + MockArbitrator.resolve, + (mockRequest, mockResponse, mockDispute, _createAccessControl(address(_arbitratorModule))) + ) ); // We escalate the dispute vm.warp(block.timestamp + _expectedDeadline + 1); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + vm.prank(_escalator); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_escalator)); // We check that the dispute was escalated IOracle.DisputeStatus _disputeStatus = oracle.disputeStatus(_disputeId); @@ -111,6 +118,7 @@ contract Integration_EscalateDispute is IntegrationBase { // Escalate dispute reverts if dispute is not active vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_CannotEscalate.selector, _disputeId)); - oracle.escalateDispute(mockRequest, mockResponse, mockDispute); + vm.prank(_escalator); + oracle.escalateDispute(mockRequest, mockResponse, mockDispute, _createAccessControl(_escalator)); } } diff --git a/solidity/test/integration/HttpRequest.t.sol b/solidity/test/integration/HttpRequest.t.sol index 894d3097..343ae7ef 100644 --- a/solidity/test/integration/HttpRequest.t.sol +++ b/solidity/test/integration/HttpRequest.t.sol @@ -59,7 +59,7 @@ contract Integration_HttpRequest is IntegrationBase { vm.startPrank(proposer); _accountingExtension.approveModule(address(_responseModule)); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); vm.stopPrank(); // expect call to accounting to pay the proposer diff --git a/solidity/test/integration/IntegrationBase.sol b/solidity/test/integration/IntegrationBase.sol index 056460de..f90f11ea 100644 --- a/solidity/test/integration/IntegrationBase.sol +++ b/solidity/test/integration/IntegrationBase.sol @@ -5,6 +5,9 @@ pragma solidity ^0.8.19; // solhint-disable-next-line no-console import {console} from 'forge-std/console.sol'; +import { + AccessController, IAccessController +} from '@defi-wonderland/prophet-core/solidity/contracts/AccessController.sol'; import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol'; import {IDisputeModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/dispute/IDisputeModule.sol'; import {IFinalityModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/finality/IFinalityModule.sol'; @@ -229,7 +232,7 @@ contract IntegrationBase is DSTestPlus, TestConstants, Helpers { function _proposeResponse() internal returns (bytes32 _responseId) { vm.startPrank(proposer); _accountingExtension.approveModule(address(_responseModule)); - _responseId = oracle.proposeResponse(mockRequest, mockResponse); + _responseId = oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl()); vm.stopPrank(); } @@ -240,7 +243,7 @@ contract IntegrationBase is DSTestPlus, TestConstants, Helpers { function _disputeResponse() internal returns (bytes32 _disputeId) { vm.startPrank(disputer); _accountingExtension.approveModule(address(_bondedDisputeModule)); - _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl()); vm.stopPrank(); } diff --git a/solidity/test/integration/MultipleCallbacksModule.t.sol b/solidity/test/integration/MultipleCallbacksModule.t.sol index aaf7d584..d57de765 100644 --- a/solidity/test/integration/MultipleCallbacksModule.t.sol +++ b/solidity/test/integration/MultipleCallbacksModule.t.sol @@ -66,7 +66,7 @@ contract Integration_MultipleCallbackModule is IntegrationBase { vm.startPrank(proposer); _accountingExtension.approveModule(address(_responseModule)); mockResponse.response = abi.encode(proposer, _requestId, bytes('')); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); vm.stopPrank(); } diff --git a/solidity/test/integration/ResponseDispute.t.sol b/solidity/test/integration/ResponseDispute.t.sol index bcea40bd..38f6681d 100644 --- a/solidity/test/integration/ResponseDispute.t.sol +++ b/solidity/test/integration/ResponseDispute.t.sol @@ -27,7 +27,7 @@ contract Integration_ResponseDispute is IntegrationBase { _deposit(_accountingExtension, disputer, usdc, _expectedBondSize); vm.prank(disputer); - bytes32 _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + bytes32 _disputeId = oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); // Check: the disputer is a participant now? assertTrue(oracle.isParticipant(_getId(mockRequest), disputer)); @@ -52,7 +52,7 @@ contract Integration_ResponseDispute is IntegrationBase { vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); vm.prank(disputer); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } /** @@ -66,7 +66,7 @@ contract Integration_ResponseDispute is IntegrationBase { vm.expectRevert(ValidatorLib.ValidatorLib_InvalidDisputeBody.selector); vm.prank(disputer); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } /** @@ -76,7 +76,7 @@ contract Integration_ResponseDispute is IntegrationBase { vm.expectRevert(IAccountingExtension.AccountingExtension_InsufficientFunds.selector); vm.prank(disputer); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } /** @@ -89,7 +89,7 @@ contract Integration_ResponseDispute is IntegrationBase { vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_AlreadyFinalized.selector, _getId(mockRequest))); vm.prank(disputer); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } /** @@ -99,10 +99,10 @@ contract Integration_ResponseDispute is IntegrationBase { _deposit(_accountingExtension, disputer, usdc, _expectedBondSize); vm.prank(disputer); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); vm.prank(disputer); vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_ResponseAlreadyDisputed.selector, _getId(mockResponse))); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); } } diff --git a/solidity/test/integration/ResponseProposal.t.sol b/solidity/test/integration/ResponseProposal.t.sol index ea0d0e10..a59d3772 100644 --- a/solidity/test/integration/ResponseProposal.t.sol +++ b/solidity/test/integration/ResponseProposal.t.sol @@ -31,7 +31,7 @@ contract Integration_ResponseProposal is IntegrationBase { mockResponse.response = _responseBytes; vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); // Check: the proposer is a participant now? assertTrue(oracle.isParticipant(_requestId, proposer)); @@ -59,7 +59,7 @@ contract Integration_ResponseProposal is IntegrationBase { vm.expectRevert(IBondedResponseModule.BondedResponseModule_TooLateToPropose.selector); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); } /** @@ -70,7 +70,7 @@ contract Integration_ResponseProposal is IntegrationBase { // First response vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); mockResponse.response = abi.encode('second response'); @@ -79,7 +79,7 @@ contract Integration_ResponseProposal is IntegrationBase { // Second response vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); } /** @@ -95,7 +95,7 @@ contract Integration_ResponseProposal is IntegrationBase { vm.expectRevert(ValidatorLib.ValidatorLib_InvalidResponseBody.selector); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); } /** @@ -128,7 +128,7 @@ contract Integration_ResponseProposal is IntegrationBase { vm.expectRevert(IAccountingExtension.AccountingExtension_InsufficientFunds.selector); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); } /** @@ -171,7 +171,7 @@ contract Integration_ResponseProposal is IntegrationBase { mockResponse.proposer = proposer; mockResponse.requestId = _requestIdApprovedDisputeModule; - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); vm.stopPrank(); uint256 _newProposerBalance = _accountingExtension.balanceOf(proposer, usdc); @@ -212,6 +212,6 @@ contract Integration_ResponseProposal is IntegrationBase { // Should revert as the dispute module is not approved vm.expectRevert(IAccountingExtension.AccountingExtension_NotAllowed.selector); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); } } diff --git a/solidity/test/integration/RootVerification.t.sol b/solidity/test/integration/RootVerification.t.sol index 52792fde..45e01aec 100644 --- a/solidity/test/integration/RootVerification.t.sol +++ b/solidity/test/integration/RootVerification.t.sol @@ -104,7 +104,7 @@ contract Integration_RootVerification is IntegrationBase { mockResponse.response = abi.encode(_correctRoot); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); vm.warp(block.timestamp + _expectedDeadline + _baseDisputeWindow); @@ -119,13 +119,13 @@ contract Integration_RootVerification is IntegrationBase { mockResponse.response = abi.encode(_invalidRoot); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl(proposer)); _resetMockIds(); vm.startPrank(disputer); _accountingExtension.approveModule(address(_responseModule)); _accountingExtension.approveModule(address(mockRequest.disputeModule)); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); vm.stopPrank(); uint256 _requesterBondedBalance = _accountingExtension.bondedAmountOf(requester, usdc, _requestId); @@ -150,12 +150,12 @@ contract Integration_RootVerification is IntegrationBase { mockResponse.response = abi.encode(_correctRoot); vm.prank(proposer); - oracle.proposeResponse(mockRequest, mockResponse); + oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl(proposer)); _resetMockIds(); vm.startPrank(disputer); _accountingExtension.approveModule(address(_responseModule)); - oracle.disputeResponse(mockRequest, mockResponse, mockDispute); + oracle.disputeResponse(mockRequest, mockResponse, mockDispute, _createAccessControl(disputer)); vm.stopPrank(); assertEq(_accountingExtension.bondedAmountOf(requester, usdc, _requestId), 0);