From c0ffeea53278c5c5fcda716988d3080cdd8f7bdb Mon Sep 17 00:00:00 2001 From: drgorillamd <83670532+drgorillamd@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:57:02 +0100 Subject: [PATCH] test(medusa): false pos fix --- test/invariants/Reproducers.t.sol | 31 +++++++++++++++++++ .../properties/PropertyDisputer.t.sol | 3 ++ .../properties/PropertyProposer.t.sol | 8 +++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/test/invariants/Reproducers.t.sol b/test/invariants/Reproducers.t.sol index 8525ae2..5405064 100644 --- a/test/invariants/Reproducers.t.sol +++ b/test/invariants/Reproducers.t.sol @@ -5,4 +5,35 @@ import {FuzzTest} from './FuzzTest.t.sol'; import {IEBORequestModule, IOracle} from './Setup.t.sol'; contract Reproducers is FuzzTest { + // forge test --match-test test_property_proposerProposeBeforeDeadline_0 -vv + + function test_property_proposerProposeBeforeDeadline_0() public { + vm.roll(3); + vm.warp(5); + vm.prank(0x0000000000000000000000000000000000050000); + this.property_requesterCanAlwaysCreateRequest( + 374_144_410_540_673_166_053_842_224_195_120_560_619_866_525_050_602, + 5_986_310_706_507_378_352_962_293_074_772_827_676_701_747_093_414_338 + ); + + vm.roll(3); + vm.warp(5); + vm.prank(0x0000000000000000000000000000000000080000); + this.property_proposerProposeBeforeDeadline( + 28_269_553_036_454_149_273_332_760_011_729_145_844_444_279_663_245_845_661_993_448_680_761_270_657 + ); + + vm.roll(3); + vm.warp(5); + vm.prank(0x00000000000000000000000000000000000a0000); + this.property_disputerCanAlwaysCreateDispute( + 52_656_145_834_278_593_348_801_540_361_656_756_882_899_066_090_699_848_781_561_730_236, + 23_384_028_043_587_125_922_018_477_620_072_735_176_296_069_636_430 + ); + + vm.roll(3); + vm.warp(5); + vm.prank(0x0000000000000000000000000000000000080000); + this.property_proposerProposeBeforeDeadline(2_106_197_910_122_343_031_135_180_017_583_558_693_042_066_481_234); + } } diff --git a/test/invariants/properties/PropertyDisputer.t.sol b/test/invariants/properties/PropertyDisputer.t.sol index 11f3c16..09f5477 100644 --- a/test/invariants/properties/PropertyDisputer.t.sol +++ b/test/invariants/properties/PropertyDisputer.t.sol @@ -124,9 +124,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 8a: fails on pledging for the correct side' ); diff --git a/test/invariants/properties/PropertyProposer.t.sol b/test/invariants/properties/PropertyProposer.t.sol index 199f9c7..dd5c85b 100644 --- a/test/invariants/properties/PropertyProposer.t.sol +++ b/test/invariants/properties/PropertyProposer.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.26; -import {IOracle} from '../Setup.t.sol'; +import {IOracle, ValidatorLib} from '../Setup.t.sol'; import {HandlerParent} from '../handlers/HandlerParent.t.sol'; contract PropertyProposer is HandlerParent { @@ -47,9 +47,11 @@ contract PropertyProposer is HandlerParent { emit ResponseProposed(requestId, responseId); } catch { - // property 3 and 4 + // property 3 and 4 + cannot propose the same response twice + bytes32 responseId = ValidatorLib._validateResponse(requestData, responseData); + assertTrue( - activeResponses && (prevDisputeId == 0 || status == IOracle.DisputeStatus.Lost) + prevResponseId == responseId || activeResponses && (prevDisputeId == 0 || status == IOracle.DisputeStatus.Lost) || block.timestamp >= oracle.requestCreatedAt(requestId) + RESPONSE_DEADLINE, 'prop-3-4: fails but no active response disputed or with lost dispute' );