Skip to content

Commit fcc9d2f

Browse files
committed
chore: forge fmt test
1 parent dc3cd7c commit fcc9d2f

File tree

5 files changed

+149
-265
lines changed

5 files changed

+149
-265
lines changed

test/AsyncFillerTest.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ contract AsyncFillerTest is SetupHook {
213213
uint256 swapAmount1 = 1000;
214214
uint256 swapAmount2 = 800;
215215
address testUser2 = makeAddr("testUser2");
216-
216+
217217
topUp(testUser2, swapAmount2);
218218

219219
// Create first async order and set router as executor
@@ -240,7 +240,7 @@ contract AsyncFillerTest is SetupHook {
240240

241241
vm.startPrank(testExecutor);
242242
token1.approve(address(router), swapAmount1 + swapAmount2);
243-
243+
244244
router.fillOrder(fillOrder1, abi.encode(address(router)));
245245
router.fillOrder(fillOrder2, abi.encode(address(router)));
246246
vm.stopPrank();

test/AsyncSwapEdgeCases.t.sol

Lines changed: 53 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
pragma solidity ^0.8.13;
33

44
import { SetupHook } from "./SetupHook.t.sol";
5+
6+
import { AsyncSwap } from "@async-swap/AsyncSwap.sol";
7+
import { AsyncFiller } from "@async-swap/libraries/AsyncFiller.sol";
58
import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol";
69
import { Currency } from "v4-core/interfaces/IPoolManager.sol";
7-
import { CurrencyLibrary } from "v4-core/types/Currency.sol";
810
import { IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
11+
import { Hooks } from "v4-core/libraries/Hooks.sol";
912
import { LPFeeLibrary } from "v4-core/libraries/LPFeeLibrary.sol";
13+
import { CurrencyLibrary } from "v4-core/types/Currency.sol";
1014
import { PoolKey } from "v4-core/types/PoolKey.sol";
11-
import { AsyncSwap } from "@async-swap/AsyncSwap.sol";
12-
import { AsyncFiller } from "@async-swap/libraries/AsyncFiller.sol";
13-
import { Hooks } from "v4-core/libraries/Hooks.sol";
1415

1516
contract AsyncSwapEdgeCasesTest is SetupHook {
1617

@@ -31,12 +32,8 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
3132
}
3233

3334
function testUnsupportedLiquidityRevert() public {
34-
IPoolManager.ModifyLiquidityParams memory params = IPoolManager.ModifyLiquidityParams({
35-
tickLower: -60,
36-
tickUpper: 60,
37-
liquidityDelta: 1000,
38-
salt: 0x0
39-
});
35+
IPoolManager.ModifyLiquidityParams memory params =
36+
IPoolManager.ModifyLiquidityParams({ tickLower: -60, tickUpper: 60, liquidityDelta: 1000, salt: 0x0 });
4037

4138
// The manager is locked so any call will fail, but this tests the path
4239
vm.expectRevert(); // Just expect any revert
@@ -55,23 +52,18 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
5552

5653
function testAsyncOrderView() public {
5754
uint256 swapAmount = 1000;
58-
55+
5956
// Initially should be 0
6057
uint256 initialClaimable = hook.asyncOrder(poolId, testUser, true);
6158
assertEq(initialClaimable, 0);
62-
59+
6360
// Create async order
6461
vm.startPrank(testUser);
6562
token0.approve(address(router), swapAmount);
66-
67-
AsyncOrder memory swapOrder = AsyncOrder({
68-
key: key,
69-
owner: testUser,
70-
zeroForOne: true,
71-
amountIn: swapAmount,
72-
sqrtPrice: 2 ** 96
73-
});
74-
63+
64+
AsyncOrder memory swapOrder =
65+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: swapAmount, sqrtPrice: 2 ** 96 });
66+
7567
router.swap(swapOrder, abi.encode(testUser, address(router)));
7668
vm.stopPrank();
7769

@@ -84,19 +76,14 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
8476
// Initially should be false
8577
bool initialExecutor = hook.isExecutor(poolId, testUser, testExecutor);
8678
assertFalse(initialExecutor);
87-
79+
8880
// Create async order which sets executor
8981
vm.startPrank(testUser);
9082
token0.approve(address(router), 1000);
91-
92-
AsyncOrder memory swapOrder = AsyncOrder({
93-
key: key,
94-
owner: testUser,
95-
zeroForOne: true,
96-
amountIn: 1000,
97-
sqrtPrice: 2 ** 96
98-
});
99-
83+
84+
AsyncOrder memory swapOrder =
85+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: 1000, sqrtPrice: 2 ** 96 });
86+
10087
router.swap(swapOrder, abi.encode(testUser, address(router)));
10188
vm.stopPrank();
10289

@@ -108,8 +95,8 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
10895
function testBeforeSwapExactOutputRevert() public {
10996
vm.startPrank(testUser);
11097
token0.approve(address(router), 1000);
111-
112-
// Try to create exact output swap (positive amountSpecified)
98+
99+
// Try to create exact output swap (positive amountSpecified)
113100
// This should revert at hook level but we need to use router
114101
AsyncOrder memory order = AsyncOrder({
115102
key: key,
@@ -123,19 +110,14 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
123110
// But this is hard to test directly, so let's just test that normal swaps work
124111
router.swap(order, abi.encode(testUser, address(router)));
125112
vm.stopPrank();
126-
113+
127114
// Verify the swap worked (it should because we're passing negative amount)
128115
assertEq(hook.asyncOrder(poolId, testUser, true), 500);
129116
}
130117

131118
function testExecuteOrderZeroAmountRevert() public {
132-
AsyncOrder memory order = AsyncOrder({
133-
key: key,
134-
owner: testUser,
135-
zeroForOne: true,
136-
amountIn: 0,
137-
sqrtPrice: 2 ** 96
138-
});
119+
AsyncOrder memory order =
120+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: 0, sqrtPrice: 2 ** 96 });
139121

140122
vm.expectRevert(AsyncFiller.ZeroFillOrder.selector);
141123
hook.executeOrder(order, "");
@@ -144,24 +126,19 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
144126
function testExecuteOrdersMultiple() public {
145127
uint256 orderCount = 3;
146128
uint256 amountPerOrder = 500;
147-
129+
148130
// Setup user balances
149131
topUp(testUser, orderCount * amountPerOrder);
150132
topUp(testExecutor, orderCount * amountPerOrder);
151-
133+
152134
// Create multiple async orders first
153-
for (uint i = 0; i < orderCount; i++) {
135+
for (uint256 i = 0; i < orderCount; i++) {
154136
vm.startPrank(testUser);
155137
token0.approve(address(router), amountPerOrder);
156-
157-
AsyncOrder memory swapOrder = AsyncOrder({
158-
key: key,
159-
owner: testUser,
160-
zeroForOne: true,
161-
amountIn: amountPerOrder,
162-
sqrtPrice: 2 ** 96
163-
});
164-
138+
139+
AsyncOrder memory swapOrder =
140+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: amountPerOrder, sqrtPrice: 2 ** 96 });
141+
165142
router.swap(swapOrder, abi.encode(testUser, address(router)));
166143
vm.stopPrank();
167144
}
@@ -172,25 +149,15 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
172149

173150
// Execute orders in batch
174151
AsyncOrder[] memory orders = new AsyncOrder[](orderCount);
175-
for (uint i = 0; i < orderCount; i++) {
176-
orders[i] = AsyncOrder({
177-
key: key,
178-
owner: testUser,
179-
zeroForOne: true,
180-
amountIn: amountPerOrder,
181-
sqrtPrice: 2 ** 96
182-
});
152+
for (uint256 i = 0; i < orderCount; i++) {
153+
orders[i] =
154+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: amountPerOrder, sqrtPrice: 2 ** 96 });
183155
}
184156

185-
// Execute orders one by one using router
186-
for (uint i = 0; i < orderCount; i++) {
187-
AsyncOrder memory fillOrder = AsyncOrder({
188-
key: key,
189-
owner: testUser,
190-
zeroForOne: true,
191-
amountIn: amountPerOrder,
192-
sqrtPrice: 2 ** 96
193-
});
157+
// Execute orders one by one using router
158+
for (uint256 i = 0; i < orderCount; i++) {
159+
AsyncOrder memory fillOrder =
160+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: amountPerOrder, sqrtPrice: 2 ** 96 });
194161

195162
vm.startPrank(testExecutor);
196163
token1.approve(address(router), amountPerOrder);
@@ -205,18 +172,13 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
205172

206173
function testHookSwapEventEmission() public {
207174
uint256 swapAmount = 1000;
208-
175+
209176
vm.startPrank(testUser);
210177
token0.approve(address(router), swapAmount);
211-
212-
AsyncOrder memory swapOrder = AsyncOrder({
213-
key: key,
214-
owner: testUser,
215-
zeroForOne: true,
216-
amountIn: swapAmount,
217-
sqrtPrice: 2 ** 96
218-
});
219-
178+
179+
AsyncOrder memory swapOrder =
180+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: swapAmount, sqrtPrice: 2 ** 96 });
181+
220182
vm.expectEmit(true, true, false, true);
221183
emit AsyncSwap.HookSwap(
222184
bytes32(uint256(keccak256(abi.encode(key)))),
@@ -226,25 +188,25 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
226188
0,
227189
0
228190
);
229-
191+
230192
router.swap(swapOrder, abi.encode(testUser, address(router)));
231193
vm.stopPrank();
232194
}
233195

