Merge pull request #26 from fleekxyz/test/foundry
Solidity tests by foundry
This commit is contained in:
commit
0e67867560
|
|
@ -1,151 +1,221 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
pragma solidity ^0.8.7;
|
pragma solidity ^0.8.7;
|
||||||
|
|
||||||
import "@openzeppelin/contracts/utils/Counters.sol";
|
import "@openzeppelin/contracts/utils/Counters.sol";
|
||||||
|
|
||||||
contract FleekAccessControl {
|
contract FleekAccessControl {
|
||||||
using Counters for Counters.Counter;
|
using Counters for Counters.Counter;
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
Owner,
|
Owner,
|
||||||
Controller
|
Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
event TokenRoleGranted(uint256 indexed tokenId, Roles indexed role, address indexed toAddress, address byAddress);
|
event TokenRoleGranted(uint256 indexed tokenId, Roles indexed role, address indexed toAddress, address byAddress);
|
||||||
event TokenRoleRevoked(uint256 indexed tokenId, Roles indexed role, address indexed toAddress, address byAddress);
|
event TokenRoleRevoked(uint256 indexed tokenId, Roles indexed role, address indexed toAddress, address byAddress);
|
||||||
event CollectionRoleGranted(Roles indexed role, address indexed toAddress, address byAddress);
|
event CollectionRoleGranted(Roles indexed role, address indexed toAddress, address byAddress);
|
||||||
event CollectionRoleRevoked(Roles indexed role, address indexed toAddress, address byAddress);
|
event CollectionRoleRevoked(Roles indexed role, address indexed toAddress, address byAddress);
|
||||||
|
|
||||||
struct Role {
|
struct Role {
|
||||||
mapping(address => uint256) indexes;
|
mapping(address => uint256) indexes;
|
||||||
address[] members;
|
address[] members;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counters.Counter private _collectionRolesVersion;
|
Counters.Counter private _collectionRolesVersion;
|
||||||
// _collectionRoles[version][role]
|
// _collectionRoles[version][role]
|
||||||
mapping(uint256 => mapping(Roles => Role)) private _collectionRoles;
|
mapping(uint256 => mapping(Roles => Role)) private _collectionRoles;
|
||||||
|
|
||||||
mapping(uint256 => Counters.Counter) private _tokenRolesVersion;
|
mapping(uint256 => Counters.Counter) private _tokenRolesVersion;
|
||||||
// _tokenRoles[tokenId][version][role]
|
// _tokenRoles[tokenId][version][role]
|
||||||
mapping(uint256 => mapping(uint256 => mapping(Roles => Role))) private _tokenRoles;
|
mapping(uint256 => mapping(uint256 => mapping(Roles => Role))) private _tokenRoles;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
_grantCollectionRole(Roles.Owner, msg.sender);
|
_grantCollectionRole(Roles.Owner, msg.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier requireCollectionRole(Roles role) {
|
modifier requireCollectionRole(Roles role) {
|
||||||
require(
|
require(
|
||||||
hasCollectionRole(role, msg.sender) || hasCollectionRole(Roles.Owner, msg.sender),
|
hasCollectionRole(role, msg.sender) || hasCollectionRole(Roles.Owner, msg.sender),
|
||||||
"FleekAccessControl: must have collection role"
|
"FleekAccessControl: must have collection role"
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier requireTokenRole(uint256 tokenId, Roles role) {
|
modifier requireTokenRole(uint256 tokenId, Roles role) {
|
||||||
require(
|
require(
|
||||||
hasTokenRole(tokenId, role, msg.sender) || hasTokenRole(tokenId, Roles.Owner, msg.sender),
|
hasTokenRole(tokenId, role, msg.sender) || hasTokenRole(tokenId, Roles.Owner, msg.sender),
|
||||||
"FleekAccessControl: must have token role"
|
"FleekAccessControl: must have token role"
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function grantCollectionRole(Roles role, address account) public requireCollectionRole(Roles.Owner) {
|
/**
|
||||||
_grantCollectionRole(role, account);
|
* @dev Grants the collection role to an address.
|
||||||
}
|
*
|
||||||
|
* Requirements:
|
||||||
function grantTokenRole(
|
*
|
||||||
uint256 tokenId,
|
* - the caller should have the collection role.
|
||||||
Roles role,
|
*
|
||||||
address account
|
*/
|
||||||
) public requireTokenRole(tokenId, Roles.Owner) {
|
function grantCollectionRole(Roles role, address account) public requireCollectionRole(Roles.Owner) {
|
||||||
_grantTokenRole(tokenId, role, account);
|
_grantCollectionRole(role, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeCollectionRole(Roles role, address account) public requireCollectionRole(Roles.Owner) {
|
/**
|
||||||
_revokeCollectionRole(role, account);
|
* @dev Grants the token role to an address.
|
||||||
}
|
*
|
||||||
|
* Requirements:
|
||||||
function revokeTokenRole(
|
*
|
||||||
uint256 tokenId,
|
* - the caller should have the token role.
|
||||||
Roles role,
|
*
|
||||||
address account
|
*/
|
||||||
) public requireTokenRole(tokenId, Roles.Owner) {
|
function grantTokenRole(
|
||||||
_revokeTokenRole(tokenId, role, account);
|
uint256 tokenId,
|
||||||
}
|
Roles role,
|
||||||
|
address account
|
||||||
function hasCollectionRole(Roles role, address account) public view returns (bool) {
|
) public requireTokenRole(tokenId, Roles.Owner) {
|
||||||
uint256 currentVersion = _collectionRolesVersion.current();
|
_grantTokenRole(tokenId, role, account);
|
||||||
|
}
|
||||||
return _collectionRoles[currentVersion][role].indexes[account] != 0;
|
|
||||||
}
|
/**
|
||||||
|
* @dev Revokes the collection role of an address.
|
||||||
function hasTokenRole(uint256 tokenId, Roles role, address account) public view returns (bool) {
|
*
|
||||||
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
* Requirements:
|
||||||
return _tokenRoles[tokenId][currentVersion][role].indexes[account] != 0;
|
*
|
||||||
}
|
* - the caller should have the collection role.
|
||||||
|
*
|
||||||
function getCollectionRoleMembers(Roles role) public view returns (address[] memory) {
|
*/
|
||||||
uint256 currentVersion = _collectionRolesVersion.current();
|
function revokeCollectionRole(Roles role, address account) public requireCollectionRole(Roles.Owner) {
|
||||||
return _collectionRoles[currentVersion][role].members;
|
_revokeCollectionRole(role, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTokenRoleMembers(uint256 tokenId, Roles role) public view returns (address[] memory) {
|
/**
|
||||||
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
* @dev Revokes the token role of an address.
|
||||||
return _tokenRoles[tokenId][currentVersion][role].members;
|
*
|
||||||
}
|
* Requirements:
|
||||||
|
*
|
||||||
function _grantCollectionRole(Roles role, address account) internal {
|
* - the caller should have the token role.
|
||||||
uint256 currentVersion = _collectionRolesVersion.current();
|
*
|
||||||
_grantRole(_collectionRoles[currentVersion][role], account);
|
*/
|
||||||
emit CollectionRoleGranted(role, account, msg.sender);
|
function revokeTokenRole(
|
||||||
}
|
uint256 tokenId,
|
||||||
|
Roles role,
|
||||||
function _revokeCollectionRole(Roles role, address account) internal {
|
address account
|
||||||
uint256 currentVersion = _collectionRolesVersion.current();
|
) public requireTokenRole(tokenId, Roles.Owner) {
|
||||||
_revokeRole(_collectionRoles[currentVersion][role], account);
|
_revokeTokenRole(tokenId, role, account);
|
||||||
emit CollectionRoleRevoked(role, account, msg.sender);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
function _grantTokenRole(uint256 tokenId, Roles role, address account) internal {
|
* @dev Returns `True` if a certain address has the collection role.
|
||||||
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
*/
|
||||||
_grantRole(_tokenRoles[tokenId][currentVersion][role], account);
|
function hasCollectionRole(Roles role, address account) public view returns (bool) {
|
||||||
emit TokenRoleGranted(tokenId, role, account, msg.sender);
|
uint256 currentVersion = _collectionRolesVersion.current();
|
||||||
}
|
|
||||||
|
return _collectionRoles[currentVersion][role].indexes[account] != 0;
|
||||||
function _revokeTokenRole(uint256 tokenId, Roles role, address account) internal {
|
}
|
||||||
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
|
||||||
_revokeRole(_tokenRoles[tokenId][currentVersion][role], account);
|
/**
|
||||||
emit TokenRoleRevoked(tokenId, role, account, msg.sender);
|
* @dev Returns `True` if a certain address has the token role.
|
||||||
}
|
*/
|
||||||
|
function hasTokenRole(uint256 tokenId, Roles role, address account) public view returns (bool) {
|
||||||
function _grantRole(Role storage role, address account) internal {
|
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
||||||
if (role.indexes[account] == 0) {
|
return _tokenRoles[tokenId][currentVersion][role].indexes[account] != 0;
|
||||||
role.members.push(account);
|
}
|
||||||
role.indexes[account] = role.members.length;
|
|
||||||
}
|
/**
|
||||||
}
|
* @dev Returns an array of addresses that all have the collection role.
|
||||||
|
*/
|
||||||
function _revokeRole(Role storage role, address account) internal {
|
function getCollectionRoleMembers(Roles role) public view returns (address[] memory) {
|
||||||
if (role.indexes[account] != 0) {
|
uint256 currentVersion = _collectionRolesVersion.current();
|
||||||
uint256 index = role.indexes[account] - 1;
|
return _collectionRoles[currentVersion][role].members;
|
||||||
uint256 lastIndex = role.members.length - 1;
|
}
|
||||||
address lastAccount = role.members[lastIndex];
|
|
||||||
|
/**
|
||||||
role.members[index] = lastAccount;
|
* @dev Returns an array of addresses that all have the same token role for a certain tokenId.
|
||||||
role.indexes[lastAccount] = index + 1;
|
*/
|
||||||
|
function getTokenRoleMembers(uint256 tokenId, Roles role) public view returns (address[] memory) {
|
||||||
role.members.pop();
|
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
||||||
delete role.indexes[account];
|
return _tokenRoles[tokenId][currentVersion][role].members;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
function _clearAllTokenRoles(uint256 tokenId) internal {
|
* @dev Grants the collection role to an address.
|
||||||
_tokenRolesVersion[tokenId].increment();
|
*/
|
||||||
}
|
function _grantCollectionRole(Roles role, address account) internal {
|
||||||
|
uint256 currentVersion = _collectionRolesVersion.current();
|
||||||
function _clearAllTokenRoles(uint256 tokenId, address newOwner) internal {
|
_grantRole(_collectionRoles[currentVersion][role], account);
|
||||||
_clearAllTokenRoles(tokenId);
|
emit CollectionRoleGranted(role, account, msg.sender);
|
||||||
_grantTokenRole(tokenId, Roles.Owner, newOwner);
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* @dev Revokes the collection role of an address.
|
||||||
|
*/
|
||||||
|
function _revokeCollectionRole(Roles role, address account) internal {
|
||||||
|
uint256 currentVersion = _collectionRolesVersion.current();
|
||||||
|
_revokeRole(_collectionRoles[currentVersion][role], account);
|
||||||
|
emit CollectionRoleRevoked(role, account, msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Grants the token role to an address.
|
||||||
|
*/
|
||||||
|
function _grantTokenRole(uint256 tokenId, Roles role, address account) internal {
|
||||||
|
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
||||||
|
_grantRole(_tokenRoles[tokenId][currentVersion][role], account);
|
||||||
|
emit TokenRoleGranted(tokenId, role, account, msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Revokes the token role of an address.
|
||||||
|
*/
|
||||||
|
function _revokeTokenRole(uint256 tokenId, Roles role, address account) internal {
|
||||||
|
uint256 currentVersion = _tokenRolesVersion[tokenId].current();
|
||||||
|
_revokeRole(_tokenRoles[tokenId][currentVersion][role], account);
|
||||||
|
emit TokenRoleRevoked(tokenId, role, account, msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Grants a certain role to a certain address.
|
||||||
|
*/
|
||||||
|
function _grantRole(Role storage role, address account) internal {
|
||||||
|
if (role.indexes[account] == 0) {
|
||||||
|
role.members.push(account);
|
||||||
|
role.indexes[account] = role.members.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Revokes a certain role from a certain address.
|
||||||
|
*/
|
||||||
|
function _revokeRole(Role storage role, address account) internal {
|
||||||
|
if (role.indexes[account] != 0) {
|
||||||
|
uint256 index = role.indexes[account] - 1;
|
||||||
|
uint256 lastIndex = role.members.length - 1;
|
||||||
|
address lastAccount = role.members[lastIndex];
|
||||||
|
|
||||||
|
role.members[index] = lastAccount;
|
||||||
|
role.indexes[lastAccount] = index + 1;
|
||||||
|
|
||||||
|
role.members.pop();
|
||||||
|
delete role.indexes[account];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Clears all token roles for a certain tokenId.
|
||||||
|
* Should only be used for burning tokens.
|
||||||
|
*/
|
||||||
|
function _clearAllTokenRoles(uint256 tokenId) internal {
|
||||||
|
_tokenRolesVersion[tokenId].increment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Clears all token roles for a certain tokenId and grants the owner role to a new address.
|
||||||
|
* Should only be used for transferring tokens.
|
||||||
|
*/
|
||||||
|
function _clearAllTokenRoles(uint256 tokenId, address newOwner) internal {
|
||||||
|
_clearAllTokenRoles(tokenId);
|
||||||
|
_grantTokenRole(tokenId, Roles.Owner, newOwner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
* - the sender must have the `tokenOwner` role.
|
* - the sender must have the `tokenOwner` role.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function burn(uint256 tokenId) public virtual requireTokenRole(tokenId, Roles.Owner) {
|
function burn(uint256 tokenId) public virtual requireTokenRole(tokenId, Roles.Owner) {
|
||||||
super._burn(tokenId);
|
super._burn(tokenId);
|
||||||
|
|
||||||
if (bytes(_apps[tokenId].externalURL).length != 0) {
|
if (bytes(_apps[tokenId].externalURL).length != 0) {
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ describe('FleekERC721', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Token URI', () => {
|
describe('Token URI', () => {
|
||||||
|
|
||||||
let tokenId: number;
|
let tokenId: number;
|
||||||
let fixture: Awaited<ReturnType<typeof defaultFixture>>;
|
let fixture: Awaited<ReturnType<typeof defaultFixture>>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Foundry Tests
|
||||||
|
|
||||||
|
This directory contains the code for all Foundry Forge Solidity tests of the FleekERC721 contract.
|
||||||
|
|
@ -3,9 +3,9 @@ pragma solidity ^0.8.7;
|
||||||
import "forge-std/Test.sol";
|
import "forge-std/Test.sol";
|
||||||
import "../../contracts/FleekERC721.sol";
|
import "../../contracts/FleekERC721.sol";
|
||||||
|
|
||||||
contract ContractBTest is Test {
|
contract FleekTest is Test {
|
||||||
FleekERC721 fleekContract;
|
FleekERC721 fleekContract;
|
||||||
uint256 testNumber;
|
address constant DEPLOYER = 0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496;
|
||||||
|
|
||||||
function setUp() public {
|
function setUp() public {
|
||||||
fleekContract = new FleekERC721("Test Contract", "FLKAPS");
|
fleekContract = new FleekERC721("Test Contract", "FLKAPS");
|
||||||
|
|
@ -19,27 +19,825 @@ contract ContractBTest is Test {
|
||||||
assertEq(fleekContract.symbol(), "FLKAPS");
|
assertEq(fleekContract.symbol(), "FLKAPS");
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMint() public {}
|
function testMint() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testTokenURI() public {}
|
assertEq(mint, 0);
|
||||||
|
assertEq(fleekContract.ownerOf(mint), DEPLOYER);
|
||||||
|
}
|
||||||
|
|
||||||
function testBurn() public {}
|
function testMintingMintedToken() public {
|
||||||
|
uint256 first_mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testSetTokenName() public {}
|
uint256 second_mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testSetTokenDescription() public {}
|
assertEq(first_mint, 0);
|
||||||
|
assertEq(second_mint, 1);
|
||||||
|
}
|
||||||
|
|
||||||
function testSetTokenImage() public {}
|
function testMintingMoreThanOneTokenForTheSameAddress() public {
|
||||||
|
uint256 first_mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testSetTokenExternalURL() public {}
|
assertEq(first_mint, 0);
|
||||||
|
|
||||||
function testSetTokenBuild() public {}
|
uint256 second_mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App 2",
|
||||||
|
"This is a test application submitted by foundry tests [2].",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testUpgradeTokenBuild() public {}
|
assertEq(second_mint, 1);
|
||||||
|
}
|
||||||
|
|
||||||
function testSetTokenENS() public {}
|
function testMintingTwoTokensForTwoAddresses() public {
|
||||||
|
uint256 first_mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
function testAddTokenController() public {}
|
assertEq(first_mint, 0);
|
||||||
|
|
||||||
function testRemoveTokenController() public {}
|
uint256 second_mint = fleekContract.mint(
|
||||||
|
address(12),
|
||||||
|
"Foundry Test App 2",
|
||||||
|
"This is a test application submitted by foundry tests[2].",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(second_mint, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testTokenURI() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
string memory tokenURI = fleekContract.tokenURI(mint);
|
||||||
|
|
||||||
|
bytes memory dataURI = abi.encodePacked(
|
||||||
|
"{",
|
||||||
|
'"name":"Foundry Test App",',
|
||||||
|
'"description":"This is a test application submitted by foundry tests.",',
|
||||||
|
'"owner":"',
|
||||||
|
Strings.toHexString(uint160(DEPLOYER), 20),
|
||||||
|
'",',
|
||||||
|
'"external_url":"https://fleek.xyz",',
|
||||||
|
'"image":"https://fleek.xyz",',
|
||||||
|
'"attributes": [',
|
||||||
|
'{"trait_type": "ENS", "value":"fleek_xyz"},',
|
||||||
|
'{"trait_type": "Commit Hash", "value":"afff3f6"},',
|
||||||
|
'{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},',
|
||||||
|
'{"trait_type": "Version", "value":"0"}',
|
||||||
|
"]",
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(
|
||||||
|
tokenURI,
|
||||||
|
string(
|
||||||
|
abi.encodePacked(
|
||||||
|
"data:application/json;base64,",
|
||||||
|
Base64.encode((dataURI))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testCallingTokenURIAfterChangingAllPossibleFields() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenName(mint, "Foundry Test App 2");
|
||||||
|
fleekContract.setTokenDescription(
|
||||||
|
mint,
|
||||||
|
"This is a test application submitted by foundry tests. 2"
|
||||||
|
);
|
||||||
|
fleekContract.setTokenImage(mint, "https://fleek2.xyz");
|
||||||
|
fleekContract.setTokenExternalURL(mint, "https://fleek2.xyz");
|
||||||
|
fleekContract.setTokenENS(mint, "fleek_xyz2");
|
||||||
|
fleekContract.setTokenBuild(
|
||||||
|
mint,
|
||||||
|
"afff3f62",
|
||||||
|
"https://github.com/fleekxyz/contracts2"
|
||||||
|
);
|
||||||
|
|
||||||
|
string memory tokenURI = fleekContract.tokenURI(mint);
|
||||||
|
|
||||||
|
bytes memory dataURI = abi.encodePacked(
|
||||||
|
"{",
|
||||||
|
'"name":"Foundry Test App 2",',
|
||||||
|
'"description":"This is a test application submitted by foundry tests. 2",',
|
||||||
|
'"owner":"',
|
||||||
|
Strings.toHexString(uint160(DEPLOYER), 20),
|
||||||
|
'",',
|
||||||
|
'"external_url":"https://fleek2.xyz",',
|
||||||
|
'"image":"https://fleek2.xyz",',
|
||||||
|
'"attributes": [',
|
||||||
|
'{"trait_type": "ENS", "value":"fleek_xyz2"},',
|
||||||
|
'{"trait_type": "Commit Hash", "value":"afff3f62"},',
|
||||||
|
'{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},',
|
||||||
|
'{"trait_type": "Version", "value":"1"}',
|
||||||
|
"]",
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(
|
||||||
|
tokenURI,
|
||||||
|
string(
|
||||||
|
abi.encodePacked(
|
||||||
|
"data:application/json;base64,",
|
||||||
|
Base64.encode((dataURI))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenName(mint, "Foundry Test App 2");
|
||||||
|
fleekContract.setTokenDescription(
|
||||||
|
mint,
|
||||||
|
"This is a test application submitted by foundry tests. 2"
|
||||||
|
);
|
||||||
|
fleekContract.setTokenImage(mint, "https://fleek2.xyz");
|
||||||
|
fleekContract.setTokenExternalURL(mint, "https://fleek2.xyz");
|
||||||
|
fleekContract.setTokenENS(mint, "fleek_xyz2");
|
||||||
|
fleekContract.setTokenBuild(
|
||||||
|
mint,
|
||||||
|
"afff3f62",
|
||||||
|
"https://github.com/fleekxyz/contracts2"
|
||||||
|
);
|
||||||
|
|
||||||
|
string memory tokenURI = fleekContract.tokenURI(mint);
|
||||||
|
|
||||||
|
bytes memory dataURI = abi.encodePacked(
|
||||||
|
"{",
|
||||||
|
'"name":"Foundry Test App 2",',
|
||||||
|
'"description":"This is a test application submitted by foundry tests. 2",',
|
||||||
|
'"owner":"',
|
||||||
|
Strings.toHexString(uint160(DEPLOYER), 20),
|
||||||
|
'",',
|
||||||
|
'"external_url":"https://fleek2.xyz",',
|
||||||
|
'"image":"https://fleek2.xyz",',
|
||||||
|
'"attributes": [',
|
||||||
|
'{"trait_type": "ENS", "value":"fleek_xyz2"},',
|
||||||
|
'{"trait_type": "Commit Hash", "value":"afff3f62"},',
|
||||||
|
'{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},',
|
||||||
|
'{"trait_type": "Version", "value":"1"}',
|
||||||
|
"]",
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(
|
||||||
|
tokenURI,
|
||||||
|
string(
|
||||||
|
abi.encodePacked(
|
||||||
|
"data:application/json;base64,",
|
||||||
|
Base64.encode((dataURI))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailCallingTokenURIOnNonExistantToken() public {
|
||||||
|
bytes memory dataURI = abi.encodePacked(
|
||||||
|
"{",
|
||||||
|
'"name":"Foundry Test App",',
|
||||||
|
'"description":"This is a test application submitted by foundry tests.",',
|
||||||
|
'"owner":"',
|
||||||
|
Strings.toHexString(uint160(DEPLOYER), 20),
|
||||||
|
'",',
|
||||||
|
'"external_url":"https://fleek.xyz",',
|
||||||
|
'"image":"https://fleek.xyz",',
|
||||||
|
'"attributes": [',
|
||||||
|
'{"trait_type": "ENS", "value":"fleek_xyz"},',
|
||||||
|
'{"trait_type": "Commit Hash", "value":"afff3f6"},',
|
||||||
|
'{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},',
|
||||||
|
'{"trait_type": "Version", "value":"0"}',
|
||||||
|
"]",
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(
|
||||||
|
fleekContract.tokenURI(0),
|
||||||
|
string(
|
||||||
|
abi.encodePacked(
|
||||||
|
"data:application/json;base64,",
|
||||||
|
Base64.encode((dataURI))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testBurn() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.burn(mint);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailBurningNonExistantToken() public {
|
||||||
|
fleekContract.burn(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailBurnAnotherUsersTokenWithoutAccess() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.burn(mint);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailTokenControllerAttemptsToBurnToken() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.burn(mint);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenName() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenName(mint, "NEW TOKEN NAME!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenNameOnAnotherUsersTokenWithoutAccess() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenName(mint, "NEW TOKEN NAME!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenDescription() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenDescription(mint, "NEW TOKEN NAME!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenDescriptionOnAnotherUsersTokenWithoutAccess()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenDescription(mint, "NEW TOKEN NAME!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenImage() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenImage(mint, "https://ethereum.org");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenImageOnAnotherUsersTokenWithoutAccess() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenImage(mint, "https://ethereum.org");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenExternalURL() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenExternalURL(mint, "https://ethereum.org");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenExternalURLOnAnotherUsersTokenWithoutAccess()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenExternalURL(mint, "https://ethereum.org");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenBuild() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenBuild(
|
||||||
|
mint,
|
||||||
|
"aaaaaaa",
|
||||||
|
"https://github.com/fleekxyz/test_contracts"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenBuildOnAnotherUsersTokenWithoutAccess() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenBuild(
|
||||||
|
mint,
|
||||||
|
"aaaaaaa",
|
||||||
|
"https://github.com/fleekxyz/test_contracts"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetTokenENS() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.setTokenENS(mint, "fleek_nfts");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailSetTokenENSOnAnotherUsersTokenWithoutAccess() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.setTokenENS(mint, "fleek_nfts");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testAddTokenController() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailAddTokenControllerOnAnotherUsersTokenWithoutAccess()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testAddTokenControllerTwice() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testRemoveTokenController() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailRemoveTokenControllerOnAnotherUsersTokenWithoutAccess()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0x91A425C1CA320A99a09BE1bee114Fce5d30153d9
|
||||||
|
);
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0x91A425C1CA320A99a09BE1bee114Fce5d30153d9
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testRemoveTokenControllerTwice() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testRemoveUnknownTokenController() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailRemoveUnknownTokenControllerFromUnknownToken() public {
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
0,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFailRemoveTokenOwnerByTokenController() public {
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
fleekContract.grantTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
|
||||||
|
);
|
||||||
|
vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84));
|
||||||
|
fleekContract.revokeTokenRole(
|
||||||
|
mint,
|
||||||
|
FleekAccessControl.Roles.Controller,
|
||||||
|
DEPLOYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testBalanceOfDeployerAfterAndBeforeMinting() public {
|
||||||
|
assertEq(fleekContract.balanceOf(DEPLOYER), 0);
|
||||||
|
|
||||||
|
uint256 mint = fleekContract.mint(
|
||||||
|
DEPLOYER,
|
||||||
|
"Foundry Test App",
|
||||||
|
"This is a test application submitted by foundry tests.",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"https://fleek.xyz",
|
||||||
|
"fleek_xyz",
|
||||||
|
"afff3f6",
|
||||||
|
"https://github.com/fleekxyz/contracts"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEq(mint, 0);
|
||||||
|
|
||||||
|
assertEq(fleekContract.balanceOf(DEPLOYER), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
yarn.lock
30
yarn.lock
|
|
@ -415,9 +415,9 @@
|
||||||
integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==
|
integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==
|
||||||
|
|
||||||
"@noble/hashes@~1.1.1":
|
"@noble/hashes@~1.1.1":
|
||||||
version "1.1.4"
|
version "1.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.4.tgz#2611ebf5764c1bf754da7c7794de4fb30512336d"
|
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.5.tgz#1a0377f3b9020efe2fae03290bd2a12140c95c11"
|
||||||
integrity sha512-+PYsVPrTSqtVjatKt2A/Proukn2Yrz61OBThOCKErc5w2/r1Fh37vbDv0Eah7pyNltrmacjwTvdw3JoR+WE4TA==
|
integrity sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==
|
||||||
|
|
||||||
"@noble/secp256k1@1.6.3", "@noble/secp256k1@~1.6.0":
|
"@noble/secp256k1@1.6.3", "@noble/secp256k1@~1.6.0":
|
||||||
version "1.6.3"
|
version "1.6.3"
|
||||||
|
|
@ -934,9 +934,9 @@
|
||||||
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
|
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
|
||||||
|
|
||||||
"@types/node@*":
|
"@types/node@*":
|
||||||
version "18.11.15"
|
version "18.11.17"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.15.tgz#de0e1fbd2b22b962d45971431e2ae696643d3f5d"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.17.tgz#5c009e1d9c38f4a2a9d45c0b0c493fe6cdb4bcb5"
|
||||||
integrity sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw==
|
integrity sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==
|
||||||
|
|
||||||
"@types/node@^10.0.3":
|
"@types/node@^10.0.3":
|
||||||
version "10.17.60"
|
version "10.17.60"
|
||||||
|
|
@ -1033,9 +1033,9 @@ acorn@^8.4.1:
|
||||||
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==
|
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==
|
||||||
|
|
||||||
address@^1.0.1:
|
address@^1.0.1:
|
||||||
version "1.2.1"
|
version "1.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/address/-/address-1.2.1.tgz#25bb61095b7522d65b357baa11bc05492d4c8acd"
|
resolved "https://registry.yarnpkg.com/address/-/address-1.2.2.tgz#2b5248dac5485a6390532c6a517fda2e3faac89e"
|
||||||
integrity sha512-B+6bi5D34+fDYENiH5qOlA0cV2rAGKuWZ9LeyUUehbXy8e0VS9e498yO0Jeeh+iM+6KbfudHTFjXw2MmJD4QRA==
|
integrity sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==
|
||||||
|
|
||||||
adm-zip@^0.4.16:
|
adm-zip@^0.4.16:
|
||||||
version "0.4.16"
|
version "0.4.16"
|
||||||
|
|
@ -3444,9 +3444,9 @@ ieee754@^1.1.13, ieee754@^1.2.1:
|
||||||
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
|
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
|
||||||
|
|
||||||
ignore@^5.1.1:
|
ignore@^5.1.1:
|
||||||
version "5.2.1"
|
version "5.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.1.tgz#c2b1f76cb999ede1502f3a226a9310fdfe88d46c"
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
|
||||||
integrity sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==
|
integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==
|
||||||
|
|
||||||
immutable@^4.0.0-rc.12:
|
immutable@^4.0.0-rc.12:
|
||||||
version "4.1.0"
|
version "4.1.0"
|
||||||
|
|
@ -5130,9 +5130,9 @@ rustbn.js@~0.2.0:
|
||||||
integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==
|
integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==
|
||||||
|
|
||||||
rxjs@^7.5.7:
|
rxjs@^7.5.7:
|
||||||
version "7.6.0"
|
version "7.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.6.0.tgz#361da5362b6ddaa691a2de0b4f2d32028f1eb5a2"
|
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.0.tgz#90a938862a82888ff4c7359811a595e14e1e09a4"
|
||||||
integrity sha512-DDa7d8TFNUalGC9VqXvQ1euWNN7sc63TrUCuM9J998+ViviahMIjKSOU7rfcgFOF+FCD71BhDRv4hrFz+ImDLQ==
|
integrity sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib "^2.1.0"
|
tslib "^2.1.0"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue