Skip to content

Commit

Permalink
test: remove fuzzing from integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Nov 21, 2024
1 parent bf1b482 commit c29fbb4
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 37 deletions.
38 changes: 24 additions & 14 deletions solidity/test/integration/AccountingExtension.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
17 changes: 11 additions & 6 deletions solidity/test/integration/Finalization.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand Down Expand Up @@ -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();
Expand All @@ -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}))
Expand All @@ -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}))
Expand All @@ -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}))
Expand Down
20 changes: 16 additions & 4 deletions solidity/test/integration/Payments.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions solidity/test/integration/ResponseDispute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
36 changes: 26 additions & 10 deletions solidity/test/integration/ResponseProposal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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?
Expand All @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion solidity/test/integration/RootVerification.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c29fbb4

Please sign in to comment.