234196
function testZeroForOneFalseDirection() public {
235197
uint256 swapAmount = 1000;
236-
198+
237199
vm.startPrank(testUser);
238200
token1.approve(address(router), swapAmount);
239-
201+
240202
AsyncOrder memory swapOrder = AsyncOrder({
241203
key: key,
242204
owner: testUser,
243205
zeroForOne: false, // currency1 to currency0
244206
amountIn: swapAmount,
245207
sqrtPrice: 2 ** 96
246208
});
247-
209+
248210
router.swap(swapOrder, abi.encode(testUser, address(router)));
249211
vm.stopPrank();
250212

@@ -292,26 +254,21 @@ contract AsyncSwapEdgeCasesTest is SetupHook {
292254
function testFuzzDifferentAmounts(uint256 amount) public {
293255
vm.assume(amount > 0);
294256
vm.assume(amount <= 10 ether);
295-
257+
296258
topUp(testUser, amount);
297259
topUp(testExecutor, amount);
298-
260+
299261
vm.startPrank(testUser);
300262
token0.approve(address(router), amount);
301-
302-
AsyncOrder memory swapOrder = AsyncOrder({
303-
key: key,
304-
owner: testUser,
305-
zeroForOne: true,
306-
amountIn: amount,
307-
sqrtPrice: 2 ** 96
308-
});
309-
263+
264+
AsyncOrder memory swapOrder =
265+
AsyncOrder({ key: key, owner: testUser, zeroForOne: true, amountIn: amount, sqrtPrice: 2 ** 96 });
266+
310267
router.swap(swapOrder, abi.encode(testUser, address(router)));
311268
vm.stopPrank();
312269

313270
uint256 claimableAmount = hook.asyncOrder(poolId, testUser, true);
314271
assertEq(claimableAmount, amount);
315272
}
316273

317-
}
274+
}

