-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathOwned.t.sol
More file actions
40 lines (29 loc) · 1013 Bytes
/
Owned.t.sol
File metadata and controls
40 lines (29 loc) · 1013 Bytes
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
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.15;
import {DSTestPlus} from "./utils/DSTestPlus.sol";
import {MockOwned} from "./utils/mocks/MockOwned.sol";
contract OwnedTest is DSTestPlus {
MockOwned mockOwned;
function setUp() public virtual {
mockOwned = new MockOwned();
}
function testTransferOwnership() public {
testTransferOwnership(address(0xBEEF));
}
function testCallFunctionAsNonOwner() public {
testCallFunctionAsNonOwner(address(0));
}
function testCallFunctionAsOwner() public {
mockOwned.updateFlag();
}
function testTransferOwnership(address newOwner) public {
mockOwned.transferOwnership(newOwner);
assertEq(mockOwned.owner(), newOwner);
}
function testCallFunctionAsNonOwner(address owner) public {
hevm.assume(owner != address(this));
mockOwned.transferOwnership(owner);
hevm.expectRevert("UNAUTHORIZED");
mockOwned.updateFlag();
}
}