Skip to content

Commit

Permalink
test(medusa): prop 10-13 (#59)
Browse files Browse the repository at this point in the history
# 🤖 Linear

Closes GRT-XXX

---------

Co-authored-by: drgorillamd <83670532+drgorillamd@users.noreply.github.com>
  • Loading branch information
simon-something and simon-something authored Nov 27, 2024
1 parent c0ffee3 commit 56aa7bd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
8 changes: 7 additions & 1 deletion test/invariants/properties/PropertyDispute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {HandlerParent} from '../handlers/HandlerParent.t.sol';
contract PropertyDispute is HandlerParent {
/// @custom:property-id 6
/// @custom:property Disputer can always dispute a response before the finalisation, if no previous dispute has been made.
/// @custom:property-id 13
/// @custom:property Each disputeId and responseId can only be tied to one requestId
function property_disputerCanAlwaysCreateDispute(uint256 _requestIdSeed, uint256 _responseIdSeed) public {
// Pick random Response
bytes32 _requestId = _getRandomRequestId(_requestIdSeed);
Expand All @@ -30,6 +32,10 @@ contract PropertyDispute is HandlerParent {
// check if no previous dispute
assertEq(_ghost_disputes[_requestId].length, 0, 'property 6: new dispute duplicate');

// check the disputeId isn't tied to another requestId
// property 13
assertEq(_ghost_disputeData[_disputeId].requestId, bytes32(0), 'Property 13: disputeId tied to another requestId');

// add to ghost disputes
_ghost_disputes[_responseId].push(_disputeId);
_ghost_disputeData[_disputeId] = _disputeData;
Expand Down Expand Up @@ -61,7 +67,7 @@ contract PropertyDispute is HandlerParent {
vm.prank(msg.sender);
try oracle.escalateDispute(_requestData, _responseData, _disputeData) {
// check that the dispute is the first one
assertEq(_ghost_disputes[_responseId][0], _disputeId, 'property 7: not first dispute');
assertEq(_ghost_activeResponses[_requestId][0], _disputeData.requestId, 'property 7: not first dispute');
} catch {
// not first dispute or
// not past the bond escalation deadline
Expand Down
31 changes: 31 additions & 0 deletions test/invariants/properties/PropertyFinalize.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {IEBORequestModule, IOracle} from '../Setup.t.sol';
import {HandlerParent} from '../handlers/HandlerParent.t.sol';

contract PropertyFinalize is HandlerParent {
/// @custom:property-id 10
/// @custom:property An answer can only be finalized after the deadline
function property_finalizeAfterDeadline(uint256 _requestIdSeed, uint256 _responseIdSeed) public {
// Pick random Response
bytes32 _requestId = _getRandomRequestId(_requestIdSeed);
IOracle.Request memory _requestData = _ghost_requestData[_requestId];

(bytes32 _responseId, IOracle.Response memory _responseData) = _getRandomActiveResponse(_requestId, _responseIdSeed);

vm.prank(msg.sender);
try oracle.finalize(_requestData, _responseData) {
// After deadline
//
// Update ghosts
} catch {
// Before response deadline or
// No response if there is one or
// Unresolved disputed or
//
}
}

// TODO: consider adding property for releasing unfinazible ones?
}
8 changes: 5 additions & 3 deletions test/invariants/properties/PropertyParent.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
pragma solidity 0.8.26;

import {PropertyDispute} from './PropertyDispute.t.sol';

import {PropertyFinalize} from './PropertyFinalize.t.sol';
import {PropertyPropose} from './PropertyPropose.t.sol';
import {PropertyRequester} from './PropertyRequester.t.sol';

contract PropertyParent is PropertyRequester, PropertyDispute {
//solhint-disable no-empty-blocks
constructor() {}
contract PropertyParent is PropertyRequester, PropertyPropose, PropertyDispute, PropertyFinalize {
// | 11 | bonded token can never be used on behalf of someone else, unless allowed by the Horizon staking contract | | [ ] |
}
18 changes: 18 additions & 0 deletions test/invariants/properties/PropertyPropose.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {IEBORequestModule, IOracle} from '../Setup.t.sol';
import {HandlerParent} from '../handlers/HandlerParent.t.sol';

contract PropertyPropose is HandlerParent {
/// @custom:property-id
/// @custom:property
function property_proposeBeforeDeadlineAndNoAnswer(uint256 _requestIdSeed, uint256 _responseIdSeed) public {
// Pick random Response
bytes32 _requestId = _getRandomRequestId(_requestIdSeed);
IOracle.Request memory _requestData = _ghost_requestData[_requestId];

// Stake some GRT in Horizon
_stakeGRT(DISPUTE_BOND_SIZE);
}
}

0 comments on commit 56aa7bd

Please sign in to comment.