Skip to content

Commit

Permalink
test: document test names
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Oct 27, 2023
1 parent 9d8e661 commit 31cd376
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/TinyENS.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract TinyENSTest is Test {
vm.stopPrank();
}

function testRegister() public {
function testRegisterNewName() public {
vm.startPrank(alice);
tinyENS.register('alice.eth');
vm.stopPrank();
Expand All @@ -28,7 +28,7 @@ contract TinyENSTest is Test {
console2.log('Alice registed alice.eth');
}

function testFailRegister() public {
function testRegisterAlreadyRegisteredName() public {
vm.startPrank(alice);
tinyENS.register('alice.eth');
assertEq(tinyENS.resolve('alice.eth'), alice);
Expand All @@ -37,16 +37,15 @@ contract TinyENSTest is Test {

console2.log('Bob tries to register alice.eth');
vm.startPrank(bob);
tinyENS.register('alice.eth');
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), 'axxxx');
assertEq(tinyENS.reverse(bob), '');
vm.stopPrank();
}

function testUpdate() public {
function testUpdateWithNewName() public {
vm.startPrank(alice);
tinyENS.register('alice.eth');
assertEq(tinyENS.resolve('alice.eth'), alice);
Expand All @@ -60,7 +59,7 @@ contract TinyENSTest is Test {
vm.stopPrank();
}

function testFailUpdate() public {
function testUpdateWithAlreadyRegisteredName() public {
vm.startPrank(alice);
tinyENS.register('alice.eth');
console2.log('Alice registed alice.eth');
Expand All @@ -70,8 +69,12 @@ contract TinyENSTest is Test {
console2.log('Bob registed bob.eth');

console2.log('Bob tries to update its name to alice.eth');
tinyENS.update('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();
}
}

0 comments on commit 31cd376

Please sign in to comment.