test/BaseAlgorithmTest.t.sol

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
77

88
// Mock implementation for testing BaseAlgorithm
99
contract MockAlgorithm is BaseAlgorithm {
10-
11-
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) {}
10+
11+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
1212

1313
function name() external pure override returns (string memory) {
1414
return "MockAlgorithm";
@@ -22,6 +22,7 @@ contract MockAlgorithm is BaseAlgorithm {
2222
// Mock implementation - just emit an event or do nothing
2323
// This allows us to test the BaseAlgorithm functionality
2424
}
25+
2526
}
2627

2728
contract BaseAlgorithmTest is SetupHook {
@@ -100,36 +101,36 @@ contract BaseAlgorithmTest is SetupHook {
100101

101102
// Test contract for BaseAlgorithm without overrides
102103
contract UnimplementedAlgorithm is BaseAlgorithm {
103-
104-
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) {}
105-
104+
105+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
106+
106107
// Don't override the virtual functions to test base revert behavior
108+
107109
}
108110

109111
contract BaseAlgorithmUnimplementedTest is SetupHook {
110-
112+
111113
UnimplementedAlgorithm unimplementedAlgorithm;
112-
114+
113115
function setUp() public override {
114116
super.setUp();
115117
unimplementedAlgorithm = new UnimplementedAlgorithm(address(hook));
116118
}
117-
119+
118120
function testNameNotImplemented() public {
119121
vm.expectRevert("BaseAlgorithm: Not implemented");
120122
unimplementedAlgorithm.name();
121123
}
122-
124+
123125
function testVersionNotImplemented() public {
124126
vm.expectRevert("BaseAlgorithm: Not implemented");
125127
unimplementedAlgorithm.version();
126128
}
127-
129+
128130
function testOrderingRuleNotImplemented() public {
129131
vm.prank(address(hook));
130132
vm.expectRevert("BaseAlgorithm: Ordering rule not implemented!");
131133
unimplementedAlgorithm.orderingRule(true, 1000);
132134
}
133-
134135

135-
}
136+
}

test/CLVRTest.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
pragma solidity ^0.8.13;
33

44
import { SetupHook } from "./SetupHook.t.sol";
5+
6+
import { BaseAlgorithm } from "@async-swap/algorithms/BaseAlgorithm.sol";
57
import { CLVR } from "@async-swap/algorithms/clvr.sol";
68
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
7-
import { BaseAlgorithm } from "@async-swap/algorithms/BaseAlgorithm.sol";
89

910
contract CLVRTest is SetupHook {
1011

@@ -68,4 +69,4 @@ contract CLVRTest is SetupHook {
6869
assertTrue(clvrAlgorithm.HOOKADDRESS() == address(hook));
6970
}
7071

71-
}
72+
}

0 commit comments

Comments
 (0)