@@ -6,19 +6,32 @@ import "forge-std/Test.sol";
6
6
import { GraphEscrowTest } from "./GraphEscrow.t.sol " ;
7
7
8
8
contract GraphEscrowThawTest is GraphEscrowTest {
9
-
10
9
/*
11
10
* TESTS
12
11
*/
13
12
14
13
function testThaw_Tokens (uint256 amount ) public useGateway useDeposit (amount) {
14
+ amount = bound (amount, 1 , type (uint256 ).max);
15
15
_thawEscrow (users.verifier, users.indexer, amount);
16
16
}
17
17
18
- function testThaw_RevertWhen_InsufficientThawAmount (
19
- uint256 amount
20
- ) public useGateway useDeposit (amount) {
21
- bytes memory expectedError = abi.encodeWithSignature ("PaymentsEscrowNotThawing() " );
18
+ function testThaw_Tokens_SuccesiveCalls (uint256 amount ) public useGateway {
19
+ amount = bound (amount, 2 , type (uint256 ).max - 10 );
20
+ _depositTokens (users.verifier, users.indexer, amount);
21
+
22
+ uint256 firstAmountToThaw = (amount + 2 - 1 ) / 2 ;
23
+ uint256 secondAmountToThaw = (amount + 10 - 1 ) / 10 ;
24
+ _thawEscrow (users.verifier, users.indexer, firstAmountToThaw);
25
+ _thawEscrow (users.verifier, users.indexer, secondAmountToThaw);
26
+
27
+ (, address msgSender , ) = vm.readCallers ();
28
+ (, uint256 amountThawing , uint256 thawEndTimestamp ) = escrow.escrowAccounts (msgSender, users.verifier, users.indexer);
29
+ assertEq (amountThawing, secondAmountToThaw);
30
+ assertEq (thawEndTimestamp, block .timestamp + withdrawEscrowThawingPeriod);
31
+ }
32
+
33
+ function testThaw_Tokens_RevertWhen_AmountIsZero () public useGateway {
34
+ bytes memory expectedError = abi.encodeWithSignature ("PaymentsEscrowInvalidZeroTokens() " );
22
35
vm.expectRevert (expectedError);
23
36
escrow.thaw (users.verifier, users.indexer, 0 );
24
37
}
@@ -28,17 +41,23 @@ contract GraphEscrowThawTest is GraphEscrowTest {
28
41
uint256 overAmount
29
42
) public useGateway useDeposit (amount) {
30
43
overAmount = bound (overAmount, amount + 1 , type (uint256 ).max);
31
- bytes memory expectedError = abi.encodeWithSignature ("PaymentsEscrowInsufficientBalance(uint256,uint256) " , amount, overAmount);
44
+ bytes memory expectedError = abi.encodeWithSignature (
45
+ "PaymentsEscrowInsufficientBalance(uint256,uint256) " ,
46
+ amount,
47
+ overAmount
48
+ );
32
49
vm.expectRevert (expectedError);
33
50
escrow.thaw (users.verifier, users.indexer, overAmount);
34
51
}
35
52
36
53
function testThaw_CancelRequest (uint256 amount ) public useGateway useDeposit (amount) {
37
- escrow.thaw (users.verifier, users.indexer, amount);
38
- escrow.thaw (users.verifier, users.indexer, 0 );
54
+ _thawEscrow (users.verifier, users.indexer, amount);
55
+ _cancelThawEscrow (users.verifier, users.indexer);
56
+ }
39
57
40
- (, uint256 amountThawing ,uint256 thawEndTimestamp ) = escrow.escrowAccounts (users.gateway, users.verifier, users.indexer);
41
- assertEq (amountThawing, 0 );
42
- assertEq (thawEndTimestamp, 0 );
58
+ function testThaw_CancelRequest_RevertWhen_NoThawing (uint256 amount ) public useGateway useDeposit (amount) {
59
+ bytes memory expectedError = abi.encodeWithSignature ("PaymentsEscrowNotThawing() " );
60
+ vm.expectRevert (expectedError);
61
+ escrow.cancelThaw (users.verifier, users.indexer);
43
62
}
44
- }
63
+ }
0 commit comments