-
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.
Merge branch 'release-testnet/v0.2.0' into feature/reverse-registrar
- Loading branch information
Showing
10 changed files
with
866 additions
and
30 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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "./RNSUnified.t.sol"; | ||
|
||
contract RNSUnified_ERC721_Test is RNSUnifiedTest { | ||
function test_TokenMetadata() external { | ||
assertEq(_rns.name(), "Ronin Name Service"); | ||
assertEq(_rns.symbol(), "RNS"); | ||
} | ||
|
||
function testFuzz_WhenExpired_RevokeOwnership_ownerOf(MintParam calldata mintParam) external mintAs(_controller) { | ||
(uint64 expiry, uint256 id) = _mint(_ronId, mintParam, _noError); | ||
_warpToExpire(expiry); | ||
assertEq(_rns.ownerOf(id), address(0x00)); | ||
} | ||
|
||
function testFuzz_WhenExpired_RevokeApproval_getApproved(address approved, MintParam calldata mintParam) | ||
external | ||
validAccount(approved) | ||
mintAs(_controller) | ||
{ | ||
vm.assume(approved != mintParam.owner && approved != _admin); | ||
(uint64 expiry, uint256 id) = _mint(_ronId, mintParam, _noError); | ||
vm.prank(mintParam.owner); | ||
_rns.setApprovalForAll(approved, true); | ||
_warpToExpire(expiry); | ||
address actualApproved = _rns.getApproved(id); | ||
assertEq(actualApproved, address(0x00)); | ||
} | ||
|
||
function testFuzz_UpdateRecordOwner_transferFrom(address newOwner, MintParam calldata mintParam) | ||
external | ||
validAccount(newOwner) | ||
mintAs(_controller) | ||
{ | ||
vm.assume(newOwner != _admin && newOwner != mintParam.owner); | ||
(, uint256 id) = _mint(_ronId, mintParam, _noError); | ||
vm.prank(mintParam.owner); | ||
_rns.transferFrom(mintParam.owner, newOwner, id); | ||
INSUnified.Record memory record = _rns.getRecord(id); | ||
assertEq(record.mut.owner, newOwner); | ||
} | ||
|
||
function testFuzz_WhenTransfered_LostProtected(address newOwner, MintParam calldata mintParam) | ||
external | ||
validAccount(newOwner) | ||
mintAs(_controller) | ||
{ | ||
vm.assume(newOwner != mintParam.owner); | ||
(, uint256 id) = _mint(_ronId, mintParam, _noError); | ||
|
||
uint256[] memory ids = new uint256[](1); | ||
ids[0] = id; | ||
vm.prank(_protectedSettler); | ||
_rns.bulkSetProtected(ids, true); | ||
|
||
INSUnified.Record memory record = _rns.getRecord(id); | ||
assertTrue(record.mut.protected); | ||
|
||
vm.prank(mintParam.owner); | ||
_rns.transferFrom(mintParam.owner, newOwner, id); | ||
|
||
record = _rns.getRecord(id); | ||
assertFalse(record.mut.protected); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "./RNSUnified.t.sol"; | ||
|
||
contract RNSUnified_BulkSetProtected_Test is RNSUnifiedTest { | ||
using LibModifyingField for ModifyingField; | ||
|
||
uint256 public constant MAX_FUZZ_INPUT = 100; | ||
|
||
modifier boundFuzzArrLength(uint256 length) { | ||
vm.assume(length <= MAX_FUZZ_INPUT); | ||
_; | ||
} | ||
|
||
function testFuzz_RevertWhenNotMinted_bulkSetProtected(bool protected, MintParam calldata mintParam) external { | ||
uint256 id = _toId(_ronId, mintParam.name); | ||
uint256[] memory ids = new uint256[](1); | ||
ids[0] = id; | ||
vm.expectRevert(INSUnified.Unexists.selector); | ||
vm.prank(_protectedSettler); | ||
_rns.bulkSetProtected(ids, protected); | ||
} | ||
|
||
function testGas_WhenMinted_AsProtectedSettler_bulkSetProtected(MintParam[] calldata mintParams) | ||
external | ||
mintAs(_controller) | ||
boundFuzzArrLength(mintParams.length) | ||
{ | ||
uint256[] memory ids = _mintBulk(mintParams); | ||
|
||
vm.prank(_protectedSettler); | ||
_rns.bulkSetProtected(ids, true); | ||
|
||
vm.pauseGasMetering(); | ||
for (uint256 i; i < ids.length;) { | ||
assertTrue(_rns.getRecord(ids[i]).mut.protected); | ||
|
||
unchecked { | ||
++i; | ||
} | ||
} | ||
vm.resumeGasMetering(); | ||
} | ||
|
||
function testGas_WhenMinted_AsProtectedSettler_bulkSetUnprotected(MintParam[] calldata mintParams) | ||
external | ||
mintAs(_controller) | ||
boundFuzzArrLength(mintParams.length) | ||
{ | ||
uint256[] memory ids = _mintBulk(mintParams); | ||
|
||
vm.pauseGasMetering(); | ||
vm.prank(_protectedSettler); | ||
_rns.bulkSetProtected(ids, true); | ||
|
||
vm.resumeGasMetering(); | ||
vm.prank(_protectedSettler); | ||
_rns.bulkSetProtected(ids, false); | ||
vm.pauseGasMetering(); | ||
|
||
for (uint256 i; i < ids.length;) { | ||
assertFalse(_rns.getRecord(ids[i]).mut.protected); | ||
|
||
unchecked { | ||
++i; | ||
} | ||
} | ||
vm.resumeGasMetering(); | ||
} | ||
} |
Oops, something went wrong.