Skip to content

Commit

Permalink
Merge branch 'development' into l-06-improve-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
marktoda committed Aug 22, 2023
2 parents e327540 + 046fc20 commit d018056
Show file tree
Hide file tree
Showing 37 changed files with 55 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150745
181972
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
196879
196867
Original file line number Diff line number Diff line change
@@ -1 +1 @@
206650
206635
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260307
260289
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190411
190399
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148194
148188
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133756
133750
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157505
157499
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150961
150955
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197273
197261
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207039
207024
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260710
260692
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190799
190787
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148401
148395
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133968
133962
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157716
157710
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146554
146882
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroSingleOrder.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136213
136207
Original file line number Diff line number Diff line change
@@ -1 +1 @@
175064
175055
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth1Output.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147390
147384
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth2Outputs.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170604
170592
Original file line number Diff line number Diff line change
@@ -1 +1 @@
435187
435160
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTwoOrders.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
255972
255957
Original file line number Diff line number Diff line change
@@ -1 +1 @@
363478
363457
2 changes: 1 addition & 1 deletion .forge-snapshots/EthOutputTestEthOutput.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156223
156217
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176915
176906
Original file line number Diff line number Diff line change
@@ -1 +1 @@
162907
162898
Original file line number Diff line number Diff line change
@@ -1 +1 @@
166046
166037
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146873
146864
2 changes: 1 addition & 1 deletion .forge-snapshots/ProtocolFeesGasComparisonTest-NoFees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149267
149261
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124929
124923
2 changes: 1 addition & 1 deletion .forge-snapshots/SwapRouter02ExecutorExecute.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
262973
262967
Original file line number Diff line number Diff line change
@@ -1 +1 @@
118092
118086
2 changes: 1 addition & 1 deletion .forge-snapshots/testExclusiveFillerSucceeds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174066
174060
2 changes: 1 addition & 1 deletion src/lib/DutchDecayLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library DutchDecayLib {
view
returns (uint256 decayedAmount)
{
if (decayEndTime < decayStartTime) {
if (decayEndTime <= decayStartTime) {
revert EndTimeBeforeStartTime();
} else if (decayEndTime <= block.timestamp) {
decayedAmount = endAmount;
Expand Down
6 changes: 3 additions & 3 deletions test/lib/DutchDecayLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {DutchDecayLib} from "../../src/lib/DutchDecayLib.sol";

contract DutchDecayLibTest is Test {
function testDutchDecayNoDecay(uint256 amount, uint256 decayStartTime, uint256 decayEndTime) public {
vm.assume(decayEndTime >= decayStartTime);
vm.assume(decayEndTime > decayStartTime);
assertEq(DutchDecayLib.decay(amount, amount, decayStartTime, decayEndTime), amount);
}

Expand Down Expand Up @@ -78,7 +78,7 @@ contract DutchDecayLibTest is Test {
public
{
vm.assume(endAmount > startAmount);
vm.assume(decayEndTime >= decayStartTime);
vm.assume(decayEndTime > decayStartTime);
uint256 decayed = DutchDecayLib.decay(startAmount, endAmount, decayStartTime, decayEndTime);
assertGe(decayed, startAmount);
assertLe(decayed, endAmount);
Expand All @@ -91,7 +91,7 @@ contract DutchDecayLibTest is Test {
uint256 decayEndTime
) public {
vm.assume(endAmount < startAmount);
vm.assume(decayEndTime >= decayStartTime);
vm.assume(decayEndTime > decayStartTime);
uint256 decayed = DutchDecayLib.decay(startAmount, endAmount, decayStartTime, decayEndTime);
assertLe(decayed, startAmount);
assertGe(decayed, endAmount);
Expand Down
19 changes: 17 additions & 2 deletions test/reactors/DutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,28 @@ contract DutchOrderReactorValidationTest is Test, DeployPermit2 {
reactor.resolveOrder(SignedOrder(abi.encode(dlo), sig));
}

function testValidateDutchEndTimeAfterStart() public view {
function testValidateDutchEndTimeEqualStart() public {
vm.expectRevert(DutchDecayLib.EndTimeBeforeStartTime.selector);
DutchOutput[] memory dutchOutputs = new DutchOutput[](1);
dutchOutputs[0] = DutchOutput(address(0), 1000, 900, address(0));
DutchOrder memory dlo = DutchOrder(
OrderInfoBuilder.init(address(reactor)).withDeadline(1659130540),
1659120540,
1659130540,
1659130540,
DutchInput(MockERC20(address(0)), 0, 0),
dutchOutputs
);
bytes memory sig = hex"1234";
reactor.resolveOrder(SignedOrder(abi.encode(dlo), sig));
}

function testValidateDutchEndTimeAfterStart() public view {
DutchOutput[] memory dutchOutputs = new DutchOutput[](1);
dutchOutputs[0] = DutchOutput(address(0), 1000, 900, address(0));
DutchOrder memory dlo = DutchOrder(
OrderInfoBuilder.init(address(reactor)).withDeadline(1659130541),
1659120540,
1659130541,
DutchInput(MockERC20(address(0)), 0, 0),
dutchOutputs
);
Expand Down

0 comments on commit d018056

Please sign in to comment.