Skip to content

Commit 4a0f436

Browse files
committed
test
1 parent 59c094b commit 4a0f436

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

test/Client.t.sol

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ contract ClientTest is Test {
228228
amount: CommonTypes.BigInt({
229229
val: hex"010000000000000000000000000000000000000000000000000000000000000000", neg: false
230230
}),
231-
operator_data: hex"8282861903E8D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001A0007E9001A00503340190131861903E8D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001A0007E9001A0050334019013180"
231+
operator_data: hex"8282861903E8D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001B00000078B30C40001A00503340190131861903E8D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001A0007E9001A0050334019013180"
232232
});
233233
vm.prank(clientAddress);
234234
vm.expectRevert(abi.encodeWithSelector(Client.InvalidAmount.selector));
@@ -261,19 +261,28 @@ contract ClientTest is Test {
261261
}
262262

263263
function testTransferRevertInsufficientAllowance() public {
264+
resolveAddress.setId(address(this), uint64(20000));
265+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
266+
264267
vm.prank(clientAddress);
265268
vm.expectRevert(abi.encodeWithSelector(Client.InsufficientAllowance.selector));
266269
client.transfer(transferParams);
267270
}
268271

269272
function testClientCanCallTransfer() public {
273+
resolveAddress.setId(address(this), uint64(20000));
274+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
275+
270276
vm.prank(allocator);
271277
client.increaseAllowance(clientAddress, SP2, 4096);
272278
vm.prank(clientAddress);
273279
client.transfer(transferParams);
274280
}
275281

276282
function testVerifregFailIsDetected() public {
283+
resolveAddress.setId(address(this), uint64(20000));
284+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
285+
277286
vm.prank(allocator);
278287
client.increaseAllowance(clientAddress, SP2, 4096);
279288
vm.etch(CALL_ACTOR_ID, address(builtInActorForTransferFunctionMock).code);
@@ -283,6 +292,9 @@ contract ClientTest is Test {
283292
}
284293

285294
function testCheckAllowanceAfterTransfer() public {
295+
resolveAddress.setId(address(this), uint64(20000));
296+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
297+
286298
vm.prank(allocator);
287299
client.increaseAllowance(clientAddress, SP2, 4096);
288300
vm.prank(clientAddress);
@@ -292,7 +304,7 @@ contract ClientTest is Test {
292304

293305
function testClaimExtensionNonExistent() public {
294306
// 0 success_count
295-
resolveAddress.setId(uint64(20000));
307+
resolveAddress.setId(address(this), uint64(20000));
296308
actorIdMock.setGetClaimsResult(hex"8282008080");
297309
transferParams.operator_data = hex"82808183194E20011A005034AC";
298310
vm.prank(clientAddress);
@@ -304,7 +316,8 @@ contract ClientTest is Test {
304316
// params taken directly from `boost extend-deal` message
305317
// no allocations
306318
// 1 extension for provider 20000 and claim id 1
307-
resolveAddress.setId(uint64(20000));
319+
resolveAddress.setId(address(this), uint64(20000));
320+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
308321
vm.prank(allocator);
309322
client.increaseAllowance(clientAddress, SP2, 4096);
310323
transferParams.operator_data = hex"82808183194E20011A005034AC";
@@ -349,6 +362,8 @@ contract ClientTest is Test {
349362
}
350363

351364
function testSPClientsMappingUpdateAllocations() public {
365+
resolveAddress.setId(address(this), uint64(20000));
366+
resolveAddress.setAddress(hex"00c2a101", uint64(20000));
352367
vm.prank(allocator);
353368
client.increaseAllowance(clientAddress, SP2, 4096);
354369

@@ -380,4 +395,37 @@ contract ClientTest is Test {
380395
assertEq(afterTransfer[0].client, clientAddress);
381396
assertEq(afterTransfer[0].usage, 2048);
382397
}
398+
399+
function testTransferRevertNoAllocationOrClaim() public {
400+
resolveAddress.setId(address(this), uint64(20000));
401+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
402+
transferParams.operator_data = hex"828080";
403+
vm.prank(clientAddress);
404+
vm.expectRevert(abi.encodeWithSelector(Client.NoAllocationOrClaim.selector));
405+
client.transfer(transferParams);
406+
}
407+
408+
function testTransferRevertInsufficientBeneficiaryExpiration() public {
409+
resolveAddress.setId(address(this), uint64(20000));
410+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
411+
transferParams.operator_data =
412+
hex"828286194E20D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001B00000078B30C40001B000004C7C203500019013186194E20D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001A0007E90019020D19013180";
413+
vm.prank(clientAddress);
414+
vm.expectRevert(
415+
abi.encodeWithSelector(Client.InsufficientBeneficiaryExpiration.selector, SP2, 6000000, 5256000000305)
416+
);
417+
client.transfer(transferParams);
418+
}
419+
420+
function testTransferRevertInsufficientExpirationForClaimExtension() public {
421+
resolveAddress.setId(address(this), uint64(20000));
422+
resolveAddress.setAddress(hex"00C2A101", uint64(20000));
423+
transferParams.operator_data =
424+
hex"828286194E20D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001B00000078B30C40001B000004C7C203500019013186194E20D82A5828000181E203922020F2B9A58BBC9D9856E52EAB85155C1BA298F7E8DF458BD20A3AD767E11572CA221908001A0007E9001B000004C7C203500019013180";
425+
vm.prank(clientAddress);
426+
vm.expectRevert(
427+
abi.encodeWithSelector(Client.InsufficientBeneficiaryExpiration.selector, SP2, 6000000, 5256000000305)
428+
);
429+
client.transfer(transferParams);
430+
}
383431
}

0 commit comments

Comments
 (0)