Skip to content

Commit e954cd8

Browse files
PaulRBergandreivladbrg
authored andcommitted
test: refactor batch tests (#355)
1 parent 9c00c12 commit e954cd8

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

Diff for: tests/integration/concrete/batch/batch.t.sol

+37-35
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
2727
//////////////////////////////////////////////////////////////////////////*/
2828

2929
function test_RevertWhen_CustomError() external {
30-
// The calls declared as bytes
30+
// The calls declared as bytes.
3131
bytes[] memory calls = new bytes[](1);
3232
calls[0] = abi.encodeCall(flow.withdrawMax, (1, users.recipient));
3333

@@ -51,7 +51,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
5151
address noAllowanceAddress = address(0xBEEF);
5252
resetPrank({ msgSender: noAllowanceAddress });
5353

54-
// The calls declared as bytes
54+
// The calls declared as bytes.
5555
bytes[] memory calls = new bytes[](1);
5656
calls[0] = abi.encodeCall(flow.deposit, (streamId, DEPOSIT_AMOUNT_6D, users.sender, users.recipient));
5757

@@ -78,7 +78,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
7878
}
7979

8080
/*//////////////////////////////////////////////////////////////////////////
81-
ADJUST-RATE-PER-SECOND-MULTIPLE
81+
ADJUST-RATE-PER-SECOND
8282
//////////////////////////////////////////////////////////////////////////*/
8383

8484
function test_Batch_AdjustRatePerSecond() external {
@@ -122,22 +122,22 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
122122
}
123123

124124
/*//////////////////////////////////////////////////////////////////////////
125-
CREATE-MULTIPLE
125+
CREATE
126126
//////////////////////////////////////////////////////////////////////////*/
127127

128-
function test_Batch_CreateMultiple() external {
128+
function test_Batch_Create() external {
129129
uint256[] memory expectedStreamIds = new uint256[](2);
130130
expectedStreamIds[0] = flow.nextStreamId();
131-
expectedStreamIds[1] = expectedStreamIds[0] + 1;
131+
expectedStreamIds[1] = flow.nextStreamId() + 1;
132132

133-
// The calls declared as bytes
133+
// The calls declared as bytes.
134134
bytes[] memory calls = new bytes[](2);
135135
calls[0] = abi.encodeCall(flow.create, (users.sender, users.recipient, RATE_PER_SECOND, usdc, TRANSFERABLE));
136136
calls[1] = abi.encodeCall(flow.create, (users.sender, users.recipient, RATE_PER_SECOND, usdc, TRANSFERABLE));
137137

138-
// It should emit events: 2 {MetadataUpdate}, 2 {CreateFlowStream}
138+
// It should emit 2 {MetadataUpdate} and 2 {CreateFlowStream} events.
139139

140-
// First stream to create
140+
// First stream to create.
141141
vm.expectEmit({ emitter: address(flow) });
142142
emit IERC4906.MetadataUpdate({ _tokenId: expectedStreamIds[0] });
143143

@@ -151,7 +151,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
151151
transferable: TRANSFERABLE
152152
});
153153

154-
// Second stream to create
154+
// Second stream to create.
155155
vm.expectEmit({ emitter: address(flow) });
156156
emit IERC4906.MetadataUpdate({ _tokenId: expectedStreamIds[1] });
157157

@@ -170,18 +170,18 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
170170
}
171171

172172
/*//////////////////////////////////////////////////////////////////////////
173-
DEPOSIT-MULTIPLE
173+
DEPOSIT
174174
//////////////////////////////////////////////////////////////////////////*/
175175

