test: add and change tests to fuzz test (#128)
This commit is contained in:
parent
70e9c14b05
commit
197a7a28c5
|
|
@ -17,22 +17,24 @@ contract Test_FleekERC721_Burn is Test_FleekERC721_Base {
|
|||
CuT.burn(tokenId);
|
||||
}
|
||||
|
||||
function test_cannotBurnAsNotOwner() public {
|
||||
vm.prank(address(1));
|
||||
function testFuzz_cannotBurnAsNotOwner(address account) public {
|
||||
vm.assume(account != deployer);
|
||||
vm.prank(account);
|
||||
expectRevertWithTokenRole();
|
||||
CuT.burn(tokenId);
|
||||
}
|
||||
|
||||
function test_cannotBurnAsController() public {
|
||||
address user = address(1);
|
||||
CuT.grantTokenRole(tokenId, FleekAccessControl.Roles.Controller, user);
|
||||
vm.prank(user);
|
||||
function testFuzz_cannotBurnAsController(address account) public {
|
||||
vm.assume(account != deployer);
|
||||
CuT.grantTokenRole(tokenId, FleekAccessControl.Roles.Controller, account);
|
||||
vm.prank(account);
|
||||
expectRevertWithTokenRole();
|
||||
CuT.burn(tokenId);
|
||||
}
|
||||
|
||||
function test_cannotBurnInexistentToken() public {
|
||||
function testFuzz_cannotBurnInexistentToken(uint256 _tokenId) public {
|
||||
vm.assume(_tokenId != tokenId);
|
||||
expectRevertWithTokenRole(); // Token role is tested first before if token exists
|
||||
CuT.burn(1);
|
||||
CuT.burn(_tokenId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,12 @@ contract Test_FleekERC721_Deploy is Test_FleekERC721_Base {
|
|||
function test_deployerShouldBeCollectionOwner() public {
|
||||
assertTrue(CuT.hasCollectionRole(FleekAccessControl.Roles.Owner, deployer));
|
||||
}
|
||||
|
||||
function testFuzz_nameAndSymbol(string memory _name, string memory _symbol) public {
|
||||
CuT = new FleekERC721();
|
||||
CuT.initialize(_name, _symbol);
|
||||
|
||||
assertEq(CuT.name(), _name);
|
||||
assertEq(CuT.symbol(), _symbol);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,22 @@ contract Test_FleekERC721_GetToken is Test_FleekERC721_Base {
|
|||
assertEq(currentBuild, 0);
|
||||
}
|
||||
|
||||
function test_getTokenAfterUpdate() public {
|
||||
CuT.setTokenName(tokenId, "New App Name");
|
||||
CuT.setTokenDescription(tokenId, "New description for the app.");
|
||||
CuT.setTokenExternalURL(tokenId, "https://new-url.com");
|
||||
CuT.setTokenENS(tokenId, "new-ens.eth");
|
||||
CuT.setTokenBuild(tokenId, "ce1a3fc141e29f8e1d00a654e156c4982d7711bf", "https://github.com/other/repo");
|
||||
CuT.setTokenLogoAndColor(tokenId, TestConstants.LOGO_1, 0x654321);
|
||||
function testFuzz_getTokenAfterUpdate(
|
||||
string memory newAppName,
|
||||
string memory newDescription,
|
||||
string memory newExternalURL,
|
||||
string memory newENS,
|
||||
string memory newCommitHash,
|
||||
string memory newRepository,
|
||||
string memory newLogo,
|
||||
uint24 newColor
|
||||
) public {
|
||||
CuT.setTokenName(tokenId, newAppName);
|
||||
CuT.setTokenDescription(tokenId, newDescription);
|
||||
CuT.setTokenExternalURL(tokenId, newExternalURL);
|
||||
CuT.setTokenENS(tokenId, newENS);
|
||||
CuT.setTokenBuild(tokenId, newCommitHash, newRepository);
|
||||
CuT.setTokenLogoAndColor(tokenId, newLogo, newColor);
|
||||
|
||||
(
|
||||
string memory name,
|
||||
|
|
@ -49,25 +58,23 @@ contract Test_FleekERC721_GetToken is Test_FleekERC721_Base {
|
|||
string memory logo,
|
||||
uint24 color
|
||||
) = CuT.getToken(tokenId);
|
||||
assertEq(name, "New App Name");
|
||||
assertEq(description, "New description for the app.");
|
||||
assertEq(externalURL, "https://new-url.com");
|
||||
assertEq(logo, TestConstants.LOGO_1);
|
||||
assertEq(color, 0x654321);
|
||||
assertEq(ENS, "new-ens.eth");
|
||||
assertEq(name, newAppName);
|
||||
assertEq(description, newDescription);
|
||||
assertEq(externalURL, newExternalURL);
|
||||
assertEq(logo, newLogo);
|
||||
assertEq(color, newColor);
|
||||
assertEq(ENS, newENS);
|
||||
assertEq(currentBuild, 1);
|
||||
}
|
||||
|
||||
function test_getTokenForDifferentAddresses() public {
|
||||
vm.prank(address(1));
|
||||
CuT.getToken(tokenId);
|
||||
vm.prank(address(2));
|
||||
CuT.getToken(tokenId);
|
||||
vm.prank(address(3));
|
||||
function testFuzz_getTokenForDifferentAddresses(address account) public {
|
||||
vm.prank(account);
|
||||
CuT.getToken(tokenId);
|
||||
}
|
||||
|
||||
function testFail_tokenURIForNonExistentId() public view {
|
||||
CuT.getToken(1);
|
||||
function testFuzz_tokenURIForNonExistentId(uint256 _tokenId) public {
|
||||
vm.assume(_tokenId != tokenId);
|
||||
expectRevertWithInvalidTokenId();
|
||||
CuT.getToken(_tokenId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,4 +49,22 @@ contract Test_FleekERC721_Mint is Test_FleekERC721_Base {
|
|||
|
||||
assertEq(CuT.balanceOf(deployer), 1);
|
||||
}
|
||||
|
||||
function testFuzz_mint(
|
||||
address to,
|
||||
string memory appName,
|
||||
string memory description,
|
||||
string memory externalURL,
|
||||
string memory ens,
|
||||
string memory commitHash,
|
||||
string memory gitRepository,
|
||||
string memory logo,
|
||||
uint24 color
|
||||
) public {
|
||||
vm.assume(to != address(0));
|
||||
uint256 tokenId = CuT.mint(to, appName, description, externalURL, ens, commitHash, gitRepository, logo, color);
|
||||
|
||||
assertEq(tokenId, 0);
|
||||
assertEq(CuT.ownerOf(tokenId), to);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,17 +66,15 @@ contract Test_FleekERC721_TokenURI is Test_FleekERC721_Base, Test_FleekERC721_To
|
|||
);
|
||||
}
|
||||
|
||||
function test_tokenURIForDifferentAddresses() public {
|
||||
vm.prank(address(1));
|
||||
CuT.tokenURI(tokenId);
|
||||
vm.prank(address(2));
|
||||
CuT.tokenURI(tokenId);
|
||||
vm.prank(address(3));
|
||||
function testFuzz_tokenURIForDifferentAddresses(address account) public {
|
||||
vm.prank(account);
|
||||
CuT.tokenURI(tokenId);
|
||||
}
|
||||
|
||||
function testFail_tokenURIForInexistentId() public view {
|
||||
CuT.tokenURI(1);
|
||||
function testFuzz_tokenURIForInexistentId(uint256 _tokenId) public {
|
||||
vm.assume(_tokenId != tokenId);
|
||||
expectRevertWithInvalidTokenId();
|
||||
CuT.tokenURI(_tokenId);
|
||||
}
|
||||
|
||||
function test_shouldEmitEventForMetadataChanges() public {
|
||||
|
|
|
|||
Loading…
Reference in New Issue