Skip to content

Commit

Permalink
fix: add inline comments for internal revert tests (#317)
Browse files Browse the repository at this point in the history
* add inline comments for internal revert tests

* test: update decay overflow naming

---------

Co-authored-by: Alan Wu <[email protected]>
  • Loading branch information
zhongeric and alanhwu authored Feb 10, 2025
1 parent 2954f97 commit 5016e3d
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 92 deletions.
8 changes: 4 additions & 4 deletions snapshots/DirectFillerFillMacroTest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DirectFillerFillMacroSingleOrder": "135973",
"DirectFillerFillMacroSingleOrderWithFee": "174570",
"DirectFillerFillMacroThreeOrdersWithFees": "433904",
"DirectFillerFillMacroTwoOrders": "255553"
"DirectFillerFillMacroSingleOrder": "135820",
"DirectFillerFillMacroSingleOrderWithFee": "174331",
"DirectFillerFillMacroThreeOrdersWithFees": "433336",
"DirectFillerFillMacroTwoOrders": "255333"
}
18 changes: 9 additions & 9 deletions snapshots/DutchOrderReactorTest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"BaseExecuteSingleWithFee": "176379",
"ExecuteBatch": "188624",
"ExecuteBatchMultipleOutputs": "197968",
"ExecuteBatchMultipleOutputsDifferentTokens": "251215",
"ExecuteBatchNativeOutput": "184650",
"ExecuteSingle": "142762",
"ExecuteSingleNativeOutput": "130824",
"ExecuteSingleValidation": "152072",
"RevertInvalidNonce": "22192"
"BaseExecuteSingleWithFee": "176167",
"ExecuteBatch": "188355",
"ExecuteBatchMultipleOutputs": "197673",
"ExecuteBatchMultipleOutputsDifferentTokens": "250894",
"ExecuteBatchNativeOutput": "184399",
"ExecuteSingle": "142617",
"ExecuteSingleNativeOutput": "130688",
"ExecuteSingleValidation": "151906",
"RevertInvalidNonce": "22119"
}
4 changes: 2 additions & 2 deletions snapshots/EthOutputDirectFillerTest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"DirectFillerFillMacroTestEth1Output": "147146",
"DirectFillerFillMacroTestEth2Outputs": "170234"
"DirectFillerFillMacroTestEth1Output": "147001",
"DirectFillerFillMacroTestEth2Outputs": "170048"
}
4 changes: 2 additions & 2 deletions snapshots/EthOutputMockFillContractTest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"EthOutputTest3OrdersWithEthAndERC20Outputs": "362445",
"EthOutputTestEthOutput": "156342"
"EthOutputTest3OrdersWithEthAndERC20Outputs": "362022",
"EthOutputTestEthOutput": "156137"
}
18 changes: 9 additions & 9 deletions snapshots/ExclusiveDutchOrderReactorTest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"BaseExecuteSingleWithFee": "176480",
"ExecuteBatch": "188814",
"ExecuteBatchMultipleOutputs": "198158",
"ExecuteBatchMultipleOutputsDifferentTokens": "251405",
"ExecuteBatchNativeOutput": "184840",
"ExecuteSingle": "142871",
"ExecuteSingleNativeOutput": "130933",
"ExecuteSingleValidation": "152181",
"RevertInvalidNonce": "22290"
"BaseExecuteSingleWithFee": "176269",
"ExecuteBatch": "188547",
"ExecuteBatchMultipleOutputs": "197865",
"ExecuteBatchMultipleOutputsDifferentTokens": "251086",
"ExecuteBatchNativeOutput": "184591",
"ExecuteSingle": "142727",
"ExecuteSingleNativeOutput": "130798",
"ExecuteSingleValidation": "152016",
"RevertInvalidNonce": "22218"
}
2 changes: 1 addition & 1 deletion snapshots/ExclusiveFillerValidationTest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"testExclusiveFillerSucceeds": "171199"
"testExclusiveFillerSucceeds": "170979"
}
18 changes: 9 additions & 9 deletions snapshots/LimitOrderReactorTest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"BaseExecuteSingleWithFee": "172831",
"ExecuteBatch": "181452",
"ExecuteBatchMultipleOutputs": "189990",
"ExecuteBatchMultipleOutputsDifferentTokens": "242428",
"ExecuteBatchNativeOutput": "177478",
"ExecuteSingle": "139215",
"ExecuteSingleNativeOutput": "127277",
"ExecuteSingleValidation": "148525",
"RevertInvalidNonce": "18656"
"BaseExecuteSingleWithFee": "172635",
"ExecuteBatch": "181215",
"ExecuteBatchMultipleOutputs": "189732",
"ExecuteBatchMultipleOutputsDifferentTokens": "242149",
"ExecuteBatchNativeOutput": "177259",
"ExecuteSingle": "139086",
"ExecuteSingleNativeOutput": "127157",
"ExecuteSingleValidation": "148375",
"RevertInvalidNonce": "18599"
}
20 changes: 10 additions & 10 deletions snapshots/NonlinearDutchDecayLibTest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"V3-DutchDecay": "16413",
"V3-DutchDecayFullyDecayed": "7908",
"V3-DutchDecayFullyDecayedNegative": "7619",
"V3-DutchDecayNegative": "15389",
"V3-DutchDecayNoDecayYet": "5720",
"V3-DutchDecayNoDecayYetNegative": "5694",
"V3-ExtendedMultiPointDutchDecay": "106707",
"V3-LocateCurvePositionMulti": "17727",
"V3-LocateCurvePositionSingle": "4227",
"V3-MultiPointDutchDecay": "33868"
"V3-DutchDecay": "16243",
"V3-DutchDecayFullyDecayed": "7838",
"V3-DutchDecayFullyDecayedNegative": "7555",
"V3-DutchDecayNegative": "15239",
"V3-DutchDecayNoDecayYet": "5692",
"V3-DutchDecayNoDecayYetNegative": "5664",
"V3-ExtendedMultiPointDutchDecay": "105758",
"V3-LocateCurvePositionMulti": "17610",
"V3-LocateCurvePositionSingle": "4191",
"V3-MultiPointDutchDecay": "33549"
}
26 changes: 13 additions & 13 deletions snapshots/PriorityOrderReactorTest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"BaseExecuteSingleWithFee": "178696",
"ExecuteBatch": "193279",
"ExecuteBatchMultipleOutputs": "202497",
"ExecuteBatchMultipleOutputsDifferentTokens": "255617",
"ExecuteBatchNativeOutput": "189305",
"ExecuteSingle": "145087",
"ExecuteSingleNativeOutput": "133149",
"ExecuteSingleValidation": "154397",
"InputPriorityFee": "147392",
"OutputPriorityFee": "147396",
"OutputPriorityFeeAndBaselinePriorityFee": "147396",
"OverrideAuctionTargetBlock": "124529",
"RevertInvalidNonce": "8853"
"BaseExecuteSingleWithFee": "178476",
"ExecuteBatch": "192994",
"ExecuteBatchMultipleOutputs": "202189",
"ExecuteBatchMultipleOutputsDifferentTokens": "255286",
"ExecuteBatchNativeOutput": "189038",
"ExecuteSingle": "144934",
"ExecuteSingleNativeOutput": "133005",
"ExecuteSingleValidation": "154223",
"InputPriorityFee": "147237",
"OutputPriorityFee": "147243",
"OutputPriorityFeeAndBaselinePriorityFee": "147243",
"OverrideAuctionTargetBlock": "124368",
"RevertInvalidNonce": "8831"
}
12 changes: 6 additions & 6 deletions snapshots/ProtocolFeesGasComparisonTest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"ProtocolFeesGasComparisonTest-InterfaceAndProtocolFee": "173684",
"ProtocolFeesGasComparisonTest-InterfaceAndProtocolFeeEthOutput": "162176",
"ProtocolFeesGasComparisonTest-InterfaceFee": "162961",
"ProtocolFeesGasComparisonTest-InterfaceFeeEthOutput": "146288",
"ProtocolFeesGasComparisonTest-NoFees": "146369",
"ProtocolFeesGasComparisonTest-NoFeesEthOutput": "124531"
"ProtocolFeesGasComparisonTest-InterfaceAndProtocolFee": "173378",
"ProtocolFeesGasComparisonTest-InterfaceAndProtocolFeeEthOutput": "161897",
"ProtocolFeesGasComparisonTest-InterfaceFee": "162696",
"ProtocolFeesGasComparisonTest-InterfaceFeeEthOutput": "146041",
"ProtocolFeesGasComparisonTest-NoFees": "146136",
"ProtocolFeesGasComparisonTest-NoFeesEthOutput": "124307"
}
4 changes: 2 additions & 2 deletions snapshots/SwapRouter02ExecutorTest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"SwapRouter02ExecutorExecute": "260669",
"SwapRouter02ExecutorExecuteAlreadyApproved": "118280"
"SwapRouter02ExecutorExecute": "260367",
"SwapRouter02ExecutorExecuteAlreadyApproved": "117992"
}
24 changes: 12 additions & 12 deletions snapshots/V2DutchOrderTest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"BaseExecuteSingleWithFee": "182480",
"ExclusiveFiller": "152632",
"ExecuteBatch": "200865",
"ExecuteBatchMultipleOutputs": "210701",
"ExecuteBatchMultipleOutputsDifferentTokens": "264440",
"ExecuteBatchNativeOutput": "196891",
"ExecuteSingle": "148863",
"ExecuteSingleNativeOutput": "136925",
"ExecuteSingleValidation": "158173",
"InputOverride": "152710",
"OutputOverride": "152659",
"RevertInvalidNonce": "28213"
"BaseExecuteSingleWithFee": "182252",
"ExclusiveFiller": "152472",
"ExecuteBatch": "200564",
"ExecuteBatchMultipleOutputs": "210371",
"ExecuteBatchMultipleOutputsDifferentTokens": "264081",
"ExecuteBatchNativeOutput": "196608",
"ExecuteSingle": "148702",
"ExecuteSingleNativeOutput": "136773",
"ExecuteSingleValidation": "157991",
"InputOverride": "152550",
"OutputOverride": "152499",
"RevertInvalidNonce": "28124"
}
24 changes: 12 additions & 12 deletions snapshots/V3DutchOrderTest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"BaseExecuteSingleWithFee": "192645",
"ExecuteBatch": "221374",
"ExecuteBatchMultipleOutputs": "234559",
"ExecuteBatchMultipleOutputsDifferentTokens": "291665",
"ExecuteBatchNativeOutput": "217400",
"ExecuteSingle": "159027",
"ExecuteSingleNativeOutput": "147089",
"ExecuteSingleValidation": "168337",
"RevertInvalidNonce": "38303",
"V3-ExclusiveFiller": "162895",
"V3-InputOverride": "162976",
"V3-OutputOverride": "162919"
"BaseExecuteSingleWithFee": "192359",
"ExecuteBatch": "220957",
"ExecuteBatchMultipleOutputs": "234094",
"ExecuteBatchMultipleOutputsDifferentTokens": "291152",
"ExecuteBatchNativeOutput": "217001",
"ExecuteSingle": "158808",
"ExecuteSingleNativeOutput": "146879",
"ExecuteSingleValidation": "168097",
"RevertInvalidNonce": "38156",
"V3-ExclusiveFiller": "162677",
"V3-InputOverride": "162758",
"V3-OutputOverride": "162701"
}
8 changes: 7 additions & 1 deletion test/lib/DutchDecayLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ contract DutchDecayLibTest is Test {
assertGe(decayed, uint256(endAmount));
}

