Skip to content

Commit

Permalink
test: update calls to totalRequestCount in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Dec 10, 2024
1 parent 76c1714 commit 0bdda11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion solidity/test/integration/ResponseDispute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract Integration_ResponseDispute is IntegrationBase {
_expectedDeadline = block.timestamp + BLOCK_TIME * 600;
_responseData = abi.encode('response');

mockRequest.nonce = uint96(oracle.totalRequestCount());
mockRequest.nonce = uint96(oracle.nextRequestNonce());

mockAccessControl.user = requester;
_requestId = oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl);
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/integration/ResponseProposal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract Integration_ResponseProposal is IntegrationBase {
function setUp() public override {
super.setUp();

mockRequest.nonce = uint96(oracle.totalRequestCount());
mockRequest.nonce = uint96(oracle.nextRequestNonce());

address _badRequester = makeAddr('badRequester');
mockAccessControl.user = _badRequester;
Expand Down
26 changes: 13 additions & 13 deletions solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ contract MockOracle is Oracle {
disputeCreatedAt[_disputeId] = _disputeCreatedAt;
}

function mock_setTotalRequestCount(uint256 _totalRequestCount) external {
totalRequestCount = _totalRequestCount;
function mock_setNextRequestNonce(uint256 _nextRequestNonce) external {
nextRequestNonce = _nextRequestNonce;
}

function mock_addResponseId(bytes32 _requestId, bytes32 _responseId) external {
Expand Down Expand Up @@ -156,7 +156,7 @@ contract Oracle_Unit_CreateRequest is BaseTest {
bytes calldata _resolutionData,
bytes calldata _finalityData
) public setResolutionAndFinality(_useResolutionAndFinality) happyPath {
uint256 _initialNonce = oracle.totalRequestCount();
uint256 _initialNonce = oracle.nextRequestNonce();

// Create the request
mockRequest.requestModuleData = _requestData;
Expand All @@ -165,7 +165,7 @@ contract Oracle_Unit_CreateRequest is BaseTest {
mockRequest.resolutionModuleData = _resolutionData;
mockRequest.finalityModuleData = _finalityData;
mockRequest.requester = requester;
mockRequest.nonce = uint96(oracle.totalRequestCount());
mockRequest.nonce = uint96(oracle.nextRequestNonce());

// Compute the associated request id
bytes32 _theoreticalRequestId = _getId(mockRequest);
Expand Down Expand Up @@ -200,7 +200,7 @@ contract Oracle_Unit_CreateRequest is BaseTest {
assertEq(_requestId, _theoreticalRequestId);

// Check: nonce incremented?
assertEq(oracle.totalRequestCount(), _initialNonce + 1);
assertEq(oracle.nextRequestNonce(), _initialNonce + 1);
}

/**
Expand Down Expand Up @@ -235,7 +235,7 @@ contract Oracle_Unit_CreateRequest is BaseTest {
* @notice Check that creating a request with a nonce that already exists reverts
*/
function test_createRequest_revertsIfInvalidNonce(uint256 _nonce) public happyPath {
vm.assume(_nonce != oracle.totalRequestCount());
vm.assume(_nonce != oracle.nextRequestNonce());

// Set the nonce
mockRequest.nonce = uint96(_nonce);
Expand Down Expand Up @@ -273,7 +273,7 @@ contract Oracle_Unit_CreateRequests is BaseTest {
bytes calldata _responseData,
bytes calldata _disputeData
) public {
uint256 _initialNonce = oracle.totalRequestCount();
uint256 _initialNonce = oracle.nextRequestNonce();
uint256 _requestsAmount = 5;
IOracle.Request[] memory _requests = new IOracle.Request[](_requestsAmount);
bytes32[] memory _precalculatedIds = new bytes32[](_requestsAmount);
Expand All @@ -290,7 +290,7 @@ contract Oracle_Unit_CreateRequests is BaseTest {
mockRequest.responseModuleData = _responseData;
mockRequest.disputeModuleData = _disputeData;
mockRequest.requester = requester;
mockRequest.nonce = uint96(oracle.totalRequestCount() + _i);
mockRequest.nonce = uint96(oracle.nextRequestNonce() + _i);

bytes32 _theoreticalRequestId = _getId(mockRequest);
_requests[_i] = mockRequest;
Expand Down Expand Up @@ -329,7 +329,7 @@ contract Oracle_Unit_CreateRequests is BaseTest {
assertEq(oracle.nonceToRequestId(_requests[_i].nonce), _requestsIds[_i]);
}

uint256 _newNonce = oracle.totalRequestCount();
uint256 _newNonce = oracle.nextRequestNonce();
assertEq(_newNonce, _initialNonce + _requestsAmount);
}

Expand All @@ -341,7 +341,7 @@ contract Oracle_Unit_CreateRequests is BaseTest {
bytes calldata _responseData,
bytes calldata _disputeData
) public {
uint256 _initialNonce = oracle.totalRequestCount();
uint256 _initialNonce = oracle.nextRequestNonce();
uint256 _requestsAmount = 5;
IOracle.Request[] memory _requests = new IOracle.Request[](_requestsAmount);
bytes32[] memory _precalculatedIds = new bytes32[](_requestsAmount);
Expand Down Expand Up @@ -369,7 +369,7 @@ contract Oracle_Unit_CreateRequests is BaseTest {
oracle.mock_setAccessModuleApproved(requester, address(accessModule), true);
oracle.createRequests(_requests, _ipfsHashes, _accessControls);

uint256 _newNonce = oracle.totalRequestCount();
uint256 _newNonce = oracle.nextRequestNonce();
assertEq(_newNonce, _initialNonce + _requestsAmount);
}
}
Expand All @@ -391,7 +391,7 @@ contract Oracle_Unit_ListRequestIds is BaseTest {
oracle.mock_setRequestId(_i, _requestId);
}

oracle.mock_setTotalRequestCount(_numberOfRequests);
oracle.mock_setNextRequestNonce(_numberOfRequests);

// Test: fetching the requests
bytes32[] memory _requestsIds = oracle.listRequestIds(0, _numberOfRequests);
Expand Down Expand Up @@ -421,7 +421,7 @@ contract Oracle_Unit_ListRequestIds is BaseTest {
oracle.mock_setRequestId(_i, _requestId);
}

oracle.mock_setTotalRequestCount(_numberOfRequests);
oracle.mock_setNextRequestNonce(_numberOfRequests);

// Test: fetching 1 extra request
bytes32[] memory _requestsIds = oracle.listRequestIds(0, _numberOfRequests + 1);
Expand Down

0 comments on commit 0bdda11

Please sign in to comment.