forked from DECA/DECANFT-SC
develop #2
|
@ -22,18 +22,18 @@ contract DCO2sTest is Test {
|
||||||
|
|
||||||
function testMintFromEnv() public {
|
function testMintFromEnv() public {
|
||||||
address to = address(0x1);
|
address to = address(0x1);
|
||||||
string memory nft68 = vm.envString("NFT68");
|
string memory nft0 = vm.envString("nfts");
|
||||||
dco2sc.safeMint(to,nft68);
|
dco2sc.safeMint(to,nft0);
|
||||||
assertEq(dco2sc.ownerOf(0), to, "Token should be minted to specified address.");
|
assertEq(dco2sc.ownerOf(0), to, "Token should be minted to specified address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice: here we test getting the Base and full URIS
|
// @notice: here we test getting the Base and full URIS
|
||||||
function testGetURI68() public {
|
function testGetURI68() public {
|
||||||
string memory URI = vm.envString("NFT68");
|
string[] memory URIs = vm.envString("nfts", ' ');
|
||||||
dco2sc.safeMint(address(1), URI);
|
dco2sc.safeMint(address(1), URIs[68]);
|
||||||
string memory tokenURI = dco2sc.tokenURI(0);
|
string memory tokenURI = dco2sc.tokenURI(0);
|
||||||
console.log(tokenURI);
|
//console.log(tokenURI);
|
||||||
assertEq(tokenURI, string.concat(baseURL, URI));
|
assertEq(tokenURI, string.concat(baseURL, URIs[68]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice: here we test getting the Base and full URIS
|
// @notice: here we test getting the Base and full URIS
|
||||||
|
@ -41,13 +41,12 @@ contract DCO2sTest is Test {
|
||||||
string memory URI = "bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa";
|
string memory URI = "bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa";
|
||||||
dco2sc.safeMint(address(1), URI);
|
dco2sc.safeMint(address(1), URI);
|
||||||
string memory tokenURI = dco2sc.tokenURI(0);
|
string memory tokenURI = dco2sc.tokenURI(0);
|
||||||
console.log(tokenURI);
|
//console.log(tokenURI);
|
||||||
assertEq(tokenURI, string.concat(baseURL,URI));
|
assertEq(tokenURI, string.concat(baseURL,URI));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice: checkFailed token Index
|
// @notice: checkFailed token Index
|
||||||
function testFailTokenIndex() public {
|
function testFailTokenIndex() view public {
|
||||||
dco2sc.tokenURI(0);
|
dco2sc.tokenURI(0);
|
||||||
}
|
}
|
||||||
// @notice: checkFailed token Index
|
// @notice: checkFailed token Index
|
||||||
|
@ -56,14 +55,29 @@ contract DCO2sTest is Test {
|
||||||
// dco2sc.tokenURI(0);
|
// dco2sc.tokenURI(0);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// @notice use the basic Enumerable properties
|
// @notice use basic Enumerable properties totalSupply
|
||||||
// function testEnumerable() public {}
|
function testEnumerableTotalSupply() public {
|
||||||
|
string[5] memory nfts = [
|
||||||
|
"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa",
|
||||||
|
"bafkreifqztiwfutjik4wfs3gyfdyrff7cugi4mcctluunrrbp5cgareisq",
|
||||||
|
"bafkreibffiehtv4ntajq5vjwpl7q44i6cjbg54lm5hkoa665ue2taspiyu",
|
||||||
|
"bafkreidcf5baqb5wevs6vyd7dtd3j7rzrq65uyqasj4dbkcy5na4ig3ay",
|
||||||
|
"bafkreiglyvpxwrxdvruit3oiw2lvkxqqxn7ojquw4gl7ck6szewz6t6cam"];
|
||||||
|
|
||||||
|
for(uint i; i < nfts.length; i++){
|
||||||
|
dco2sc.safeMint(address(1), nfts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEq(nfts.length, dco2sc.totalSupply());
|
||||||
|
}
|
||||||
|
|
||||||
|
// @notice use the basic Enumerable property tokenByIndex
|
||||||
function testEnumerableTokenByIndex() public {
|
function testEnumerableTokenByIndex() public {
|
||||||
string[5] memory nfts = [
|
string[5] memory nfts = [
|
||||||
"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa",
|
"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa",
|
||||||
"bafkreifqztiwfutjik4wfs3gyfdyrff7cugi4mcctluunrrbp5cgareisq",
|
"bafkreifqztiwfutjik4wfs3gyfdyrff7cugi4mcctluunrrbp5cgareisq",
|
||||||
"bafkreibffiehtv4ntajq5vjwpl7q44i6cjbg54lm5hkoa665ue2taspiyu",
|
"bafkreibffiehtv4ntajq5vjwpl7q44i6cjbg54lm5hkoa665ue2taspiyu",
|
||||||
"bafkreidcf5baqb5wevs6vyd7dtd3j7rzrq65uyqasj4dbkcy6na4ig3ay",
|
"bafkreidcf5baqb5wevs6vyd7dtd3j7rzrq65uyqasj4dbkcy5na4ig3ay",
|
||||||
"bafkreiglyvpxwrxdvruit3oiw2lvkxqqxn7ojquw4gl7ck6szewz6t6cam"];
|
"bafkreiglyvpxwrxdvruit3oiw2lvkxqqxn7ojquw4gl7ck6szewz6t6cam"];
|
||||||
|
|
||||||
for(uint i; i < nfts.length; i++){
|
for(uint i; i < nfts.length; i++){
|
||||||
|
@ -79,13 +93,39 @@ contract DCO2sTest is Test {
|
||||||
// Test for token By Index 3
|
// Test for token By Index 3
|
||||||
tokenID = dco2sc.tokenByIndex(3);
|
tokenID = dco2sc.tokenByIndex(3);
|
||||||
assertEq(nfts[3], nfts[tokenID]);
|
assertEq(nfts[3], nfts[tokenID]);
|
||||||
|
|
||||||
// Test tokenURI from by ID3
|
|
||||||
string memory tokenURI = dco2sc.tokenURI(tokenID);
|
|
||||||
console.log(tokenURI);
|
|
||||||
assertEq(tokenURI, string.concat(baseURL,nfts[3]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @notice use the basic Enumerable property TokenOfOwnerByIndex
|
||||||
|
function testEnumerableTokenOfOwnerByIndex() public {
|
||||||
|
string[5] memory nfts = [
|
||||||
|
"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa",
|
||||||
|
"bafkreifqztiwfutjik4wfs3gyfdyrff7cugi4mcctluunrrbp5cgareisq",
|
||||||
|
"bafkreibffiehtv4ntajq5vjwpl7q44i6cjbg54lm5hkoa665ue2taspiyu",
|
||||||
|
"bafkreidcf5baqb5wevs6vyd7dtd3j7rzrq65uyqasj4dbkcy5na4ig3ay",
|
||||||
|
"bafkreiglyvpxwrxdvruit3oiw2lvkxqqxn7ojquw4gl7ck6szewz6t6cam"];
|
||||||
|
|
||||||
|
for(uint i; i < nfts.length; i++){
|
||||||
|
if(i % 2 == 0) {
|
||||||
|
dco2sc.safeMint(address(1), nfts[i]);
|
||||||
|
} else {
|
||||||
|
dco2sc.safeMint(address(2), nfts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the balance of NFTs of the account 1
|
||||||
|
uint account1_balance = dco2sc.balanceOf(address(1));
|
||||||
|
assertEq(account1_balance, 3);
|
||||||
|
|
||||||
|
for(uint i; i < account1_balance; i++){
|
||||||
|
// get the TokenID from account NFTs Index
|
||||||
|
uint token_id = dco2sc.tokenOfOwnerByIndex(address(1), i);
|
||||||
|
// console.log("Token ID ", token_id, " has URI: ", dco2sc.tokenURI(token_id));
|
||||||
|
assertEq(dco2sc.tokenURI(token_id), string.concat(baseURL, nfts[token_id]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @notice: testFailMintToZeroAddress test that cannot safe mint to address 0
|
// @notice: testFailMintToZeroAddress test that cannot safe mint to address 0
|
||||||
function testFailMintToZeroAddress() public {
|
function testFailMintToZeroAddress() public {
|
||||||
dco2sc.safeMint(address(0),"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa");
|
dco2sc.safeMint(address(0),"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa");
|
||||||
|
|
Loading…
Reference in New Issue