forked from crytic/properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERC20IncreaseAllowanceProperties.sol
58 lines (51 loc) · 1.9 KB
/
ERC20IncreaseAllowanceProperties.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
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;
import "../util/ERC20TestBase.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
abstract contract CryticERC20IncreaseAllowanceProperties is CryticERC20Base {
constructor() {}
////////////////////////////////////////
// Properties
// Allowance should be modified correctly via increase/decrease
function test_ERC20_setAndIncreaseAllowance(
address target,
uint256 initialAmount,
uint256 increaseAmount
) public {
bool r = this.approve(target, initialAmount);
assertWithMsg(r == true, "Failed to set initial allowance via approve");
assertEq(
allowance(address(this), target),
initialAmount,
"Allowance not set correctly"
);
r = this.increaseAllowance(target, increaseAmount);
assertWithMsg(r == true, "Failed to increase allowance");
assertEq(
allowance(address(this), target),
initialAmount + increaseAmount,
"Allowance not increased correctly"
);
}
// Allowance should be modified correctly via increase/decrease
function test_ERC20_setAndDecreaseAllowance(
address target,
uint256 initialAmount,
uint256 decreaseAmount
) public {
bool r = this.approve(target, initialAmount);
assertWithMsg(r == true, "Failed to set initial allowance via approve");
assertEq(
allowance(address(this), target),
initialAmount,
"Allowance not set correctly"
);
r = this.decreaseAllowance(target, decreaseAmount);
assertWithMsg(r == true, "Failed to decrease allowance");
assertEq(
allowance(address(this), target),
initialAmount - decreaseAmount,
"Allowance not decreased correctly"
);
}
}