-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
LilENS.t.sol
57 lines (42 loc) · 1.37 KB
/
LilENS.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
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;
import { Vm } from 'forge-std/Vm.sol';
import { LilENS } from '../LilENS.sol';
import { DSTest } from 'ds-test/test.sol';
contract User {}
contract LilENSTest is DSTest {
User internal user;
LilENS internal lilENS;
Vm internal hevm = Vm(HEVM_ADDRESS);
function setUp() public {
user = new User();
lilENS = new LilENS();
}
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));
}
}