Skip to content

Commit

Permalink
test(medusa): false pos fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-something committed Dec 16, 2024
1 parent 2b8bc63 commit c0ffee2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 105 deletions.
102 changes: 0 additions & 102 deletions test/invariants/Reproducers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,106 +5,4 @@ import {FuzzTest} from './FuzzTest.t.sol';
import {IEBORequestModule, IOracle} from './Setup.t.sol';

contract Reproducers is FuzzTest {
// forge test --match-test test_prop_singleRequestIdForSingleDisputeOrResponseId_0 -vv

function test_prop_singleRequestIdForSingleDisputeOrResponseId_0() public {
vm.roll(3);
vm.warp(107_622);
vm.prank(0x0000000000000000000000000000000000030000);
this.property_requesterCanAlwaysCreateRequest(
10, 37_029_423_570_101_568_114_192_451_652_059_639_489_459_691_769_081_285_614_258_977_732_585_787
);

vm.roll(29_920);
vm.warp(191_126);
vm.prank(0x0000000000000000000000000000000000020000);
this.property_proposerProposeBeforeDeadline(
3_533_694_129_556_768_659_166_594_920_800_430_618_073_929_656_453_786_986_859_439_806_182_558_244
);

vm.roll(41_973);
vm.warp(293_378);
vm.prank(0x0000000000000000000000000000000000070000);
this.property_disputerCanAlwaysCreateDispute(
44_601_490_397_061_246_283_071_436_695_194_755_937_831_813,
24_519_928_653_539_120_916_142_750_395_984_862_678_837_009_021_121_402_119
);

vm.roll(72_668);
vm.warp(701_817);
vm.prank(0x0000000000000000000000000000000000090000);
this.property_finalizeAfterDeadline(
441_711_766_194_596_082_395_824_375_183_268_584_384_174_444_443_096_125_085_881_927_426_324_089,
55_213_970_774_324_510_299_478_046_897_908_487_977_573_366_651_192_816_587_142_984_978_084_060
);

vm.roll(130_241);
vm.warp(1_239_575);
vm.prank(0x0000000000000000000000000000000000060000);
this.property_disputerEscalateFirstDisputedResponse(
441_711_766_194_596_082_395_824_375_183_267_903_819_727_185_636_638_495_186_960_857_860_556_558,
601_007_113_947_101_039_560_436_606_908_369_912_464
);

vm.roll(133_321);
vm.warp(1_272_520);
vm.prank(0x0000000000000000000000000000000000030000);
this.handleArbitrateDispute(
98_079_714_617_799_838_069_981_031_751_129_814_657_974_628_780_861_328_198,
10_543_876_310_748_807_825_434_603_100_744_632_307_071_557,
7_369_614_386_207_023_510_276_552_037
);

vm.roll(133_321);
vm.warp(1_272_520);
vm.prank(0x0000000000000000000000000000000000030000);
this.property_requesterCanAlwaysCreateRequest(
10, 1_184_941_554_243_250_179_654_158_452_865_908_463_662_710_136_610_601_139_976_392_267_926_618_806
);

vm.roll(133_469);
vm.warp(1_272_796);
vm.prank(0x0000000000000000000000000000000000060000);
this.prop_singleRequestIdForSingleDisputeOrResponseId();
}

// forge test --match-test test_property_pledgerCanPledgeFor_1 -vv

function test_property_pledgerCanPledgeFor_1() public {
vm.roll(56_765);
vm.warp(310_068);
vm.prank(0x0000000000000000000000000000000000030000);
this.property_requesterCanAlwaysCreateRequest(
23_945_252_909_255_375_823_092_408_840_274_513_180_624_399_837_945_186, 2_086_162_298_782_925_019_460
);

vm.roll(86_763);
vm.warp(575_158);
vm.prank(0x0000000000000000000000000000000000030000);
this.property_proposerProposeBeforeDeadline(631_432_499_075_532_304_456_395_701_379_901_335_158_300_516);

vm.roll(108_137);
vm.warp(650_339);
vm.prank(0x0000000000000000000000000000000000030000);
this.property_disputerCanAlwaysCreateDispute(
862_718_293_348_820_473_429_987_288_449_076_456_476_499_045_871_166_767_810_196_422_572_057,
1_239_938_753_245_600_703_949_804_873_417_738_265_153_932
);

vm.roll(143_071);
vm.warp(748_820);
vm.prank(0x0000000000000000000000000000000000070000);
this.property_disputerEscalateFirstDisputedResponse(
1_645_504_557_321_206_042_785_170_517_226_798_052_215_695_477_109_921_052_145_574_832,
3_213_876_088_517_980_570_777_725_284_107_382_648_403_960_509_936_676_257_779_973
);

vm.roll(150_070);
vm.warp(774_026);
vm.prank(0x0000000000000000000000000000000000070000);
this.property_pledgerCanPledgeFor(
6_901_746_346_790_563_787_434_755_862_238_646_067_770_489_658_248_914_019_106_131_779_923_731,
6_129_982_162_203_152_163_068_464_937_047_330_911_145_056_599_837_097_252
);
}
}
2 changes: 2 additions & 0 deletions test/invariants/handlers/HandlerCouncilArbitrator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ contract HandlerCouncilArbitrator is BaseHandler {
(bytes32 disputeId, IOracle.Dispute memory dispute) = _getRandomDispute(requestId, _disputeIndex);
if (dispute.requestId == bytes32(0)) return;

if (!_ghost_escalatedDisputes[disputeId]) return;

// Generate a valid dispute status (NoResolution, Won, Lost)
IOracle.DisputeStatus status = IOracle.DisputeStatus(
bound(_statusSeed, uint8(IOracle.DisputeStatus.NoResolution), uint8(IOracle.DisputeStatus.Lost))
Expand Down
13 changes: 10 additions & 3 deletions test/invariants/properties/PropertyDisputer.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

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

contract PropertyDisputer is HandlerParent {
Expand Down Expand Up @@ -89,14 +89,19 @@ contract PropertyDisputer is HandlerParent {
// add to ghost escalated disputes
_ghost_escalatedDisputes[_disputeId] = true;
} catch {
IBondEscalationModule.BondEscalation memory _escalation = bondEscalationModule.getEscalation(_disputeId);

// not first dispute, or
// not past the bond escalation deadline, or
// already escalated, or
// already escalated/not active anymore (status none, or finalized, etc)
// bond not tied
assertTrue(
_ghost_activeResponses[_requestId][0] != _disputeData.responseId
|| block.timestamp <= oracle.disputeCreatedAt(_disputeId) + DISPUTE_DEADLINE
|| _ghost_escalatedDisputes[_disputeId],
|| _ghost_escalatedDisputes[_disputeId]
|| _escalation.status != IBondEscalationModule.BondEscalationStatus.Active
|| _totalPledgesFor(_disputeId) != _totalPledgesAgainst(_disputeId),
// || _escalation.amountOfPledgesForDispute != _escalation.amountOfPledgesAgainstDispute,
'property 7: fails on first disputed response'
);
}
Expand Down Expand Up @@ -144,10 +149,12 @@ contract PropertyDisputer is HandlerParent {
);
} catch {
// add tying buffer to deadline
IBondEscalationModule.BondEscalation memory _escalation = bondEscalationModule.getEscalation(_disputeId);

assertTrue(
!_ghost_escalatedDisputes[_disputeId]
|| block.timestamp > oracle.disputeCreatedAt(_disputeId) + DISPUTE_DEADLINE
|| _escalation.status != IBondEscalationModule.BondEscalationStatus.Active
|| _totalPledgesFor(_disputeId) < _totalPledgesAgainst(_disputeId),
'property 8b: fails on pledging for the correct side'
);
Expand Down

0 comments on commit c0ffee2

Please sign in to comment.