This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTest_ZivoeTrancheToken.sol
90 lines (63 loc) · 2.78 KB
/
Test_ZivoeTrancheToken.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "../Utility/Utility.sol";
contract Test_ZivoeTrancheToken is Utility {
ZivoeTrancheToken zTT;
function setUp() public {
// Launch a new ZivoeTrancheToken contract.
zTT = new ZivoeTrancheToken("ZivoeTrancheToken", "zTT");
}
function test_ZivoeTrancheToken_burn_state(uint96 random) public {
// Give address(this) minting privlidges and mint some for testing burn().
zTT.changeMinterRole(address(this), true);
zTT.mint(address(this), uint256(random));
// Pre-state.
assertEq(zTT.totalSupply(), uint256(random));
assertEq(zTT.balanceOf(address(this)), uint256(random));
// burn().
zTT.burn(uint256(random));
// Post-state.
assertEq(zTT.totalSupply(), 0);
assertEq(zTT.balanceOf(address(this)), 0);
}
function test_ZivoeTrancheToken_mint_restrictions() public {
// Can't mint unless isMinterRole().
hevm.startPrank(address(bob));
hevm.expectRevert("ZivoeTrancheToken::isMinterRole() !_isMinter[_msgSender()]");
zTT.mint(address(this), 100);
hevm.stopPrank();
}
function test_ZivoeTrancheToken_mint_state(uint96 random) public {
// Give address(this) minting privlidges and mint some for testing burn().
zTT.changeMinterRole(address(this), true);
// Pre-state.
assertEq(zTT.totalSupply(), 0);
assertEq(zTT.balanceOf(address(this)), 0);
// mint().
zTT.mint(address(this), uint256(random));
// Post-state.
assertEq(zTT.totalSupply(), uint256(random));
assertEq(zTT.balanceOf(address(this)), uint256(random));
}
function test_ZivoeTrancheToken_changeMinterRole_restrictions() public {
// Can't update isMinterRole() unless _owner().
hevm.startPrank(address(bob));
hevm.expectRevert("Ownable: caller is not the owner");
zTT.changeMinterRole(address(bob), true);
hevm.stopPrank();
}
/// @notice This event is emitted when changeMinterRole() is called.
/// @param account The account who is receiving or losing the minter role.
/// @param allowed If true, the account is receiving minter role privlidges, if false the account is losing minter role privlidges.
event MinterUpdated(address indexed account, bool allowed);
function test_ZivoeTrancheToken_changeMinterRole_state() public {
// Pre-state.
assert(!zTT.isMinter(address(this)));
// mint().
hevm.expectEmit(true, false, false, true, address(zTT));
emit MinterUpdated(address(this), true);
zTT.changeMinterRole(address(this), true);
// Post-state.
assert(zTT.isMinter(address(this)));
}
}