diff --git a/solidity/test/integration/AccountingExtension.t.sol b/solidity/test/integration/AccountingExtension.t.sol index 7e63988..f792df5 100644 --- a/solidity/test/integration/AccountingExtension.t.sol +++ b/solidity/test/integration/AccountingExtension.t.sol @@ -20,7 +20,10 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Depositing ERC20 should update the virtual balance and the token contract balance */ - function test_depositERC20(uint256 _initialBalance, uint256 _depositAmount) public { + function test_depositERC20() public { + // uint256 _initialBalance = 1 ether; + uint256 _depositAmount = 1 ether; + vm.assume(_initialBalance >= _depositAmount); _deposit(_accountingExtension, user, usdc, _depositAmount, _initialBalance); @@ -34,7 +37,10 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Depositing more than the user's balance should revert */ - function test_depositERC20_invalidAmount(uint256 _initialBalance, uint256 _invalidDepositAmount) public { + function test_depositERC20_invalidAmount() public { + uint256 _invalidDepositAmount = 1.1 ether; + // uint256 _initialBalance = 1 ether; + vm.assume(_invalidDepositAmount > _initialBalance); deal(address(usdc), user, _initialBalance); @@ -51,7 +57,11 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Withdrawing ERC20 should update the virtual balance and the token contract balance */ - function test_withdrawERC20(uint256 _initialBalance, uint256 _depositAmount, uint256 _withdrawAmount) public { + function test_withdrawERC20() public { + // uint256 _initialBalance = 1 ether; + uint256 _depositAmount = 1 ether; + uint256 _withdrawAmount = 0.5 ether; + vm.assume(_withdrawAmount <= _depositAmount); _deposit(_accountingExtension, user, usdc, _depositAmount, _initialBalance); @@ -68,11 +78,10 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Withdrawing more than the user's virtual balance should revert */ - function test_withdrawERC20_insufficientFunds( - uint256 _initialBalance, - uint256 _depositAmount, - uint256 _withdrawAmount - ) public { + function test_withdrawERC20_insufficientFunds() public { + // uint256 _initialBalance = 1 ether; + uint256 _depositAmount = 1 ether; + uint256 _withdrawAmount = 2 ether; vm.assume(_withdrawAmount > _depositAmount); _deposit(_accountingExtension, user, usdc, _depositAmount, _initialBalance); @@ -85,11 +94,10 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Withdrawing more WETH than was deposited by the user should revert */ - function test_withdrawETH_insufficientFunds( - uint256 _initialBalance, - uint256 _depositAmount, - uint256 _withdrawAmount - ) public { + function test_withdrawETH_insufficientFunds() public { + // uint256 _initialBalance = 1 ether; + uint256 _depositAmount = 1 ether; + uint256 _withdrawAmount = 2 ether; vm.assume(_withdrawAmount > _depositAmount); _deposit(_accountingExtension, user, weth, _depositAmount, _initialBalance); @@ -102,7 +110,9 @@ contract Integration_AccountingExtension is IntegrationBase { /** * @notice Withdrawing the bonded funds should revert */ - function test_withdrawBondedFunds(uint256 _initialBalance, uint256 _bondAmount) public { + function test_withdrawBondedFunds() public { + // uint256 _initialBalance = 1 ether; + uint256 _bondAmount = 1 ether; vm.assume(_bondAmount > 0); _deposit(_accountingExtension, user, usdc, _bondAmount, _initialBalance); diff --git a/solidity/test/integration/Finalization.t.sol b/solidity/test/integration/Finalization.t.sol index d8aa3f8..a096acf 100644 --- a/solidity/test/integration/Finalization.t.sol +++ b/solidity/test/integration/Finalization.t.sol @@ -21,7 +21,8 @@ contract Integration_Finalization is IntegrationBase { /** * @notice Finalization data is set and callback calls are made. */ - function test_makeAndIgnoreLowLevelCalls(bytes memory _calldata) public { + function test_makeAndIgnoreLowLevelCalls() public { + bytes memory _calldata = bytes('some-calldata'); _setFinalizationModule( address(_callbackModule), abi.encode(ICallbackModule.RequestParameters({target: address(_mockCallback), data: _calldata})) @@ -73,8 +74,9 @@ contract Integration_Finalization is IntegrationBase { /** * @notice Finalizing a request with a ongoing dispute reverts. */ - function test_revertFinalizeInDisputeWindow(uint256 _timestamp) public { - _timestamp = bound(_timestamp, block.timestamp, block.timestamp + _expectedDeadline - _baseDisputeWindow - 1); + function test_revertFinalizeInDisputeWindow() public { + uint256 _timestamp = block.timestamp + _expectedDeadline - _baseDisputeWindow - 1; + // _timestamp = bound(_timestamp, block.timestamp, block.timestamp + _expectedDeadline - _baseDisputeWindow - 1); _createRequest(); _proposeResponse(); @@ -90,7 +92,8 @@ contract Integration_Finalization is IntegrationBase { /** * @notice Finalizing a request without disputes triggers callback calls and executes without reverting. */ - function test_finalizeWithUndisputedResponse(bytes calldata _calldata) public { + function test_finalizeWithUndisputedResponse() public { + bytes memory _calldata = bytes('callback'); _setFinalizationModule( address(_callbackModule), abi.encode(ICallbackModule.RequestParameters({target: address(_mockCallback), data: _calldata})) @@ -114,7 +117,8 @@ contract Integration_Finalization is IntegrationBase { /** * @notice Finalizing a request before the disputing deadline reverts. */ - function test_revertFinalizeBeforeDeadline(bytes calldata _calldata) public { + function test_revertFinalizeBeforeDeadline() public { + bytes memory _calldata = bytes('wellformed-callback'); _setFinalizationModule( address(_callbackModule), abi.encode(ICallbackModule.RequestParameters({target: address(_mockCallback), data: _calldata})) @@ -133,7 +137,8 @@ contract Integration_Finalization is IntegrationBase { /** * @notice Finalizing a request without a response. */ - function test_finalizeWithoutResponse(bytes calldata _calldata) public { + function test_finalizeWithoutResponse() public { + bytes memory _calldata = bytes('wellformed-callback'); _setFinalizationModule( address(_callbackModule), abi.encode(ICallbackModule.RequestParameters({target: address(_mockCallback), data: _calldata})) diff --git a/solidity/test/integration/Payments.t.sol b/solidity/test/integration/Payments.t.sol index 1917890..f132f1f 100644 --- a/solidity/test/integration/Payments.t.sol +++ b/solidity/test/integration/Payments.t.sol @@ -4,7 +4,10 @@ pragma solidity ^0.8.19; import './IntegrationBase.sol'; contract Integration_Payments is IntegrationBase { - function test_releaseValidResponse_ERC20(uint256 _rewardSize, uint256 _bondSize) public { + function test_releaseValidResponse_ERC20() public { + uint256 _rewardSize = 0.1 ether; + uint256 _bondSize = 0.5 ether; + // Exception to avoid overflow when depositing. vm.assume(_rewardSize < type(uint256).max - _bondSize); @@ -44,7 +47,10 @@ contract Integration_Payments is IntegrationBase { assertEq(_accountingExtension.bondedAmountOf(proposer, usdc, _requestId), 0); } - function test_releaseValidResponse_ETH(uint256 _rewardSize, uint256 _bondSize) public { + function test_releaseValidResponse_ETH() public { + uint256 _rewardSize = 0.1 ether; + uint256 _bondSize = 0.5 ether; + // Exception to avoid overflow when depositing. vm.assume(_rewardSize < type(uint256).max - _bondSize); @@ -83,7 +89,10 @@ contract Integration_Payments is IntegrationBase { assertEq(_accountingExtension.bondedAmountOf(proposer, weth, _requestId), 0); } - function test_releaseSuccessfulDispute_ERC20(uint256 _rewardSize, uint256 _bondSize) public { + function test_releaseSuccessfulDispute_ERC20() public { + uint256 _rewardSize = 0.1 ether; + uint256 _bondSize = 0.5 ether; + // Exceptions to avoid overflow when depositing. vm.assume(_bondSize < type(uint256).max / 2); vm.assume(_rewardSize < type(uint256).max - _bondSize * 2); @@ -119,7 +128,10 @@ contract Integration_Payments is IntegrationBase { assertEq(_accountingExtension.bondedAmountOf(disputer, usdc, _requestId), 0); } - function test_releaseSuccessfulDispute_ETH(uint256 _rewardSize, uint256 _bondSize) public { + function test_releaseSuccessfulDispute_ETH() public { + uint256 _rewardSize = 0.1 ether; + uint256 _bondSize = 0.5 ether; + // Exceptions to avoid overflow when depositing. vm.assume(_bondSize < type(uint256).max / 2); vm.assume(_rewardSize < type(uint256).max - _bondSize * 2); diff --git a/solidity/test/integration/ResponseDispute.t.sol b/solidity/test/integration/ResponseDispute.t.sol index 30c0482..011e526 100644 --- a/solidity/test/integration/ResponseDispute.t.sol +++ b/solidity/test/integration/ResponseDispute.t.sol @@ -45,7 +45,8 @@ contract Integration_ResponseDispute is IntegrationBase { /** * @notice Disputing a non-existent response should revert */ - function test_disputeResponse_nonExistentResponse(bytes32 _nonExistentResponseId) public { + function test_disputeResponse_nonExistentResponse() public { + bytes32 _nonExistentResponseId = keccak256(abi.encode('bad')); vm.assume(_nonExistentResponseId != _getId(mockResponse)); mockDispute.responseId = _nonExistentResponseId; @@ -58,7 +59,9 @@ contract Integration_ResponseDispute is IntegrationBase { /** * @notice Sending an an invalid dispute in should revert */ - function test_disputeResponse_requestAndResponseMismatch(bytes32 _requestId) public { + function test_disputeResponse_requestAndResponseMismatch() public { + bytes32 _requestId = keccak256(abi.encode('bad')); + vm.assume(_requestId != _getId(mockRequest)); mockDispute.requestId = _requestId; diff --git a/solidity/test/integration/ResponseProposal.t.sol b/solidity/test/integration/ResponseProposal.t.sol index 62ecdde..a68c384 100644 --- a/solidity/test/integration/ResponseProposal.t.sol +++ b/solidity/test/integration/ResponseProposal.t.sol @@ -27,7 +27,8 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing a response updates the state of the oracle, including the list of participants and the response's creation time */ - function test_proposeResponse_validResponse(bytes memory _responseBytes) public { + function test_proposeResponse_validResponse() public { + bytes memory _responseBytes = abi.encode('valid-response'); mockResponse.response = _responseBytes; vm.prank(proposer); @@ -47,8 +48,11 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing a response after the deadline reverts */ - function test_proposeResponse_afterDeadline(uint256 _secondsAfter, bytes memory _responseBytes) public { - _secondsAfter = bound(_secondsAfter, 1, type(uint248).max); + function test_proposeResponse_afterDeadline() public { + uint256 _secondsAfter = 365 days; + bytes memory _responseBytes = abi.encode('any-response'); + + // _secondsAfter = bound(_secondsAfter, 1, type(uint248).max); // Warp to timestamp after deadline vm.warp(block.timestamp + _expectedDeadline + _secondsAfter); @@ -65,13 +69,17 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing a response to an already answered request reverts */ - function test_proposeResponse_alreadyResponded(bytes memory _responseBytes) public { + function test_proposeResponse_alreadyResponded() public { + bytes memory _responseBytes = abi.encode('valid-response'); + mockResponse.response = _responseBytes; // First response vm.prank(proposer); oracle.proposeResponse(mockRequest, mockResponse, _createAccessControl()); + // review: When this request is _answered_? + mockResponse.response = abi.encode('second response'); // Check: does revert if already responded? @@ -85,7 +93,10 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing a response with an invalid request id reverts */ - function test_proposeResponse_nonExistentRequest(bytes memory _responseBytes, bytes32 _nonExistentRequestId) public { + function test_proposeResponse_nonExistentRequest() public { + bytes memory _responseBytes = abi.encode('valid-response'); + bytes32 _nonExistentRequestId = keccak256(abi.encode('invalid-requestId')); + vm.assume(_nonExistentRequestId != _requestId); mockResponse.response = _responseBytes; @@ -101,7 +112,9 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing without enough funds bonded reverts */ - function test_proposeResponse_insufficientFunds(bytes memory _responseBytes) public { + function test_proposeResponse_insufficientFunds() public { + bytes memory _responseBytes = abi.encode('valid-response'); + // Using WETH as the bond token mockRequest.nonce += 1; mockRequest.responseModuleData = abi.encode( @@ -134,7 +147,9 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing from an approved dispute module */ - function test_proposeResponse_fromApprovedDisputeModule(bytes memory _responseBytes) public { + function test_proposeResponse_fromApprovedDisputeModule() public { + bytes memory _responseBytes = abi.encode('valid-response'); + address _otherRequester = makeAddr('otherRequester'); address _approvedDisputeModule = makeAddr('_approvedDisputeModule'); @@ -163,8 +178,8 @@ contract Integration_ResponseProposal is IntegrationBase { // Create a new request with another dispute module _accountingExtension.approveModule(mockRequest.requestModule); bytes32 _requestIdApprovedDisputeModule = oracle.createRequest(mockRequest, _ipfsHash, _createAccessControl()); - - changePrank(_approvedDisputeModule); + vm.stopPrank(); + vm.startPrank(_approvedDisputeModule); // Propose a response from the approved dispute module mockResponse.response = _responseBytes; @@ -184,7 +199,8 @@ contract Integration_ResponseProposal is IntegrationBase { /** * @notice Proposing from an unapproved dispute module */ - function test_proposeResponse_fromUnapprovedDisputeModule(bytes memory _responseBytes) public { + function test_proposeResponse_fromUnapprovedDisputeModule() public { + bytes memory _responseBytes = abi.encode('valid-response'); address _attacker = makeAddr('attacker'); mockRequest.nonce += 1; mockRequest.requester = _attacker; diff --git a/solidity/test/integration/RootVerification.t.sol b/solidity/test/integration/RootVerification.t.sol index 9d501b6..184009c 100644 --- a/solidity/test/integration/RootVerification.t.sol +++ b/solidity/test/integration/RootVerification.t.sol @@ -111,7 +111,8 @@ contract Integration_RootVerification is IntegrationBase { oracle.finalize(mockRequest, mockResponse, _createAccessControl(address(this))); } - function test_disputeResponse_incorrectResponse(bytes32 _invalidRoot) public { + function test_disputeResponse_incorrectResponse() public { + bytes32 _invalidRoot = keccak256(abi.encode('invalid-root')); vm.assume(_correctRoot != _invalidRoot); _deposit(_accountingExtension, proposer, usdc, _expectedBondSize);