forked from crytic/properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERC20ExternalIncreaseAllowanceProperties.sol
59 lines (52 loc) · 1.9 KB
/
ERC20ExternalIncreaseAllowanceProperties.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;
import "../util/ERC20ExternalTestBase.sol";
abstract contract CryticERC20ExternalIncreaseAllowanceProperties is
CryticERC20ExternalTestBase
{
constructor() {}
////////////////////////////////////////
// Properties
// Allowance should be modified correctly via increase/decrease
function test_ERC20external_setAndIncreaseAllowance(
address target,
uint256 initialAmount,
uint256 increaseAmount
) public {
bool r = token.approve(target, initialAmount);
assertWithMsg(r == true, "Failed to set initial allowance via approve");
assertEq(
token.allowance(address(this), target),
initialAmount,
"Allowance not set correctly"
);
r = token.increaseAllowance(target, increaseAmount);
assertWithMsg(r == true, "Failed to increase allowance");
assertEq(
token.allowance(address(this), target),
initialAmount + increaseAmount,
"Allowance not increased correctly"
);
}
// Allowance should be modified correctly via increase/decrease
function test_ERC20external_setAndDecreaseAllowance(
address target,
uint256 initialAmount,
uint256 decreaseAmount
) public {
bool r = token.approve(target, initialAmount);
assertWithMsg(r == true, "Failed to set initial allowance via approve");
assertEq(
token.allowance(address(this), target),
initialAmount,
"Allowance not set correctly"
);
r = token.decreaseAllowance(target, decreaseAmount);
assertWithMsg(r == true, "Failed to decrease allowance");
assertEq(
token.allowance(address(this), target),
initialAmount - decreaseAmount,
"Allowance not decreased correctly"
);
}
}