176-
function test_Batch_DepositMultiple() external {
177-
// The calls declared as bytes
176+
function test_Batch_Deposit() external {
177+
// The calls declared as bytes.
178178
bytes[] memory calls = new bytes[](2);
179179
calls[0] = abi.encodeCall(flow.deposit, (defaultStreamIds[0], DEPOSIT_AMOUNT_6D, users.sender, users.recipient));
180180
calls[1] = abi.encodeCall(flow.deposit, (defaultStreamIds[1], DEPOSIT_AMOUNT_6D, users.sender, users.recipient));
181181

182182
// It should emit 2 {Transfer}, 2 {DepositFlowStream}, 2 {MetadataUpdate} events.
183183

184-
// First stream to deposit
184+
// First stream to deposit.
185185
vm.expectEmit({ emitter: address(usdc) });
186186
emit IERC20.Transfer({ from: users.sender, to: address(flow), value: DEPOSIT_AMOUNT_6D });
187187

@@ -195,7 +195,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
195195
vm.expectEmit({ emitter: address(flow) });
196196
emit IERC4906.MetadataUpdate({ _tokenId: defaultStreamIds[0] });
197197

198-
// Second stream to deposit
198+
// Second stream to deposit.
199199
vm.expectEmit({ emitter: address(usdc) });
200200
emit IERC20.Transfer({ from: users.sender, to: address(flow), value: DEPOSIT_AMOUNT_6D });
201201

@@ -218,21 +218,21 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
218218
}
219219

220220
/*//////////////////////////////////////////////////////////////////////////
221-
PAUSE-MULTIPLE
221+
PAUSE
222222
//////////////////////////////////////////////////////////////////////////*/
223223

224-
function test_Batch_PauseMultiple() external {
225-
// The calls declared as bytes
224+
function test_Batch_Pause() external {
225+
// The calls declared as bytes.
226226
bytes[] memory calls = new bytes[](2);
227227
calls[0] = abi.encodeCall(flow.pause, (defaultStreamIds[0]));
228228
calls[1] = abi.encodeCall(flow.pause, (defaultStreamIds[1]));
229229

230230
uint256 previousTotalDebt0 = flow.totalDebtOf(defaultStreamId);
231231
uint256 previousTotalDebt1 = flow.totalDebtOf(defaultStreamIds[1]);
232232

233-
// It should emit 2 {PauseFlowStream}, 2 {MetadataUpdate} events.
233+
// It should emit 2 {PauseFlowStream} and 2 {MetadataUpdate} events.
234234

235-
// First stream pause
235+
// First stream pause.
236236
vm.expectEmit({ emitter: address(flow) });
237237
emit ISablierFlow.PauseFlowStream({
238238
streamId: defaultStreamIds[0],
@@ -244,7 +244,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
244244
vm.expectEmit({ emitter: address(flow) });
245245
emit IERC4906.MetadataUpdate({ _tokenId: defaultStreamIds[0] });
246246

247-
// Second stream pause
247+
// Second stream pause.
248248
vm.expectEmit({ emitter: address(flow) });
249249
emit ISablierFlow.PauseFlowStream({
250250
streamId: defaultStreamIds[1],
@@ -261,19 +261,21 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
261261
}
262262

263263
/*//////////////////////////////////////////////////////////////////////////
264-
REFUND-MULTIPLE
264+
REFUND
265265
//////////////////////////////////////////////////////////////////////////*/
266266

267-
function test_Batch_RefundMultiple() external {
267+
function test_Batch_Refund() external {
268268
depositDefaultAmount(defaultStreamIds[0]);
269269
depositDefaultAmount(defaultStreamIds[1]);
270270

271-
// The calls declared as bytes
271+
// The calls declared as bytes.
272272
bytes[] memory calls = new bytes[](2);
273273
calls[0] = abi.encodeCall(flow.refund, (defaultStreamIds[0], REFUND_AMOUNT_6D));
274274
calls[1] = abi.encodeCall(flow.refund, (defaultStreamIds[1], REFUND_AMOUNT_6D));
275275

276276
// It should emit 2 {Transfer} and 2 {RefundFromFlowStream} events.
277+
278+
// First stream refund.
277279
vm.expectEmit({ emitter: address(usdc) });
278280
emit IERC20.Transfer({ from: address(flow), to: users.sender, value: REFUND_AMOUNT_6D });
279281

@@ -284,7 +286,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
284286
amount: REFUND_AMOUNT_6D
285287
});
286288

287-
// Second stream refund
289+
// Second stream refund.
288290
vm.expectEmit({ emitter: address(usdc) });
289291
emit IERC20.Transfer({ from: address(flow), to: users.sender, value: REFUND_AMOUNT_6D });
290292

@@ -304,21 +306,21 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
304306
}
305307

306308
/*//////////////////////////////////////////////////////////////////////////
307-
RESTART-MULTIPLE
309+
RESTART
308310
//////////////////////////////////////////////////////////////////////////*/
309311

310-
function test_Batch_RestartMultiple() external {
312+
function test_Batch_Restart() external {
311313
flow.pause({ streamId: defaultStreamIds[0] });
312314
flow.pause({ streamId: defaultStreamIds[1] });
313315

314-
// The calls declared as bytes
316+
// The calls declared as bytes.
315317
bytes[] memory calls = new bytes[](2);
316318
calls[0] = abi.encodeCall(flow.restart, (defaultStreamIds[0], RATE_PER_SECOND));
317319
calls[1] = abi.encodeCall(flow.restart, (defaultStreamIds[1], RATE_PER_SECOND));
318320

319321
// It should emit 2 {RestartFlowStream} and 2 {MetadataUpdate} events.
320322

321-
// First stream restart
323+
// First stream restart.
322324
vm.expectEmit({ emitter: address(flow) });
323325
emit ISablierFlow.RestartFlowStream({
324326
streamId: defaultStreamIds[0],
@@ -329,7 +331,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
329331
vm.expectEmit({ emitter: address(flow) });
330332
emit IERC4906.MetadataUpdate({ _tokenId: defaultStreamIds[0] });
331333

332-
// Second stream restart
334+
// Second stream restart.
333335
vm.expectEmit({ emitter: address(flow) });
334336
emit ISablierFlow.RestartFlowStream({
335337
streamId: defaultStreamIds[1],
@@ -345,21 +347,21 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
345347
}
346348

347349
/*//////////////////////////////////////////////////////////////////////////
348-
WITHDRAW-MULTIPLE
350+
WITHDRAW
349351
//////////////////////////////////////////////////////////////////////////*/
350352

351-
function test_Batch_WithdrawMultiple() external {
353+
function test_Batch_Withdraw() external {
352354
depositDefaultAmount(defaultStreamIds[0]);
353355
depositDefaultAmount(defaultStreamIds[1]);
354356

355-
// The calls declared as bytes
357+
// The calldata encoded as a bytes array.
356358
bytes[] memory calls = new bytes[](2);
357359
calls[0] = abi.encodeCall(flow.withdraw, (defaultStreamIds[0], users.recipient, WITHDRAW_AMOUNT_6D));
358360
calls[1] = abi.encodeCall(flow.withdraw, (defaultStreamIds[1], users.recipient, WITHDRAW_AMOUNT_6D));
359361

360362
// It should emit 2 {Transfer}, 2 {WithdrawFromFlowStream} and 2 {MetadataUpdated} events.
361363

362-
// First stream withdraw
364+
// First stream withdrawal.
363365
vm.expectEmit({ emitter: address(usdc) });
364366
emit IERC20.Transfer({ from: address(flow), to: users.recipient, value: WITHDRAW_AMOUNT_6D });
365367

@@ -376,7 +378,7 @@ contract Batch_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
376378
vm.expectEmit({ emitter: address(flow) });
377379
emit IERC4906.MetadataUpdate({ _tokenId: defaultStreamIds[0] });
378380

379-
// Second stream withdraw
381+
// Second stream withdrawal.
380382
vm.expectEmit({ emitter: address(usdc) });
381383
emit IERC20.Transfer({ from: address(flow), to: users.recipient, value: WITHDRAW_AMOUNT_6D });
382384

0 commit comments

Comments
 (0)