-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
240 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.21; | ||
|
||
import '../src/TinyENS.sol'; | ||
import '@forge-std/Test.sol'; | ||
import "../src/TinyENS.sol"; | ||
import "@forge-std/Test.sol"; | ||
|
||
contract TinyENSTest is Test { | ||
TinyENS private tinyENS; | ||
TinyENS private tinyENS; | ||
|
||
address private owner = makeAddr('owner'); | ||
address private alice = makeAddr('alice'); | ||
address private bob = makeAddr('bob'); | ||
address private owner = makeAddr("owner"); | ||
address private alice = makeAddr("alice"); | ||
address private bob = makeAddr("bob"); | ||
|
||
function setUp() public { | ||
vm.startPrank(owner); | ||
tinyENS = new TinyENS(); | ||
console2.log('TinyENS deployed'); | ||
vm.stopPrank(); | ||
} | ||
function setUp() public { | ||
vm.startPrank(owner); | ||
tinyENS = new TinyENS(); | ||
console2.log("TinyENS deployed"); | ||
vm.stopPrank(); | ||
} | ||
|
||
function test_RegisterNewName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register('alice.eth'); | ||
vm.stopPrank(); | ||
function test_RegisterNewName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register("alice.eth"); | ||
vm.stopPrank(); | ||
|
||
assertEq(tinyENS.resolve('alice.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice.eth'); | ||
console2.log('Alice registed alice.eth'); | ||
} | ||
assertEq(tinyENS.resolve("alice.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice.eth"); | ||
console2.log("Alice registed alice.eth"); | ||
} | ||
|
||
function test_RegisterAlreadyRegisteredName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register('alice.eth'); | ||
assertEq(tinyENS.resolve('alice.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice.eth'); | ||
console2.log('Alice registed alice.eth'); | ||
function test_RegisterAlreadyRegisteredName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register("alice.eth"); | ||
assertEq(tinyENS.resolve("alice.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice.eth"); | ||
console2.log("Alice registed alice.eth"); | ||
|
||
console2.log('Bob tries to register alice.eth'); | ||
vm.startPrank(bob); | ||
vm.expectRevert(TinyENS.AlreadyRegistered.selector); | ||
tinyENS.register('alice.eth'); | ||
assertEq(tinyENS.resolve('alice.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice.eth'); | ||
assertEq(tinyENS.reverse(bob), ''); | ||
vm.stopPrank(); | ||
} | ||
console2.log("Bob tries to register alice.eth"); | ||
vm.startPrank(bob); | ||
vm.expectRevert(TinyENS.AlreadyRegistered.selector); | ||
tinyENS.register("alice.eth"); | ||
assertEq(tinyENS.resolve("alice.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice.eth"); | ||
assertEq(tinyENS.reverse(bob), ""); | ||
vm.stopPrank(); | ||
} | ||
|
||
function test_UpdateWithNewName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register('alice.eth'); | ||
assertEq(tinyENS.resolve('alice.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice.eth'); | ||
console2.log('Alice registed alice.eth'); | ||
function test_UpdateWithNewName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register("alice.eth"); | ||
assertEq(tinyENS.resolve("alice.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice.eth"); | ||
console2.log("Alice registed alice.eth"); | ||
|
||
tinyENS.register('alice22.eth'); | ||
assertEq(tinyENS.resolve('alice22.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice22.eth'); | ||
console2.log('Alice updated its name to alice22.eth'); | ||
vm.stopPrank(); | ||
} | ||
tinyENS.register("alice22.eth"); | ||
assertEq(tinyENS.resolve("alice22.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice22.eth"); | ||
console2.log("Alice updated its name to alice22.eth"); | ||
vm.stopPrank(); | ||
} | ||
|
||
function test_UpdateWithAlreadyRegisteredName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register('alice.eth'); | ||
console2.log('Alice registed alice.eth'); | ||
function test_UpdateWithAlreadyRegisteredName() public { | ||
vm.startPrank(alice); | ||
tinyENS.register("alice.eth"); | ||
console2.log("Alice registed alice.eth"); | ||
|
||
vm.startPrank(bob); | ||
tinyENS.register('bob.eth'); | ||
console2.log('Bob registed bob.eth'); | ||
vm.startPrank(bob); | ||
tinyENS.register("bob.eth"); | ||
console2.log("Bob registed bob.eth"); | ||
|
||
console2.log('Bob tries to update its name to alice.eth'); | ||
vm.expectRevert(TinyENS.AlreadyRegistered.selector); | ||
tinyENS.update('alice.eth'); | ||
assertEq(tinyENS.resolve('alice.eth'), alice); | ||
assertEq(tinyENS.reverse(alice), 'alice.eth'); | ||
assertEq(tinyENS.resolve('bob.eth'), bob); | ||
assertEq(tinyENS.reverse(bob), 'bob.eth'); | ||
vm.stopPrank(); | ||
} | ||
console2.log("Bob tries to update its name to alice.eth"); | ||
vm.expectRevert(TinyENS.AlreadyRegistered.selector); | ||
tinyENS.update("alice.eth"); | ||
assertEq(tinyENS.resolve("alice.eth"), alice); | ||
assertEq(tinyENS.reverse(alice), "alice.eth"); | ||
assertEq(tinyENS.resolve("bob.eth"), bob); | ||
assertEq(tinyENS.reverse(bob), "bob.eth"); | ||
vm.stopPrank(); | ||
} | ||
} |
Oops, something went wrong.