Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: medusa tests #51

Draft
wants to merge 29 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5d5fd14
chore: properties md update
simon-something Oct 29, 2024
3b77715
test(medusa): handlers and working setup
simon-something Nov 10, 2024
1b53763
test(medusa): add lib to crytic compile
simon-something Nov 10, 2024
98de161
test(medusa): prop 0 sanity check ok
simon-something Nov 10, 2024
92a50e3
test(medusa): git ignore corpus
simon-something Nov 10, 2024
1e78bdb
test(medusa): git ignore corpus
simon-something Nov 10, 2024
efc8876
test(medusa): typo medusa json
simon-something Nov 10, 2024
e4cf1e5
test(medusa): rm corpus
simon-something Nov 10, 2024
c0ffee6
test(medusa): natspec
simon-something Nov 11, 2024
c0ffee7
test(medusa): rm non-sensical handlers onlyoracle etc
simon-something Nov 11, 2024
c0ffeed
test(medusa): ghosts refactor
simon-something Nov 13, 2024
c0ffee6
test(medusa): more handler fixes
simon-something Nov 13, 2024
c0ffeee
test(medusa): properties md update
simon-something Nov 20, 2024
9c8dce2
test(medusa): requester properties (#57)
0xJabberwock Nov 28, 2024
c0ffee9
test(medusa): dispute window in prop6
simon-something Nov 28, 2024
c0ffeef
test(medusa): fix approveModule
simon-something Nov 28, 2024
c0ffeeb
test(medusa): fix approveModule
simon-something Nov 28, 2024
97fff3c
test(medusa): rename PropertyDispute to PropertyDisputer
0xJabberwock Nov 29, 2024
80d145f
test(medusa): correct prop-6
0xJabberwock Nov 29, 2024
1d45342
test(medusa): assert prop-7
0xJabberwock Nov 29, 2024
c0ffee6
test(medusa): properties 13
simon-something Nov 30, 2024
c0ffee9
test(medusa): fix prop1 for empty finalized req
simon-something Dec 7, 2024
c0ffee7
test(medusa): fix fp
simon-something Dec 11, 2024
7218056
test(medusa): proposer properties
0xJabberwock Dec 13, 2024
2b8bc63
test(medusa): fix prop8b
simon-something Dec 11, 2024
c0ffee2
test(medusa): false pos fix
simon-something Dec 16, 2024
c0ffeea
test(medusa): false pos fix
simon-something Dec 16, 2024
a3b8f1c
Merge branch 'dev' into test/handler-cov
simon-something Dec 18, 2024
c0ffee8
Revert "Merge branch 'dev' into test/handler-cov"
simon-something Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the escalation status comparison redundant with _ghost_escalatedDisputes?

|| _totalPledgesFor(_disputeId) < _totalPledgesAgainst(_disputeId),
'property 8b: fails on pledging for the correct side'
);
Expand Down
Loading