Skip to content

Commit

Permalink
test: oracle unit tests (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent authored Oct 4, 2023
1 parent bacc238 commit 42374ba
Show file tree
Hide file tree
Showing 3 changed files with 628 additions and 508 deletions.
11 changes: 7 additions & 4 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ contract Oracle is IOracle {

/// @inheritdoc IOracle
function listRequestIds(uint256 _startFrom, uint256 _batchSize) external view returns (bytes32[] memory _list) {
if (_batchSize > totalRequestCount) {
uint256 _totalRequestsCount = totalRequestCount;

// If trying to collect non-existent ids only, return empty array
if (_startFrom > _totalRequestsCount) {
return _list;
}

if (_batchSize > totalRequestCount - _startFrom) {
_batchSize = totalRequestCount - _startFrom;
if (_batchSize > _totalRequestsCount - _startFrom) {
_batchSize = _totalRequestsCount - _startFrom;
}

_list = new bytes32[](_batchSize);
Expand Down Expand Up @@ -378,7 +381,7 @@ contract Oracle is IOracle {
DisputeStatus _disputeStatus = _disputes[_disputeId].status;

if (_disputeStatus != DisputeStatus.None && _disputeStatus != DisputeStatus.Lost) {
revert Oracle_InvalidFinalizedResponse(_requestId);
revert Oracle_InvalidFinalizedResponse(_responseId);
}

unchecked {
Expand Down
4 changes: 0 additions & 4 deletions solidity/test/integration/EscalateDispute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ contract Integration_EscalateDispute is IntegrationBase {
IOracle.Dispute memory _dispute = oracle.getDispute(_disputeId);
assertTrue(_dispute.status == IOracle.DisputeStatus.Escalated);

/// TODO: The MockDisputeModule should now have the escalation status escalated
// IMockDisputeModule.BondEscalation memory _bondEscalation = _disputeModule.getEscalation(_requestId);
// assertTrue(_bondEscalation.status == IMockDisputeModule.BondEscalationStatus.Escalated);

/// Escalate dispute reverts if dispute is not active
vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_CannotEscalate.selector, _disputeId));
oracle.escalateDispute(_disputeId);
Expand Down
Loading

0 comments on commit 42374ba

Please sign in to comment.