Skip to content

Commit

Permalink
test: enforce 0 < exclusivityEndTime <= deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Oct 1, 2024
1 parent 415aa18 commit 6f5ffa7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
}

0 comments on commit 6f5ffa7

Please sign in to comment.