From 6f5ffa781fd58df90c6e930826e98a03e143a67a Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:09:10 +0100 Subject: [PATCH] test: enforce `0 < exclusivityEndTime <= deadline` --- .../test/FastBridgeV2.Src.Exclusivity.Negative.t.sol | 12 ++++++++++++ .../test/FastBridgeV2.Src.Exclusivity.t.sol | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.Negative.t.sol b/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.Negative.t.sol index 6de747706d..0b19f097f3 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.Negative.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.Negative.t.sol @@ -26,12 +26,24 @@ contract FastBridgeV2SrcExclusivityNegativeTest is FastBridgeV2SrcTest { bridge(caller, msgValue, params, paramsV2); } + function test_bridge_revert_exclusivityEndTimeZero() public { + tokenParamsV2.quoteExclusivitySeconds = -int256(block.timestamp); + vm.expectRevert(ExclusivityParamsIncorrect.selector); + bridge({caller: userA, msgValue: 0, params: tokenParams, paramsV2: tokenParamsV2}); + } + function test_bridge_revert_exclusivityPeriodUnderflow() public { tokenParamsV2.quoteExclusivitySeconds = -int256(block.timestamp + 1); vm.expectRevert(ExclusivityParamsIncorrect.selector); bridge({caller: userA, msgValue: 0, params: tokenParams, paramsV2: tokenParamsV2}); } + function test_bridge_eth_revert_exclusivityEndTimeZero() public { + ethParamsV2.quoteExclusivitySeconds = -int256(block.timestamp); + vm.expectRevert(ExclusivityParamsIncorrect.selector); + bridge({caller: userA, msgValue: ethParams.originAmount, params: ethParams, paramsV2: ethParamsV2}); + } + function test_bridge_eth_revert_exclusivityPeriodUnderflow() public { ethParamsV2.quoteExclusivitySeconds = -int256(block.timestamp + 1); vm.expectRevert(ExclusivityParamsIncorrect.selector); diff --git a/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol b/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol index a6e5943818..259ef0bacd 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol @@ -25,4 +25,16 @@ contract FastBridgeV2SrcExclusivityTest is FastBridgeV2SrcTest { IFastBridgeV2.BridgeParamsV2 memory paramsV2 = params.originToken == ETH_ADDRESS ? ethParamsV2 : tokenParamsV2; bridge(caller, msgValue, params, paramsV2); } + + function test_bridge_revert_exclusivityEndTimeOverDeadline() public { + tokenParamsV2.quoteExclusivitySeconds = int256(DEADLINE + 1); + vm.expectRevert(ExclusivityParamsIncorrect.selector); + bridge({caller: userA, msgValue: 0, params: tokenParams, paramsV2: tokenParamsV2}); + } + + function test_bridge_eth_revert_exclusivityEndTimeOverDeadline() public { + ethParamsV2.quoteExclusivitySeconds = int256(DEADLINE + 1); + vm.expectRevert(ExclusivityParamsIncorrect.selector); + bridge({caller: userA, msgValue: ethParams.originAmount, params: ethParams, paramsV2: ethParamsV2}); + } }