/// forge-config: default.allow_internal_expect_revert = true
function testDutchDecayInvalidTimes(
uint256 startAmount,
uint256 endAmount,
Expand All @@ -108,14 +109,19 @@ contract DutchDecayLibTest is Test {
DutchDecayLib.decay(startAmount, endAmount, decayStartTime, decayEndTime);
}

function testDutchDecayOverflow() public {
/// forge-config: default.allow_internal_expect_revert = true
function testDutchDownwardDecayOverflow() public {
vm.expectRevert();
DutchDecayLib.linearDecay(0, 100, 99, type(int256).max, -1);
}

/// forge-config: default.allow_internal_expect_revert = true
function testDutchUpwardDecayOverflow() public {
vm.expectRevert();
DutchDecayLib.linearDecay(0, 100, 99, -1, type(int256).max);
}

/// forge-config: default.allow_internal_expect_revert = true
function testDutchDecayDivByZero() public {
vm.expectRevert();
DutchDecayLib.linearDecay(100, 100, 99, 1, -1);
Expand Down
4 changes: 4 additions & 0 deletions test/lib/MathExt.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ contract MathExtTest is Test {
assertEq(b.sub(int256(a)), b - a);
}

/// forge-config: default.allow_internal_expect_revert = true
function testSubIntFromUintNegativeUint() public {
vm.expectRevert();
uint256(1).sub(int256(2));
}

/// forge-config: default.allow_internal_expect_revert = true
function testSubIntFromUintOverflow() public {
vm.expectRevert();
UINT256_MAX.sub(-1);
Expand Down Expand Up @@ -92,11 +94,13 @@ contract MathExtTest is Test {
assertEq(c, int256(a) - int256(b));
}

/// forge-config: default.allow_internal_expect_revert = true
function testSubUintFromUintUnderflow() public {
vm.expectRevert();
uint256(0).sub(type(uint256).max);
}

/// forge-config: default.allow_internal_expect_revert = true
function testSubUintFromUintOverflow() public {
vm.expectRevert();
UINT256_MAX.sub(uint256(1));
Expand Down
2 changes: 2 additions & 0 deletions test/lib/NonLinearDutchDecayLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ contract NonlinearDutchDecayLibTest is Test, BlockNumberish {
assertEq(decayOutput(curve, startAmount, decayStartBlock, 0 ether), 0);
}

/// forge-config: default.allow_internal_expect_revert = true
function testDutchOverflowDecay() public {
uint256 decayStartBlock = 100;
uint256 startAmount = 1 ether;
Expand All @@ -551,6 +552,7 @@ contract NonlinearDutchDecayLibTest is Test, BlockNumberish {
decayOutput(curve, startAmount, decayStartBlock, 1 ether);
}

/// forge-config: default.allow_internal_expect_revert = true
function testDutchMismatchedDecay() public {
uint256 decayStartBlock = 100;
uint256 startAmount = 1 ether;
Expand Down
2 changes: 2 additions & 0 deletions test/lib/PriorityFeeLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ contract PriorityFeeLibTest is Test {
}

/// @notice if the amount to scale is large enough to cause a phantom overflow in mulDivUp, we expect a revert
/// forge-config: default.allow_internal_expect_revert = true
function testScaleRevertsOnLargeOutput() public {
uint256 priorityFee = 0;
vm.txGasPrice(priorityFee);
Expand Down Expand Up @@ -124,6 +125,7 @@ contract PriorityFeeLibTest is Test {
assertEq(scaledOutput.amount, output.amount);
}

/// forge-config: default.allow_internal_expect_revert = true
function testScaleOutputPriorityFee_fuzz(uint256 priorityFee, uint256 mpsPerPriorityFeeWei) public {
// the amount of MPS to scale the output by
uint256 scalingFactor = MPS;
Expand Down
2 changes: 2 additions & 0 deletions test/lib/Uint16Array.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ contract Uint16ArrayTest is Test {
}
}

/// forge-config: default.allow_internal_expect_revert = true
function testToUint16ArrayRevert() public {
vm.expectRevert(InvalidArrLength.selector);
toUint16Array(ArrayBuilder.fillUint16(17, 1));
}

/// forge-config: default.allow_internal_expect_revert = true
function testGetElementRevert() public {
Uint16Array packedArr = toUint16Array(ArrayBuilder.fillUint16(5, 1));
vm.expectRevert(IndexOutOfBounds.selector);
Expand Down

0 comments on commit 5016e3d

Please sign in to comment.