forked from m1guelpf/lil-web3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLilENS.t.sol
More file actions
58 lines (43 loc) · 1.33 KB
/
Copy pathLilENS.t.sol
File metadata and controls
58 lines (43 loc) · 1.33 KB
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-only
pragma solidity ^0.8.10;
import './Hevm.sol';
import '../LilENS.sol';
import 'ds-test/test.sol';
contract User {}
contract LilENSTest is DSTest {
User internal user;
Hevm internal hevm;
LilENS internal lilENS;
function setUp() public {
user = new User();
lilENS = new LilENS();
hevm = Hevm(HEVM_ADDRESS);
}
function testCanRegister() public {
assertEq(lilENS.lookup('test'), address(0));
lilENS.register('test');
assertEq(lilENS.lookup('test'), address(this));
}
function testCannotRegisterExistingName() public {
lilENS.register('test');
assertEq(lilENS.lookup('test'), address(this));
hevm.prank(address(user));
hevm.expectRevert(abi.encodeWithSignature('AlreadyRegistered()'));
lilENS.register('test');
assertEq(lilENS.lookup('test'), address(this));
}
function testCanUpdate() public {
lilENS.register('test');
assertEq(lilENS.lookup('test'), address(this));
lilENS.update('test', address(user));
assertEq(lilENS.lookup('test'), address(user));
}
function testNonOwnerCannotUpdate() public {
lilENS.register('test');
assertEq(lilENS.lookup('test'), address(this));
hevm.prank(address(user));
hevm.expectRevert(abi.encodeWithSignature('Unauthorized()'));
lilENS.update('test', address(user));
assertEq(lilENS.lookup('test'), address(this));
}
}