forked from scroll-tech/scroll-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Whitelist.t.sol
64 lines (53 loc) · 2.12 KB
/
Whitelist.t.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
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {DSTestPlus} from "solmate/test/utils/DSTestPlus.sol";
import {WETH} from "solmate/tokens/WETH.sol";
import {Whitelist} from "../L2/predeploys/Whitelist.sol";
contract WhitelistTest is DSTestPlus {
Whitelist private whitelist;
function setUp() public {
whitelist = new Whitelist(address(this));
}
function testRenounceOwnership() external {
// call by non-owner, should revert
hevm.startPrank(address(1));
hevm.expectRevert("caller is not the owner");
whitelist.renounceOwnership();
hevm.stopPrank();
// call by owner, should succeed
assertEq(whitelist.owner(), address(this));
whitelist.renounceOwnership();
assertEq(whitelist.owner(), address(0));
}
function testTransferOwnership(address _to) external {
// call by non-owner, should revert
hevm.startPrank(address(1));
hevm.expectRevert("caller is not the owner");
whitelist.transferOwnership(_to);
hevm.stopPrank();
// call by owner, should succeed
if (_to == address(0)) {
hevm.expectRevert("new owner is the zero address");
whitelist.transferOwnership(_to);
} else {
assertEq(whitelist.owner(), address(this));
whitelist.transferOwnership(_to);
assertEq(whitelist.owner(), _to);
}
}
function testUpdateWhitelistStatus(address _to) external {
address[] memory _accounts = new address[](1);
_accounts[0] = _to;
// call by non-owner, should revert
hevm.startPrank(address(1));
hevm.expectRevert("caller is not the owner");
whitelist.updateWhitelistStatus(_accounts, true);
hevm.stopPrank();
// call by owner, should succeed
assertBoolEq(whitelist.isSenderAllowed(_to), false);
whitelist.updateWhitelistStatus(_accounts, true);
assertBoolEq(whitelist.isSenderAllowed(_to), true);
whitelist.updateWhitelistStatus(_accounts, false);
assertBoolEq(whitelist.isSenderAllowed(_to), false);
}
}