forked from DECA/DECANFT-SC
Test Enumerable first test
This commit is contained in:
parent
4745da5330
commit
368f029a77
|
@ -6,9 +6,11 @@ import {DCO2s} from "../src/DCO2s.sol";
|
|||
|
||||
contract DCO2sTest is Test {
|
||||
DCO2s public dco2sc;
|
||||
string public baseURL;
|
||||
|
||||
function setUp() public {
|
||||
dco2sc = new DCO2s(address(this), address(this), "DCO2s", "DCO2");
|
||||
baseURL = "https://gateway.decentralizedscience.org/ipfs/";
|
||||
}
|
||||
|
||||
// @notice this code safe mints an NFT to address 0x1
|
||||
|
@ -18,14 +20,29 @@ contract DCO2sTest is Test {
|
|||
assertEq(dco2sc.ownerOf(0), to, "Token should be minted to specified address.");
|
||||
}
|
||||
|
||||
function testMintFromEnv() public {
|
||||
address to = address(0x1);
|
||||
string memory nft68 = vm.envString("NFT68");
|
||||
dco2sc.safeMint(to,nft68);
|
||||
assertEq(dco2sc.ownerOf(0), to, "Token should be minted to specified address.");
|
||||
}
|
||||
|
||||
// @notice: here we test getting the Base and full URIS
|
||||
function testGetURI68() public {
|
||||
string memory URI = vm.envString("NFT68");
|
||||
dco2sc.safeMint(address(1), URI);
|
||||
string memory tokenURI = dco2sc.tokenURI(0);
|
||||
console.log(tokenURI);
|
||||
assertEq(tokenURI, string.concat(baseURL, URI));
|
||||
}
|
||||
|
||||
// @notice: here we test getting the Base and full URIS
|
||||
function testGetURI() public {
|
||||
string memory _baseURL = "https://gateway.decentralizedscience.org/ipfs/";
|
||||
string memory URI = "bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa";
|
||||
dco2sc.safeMint(address(1), URI);
|
||||
string memory tokenURI = dco2sc.tokenURI(0);
|
||||
console.log(tokenURI);
|
||||
assertEq(tokenURI, string.concat(_baseURL,URI));
|
||||
assertEq(tokenURI, string.concat(baseURL,URI));
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,6 +58,33 @@ contract DCO2sTest is Test {
|
|||
|
||||
// @notice use the basic Enumerable properties
|
||||
// function testEnumerable() public {}
|
||||
function testEnumerableTokenByIndex() public {
|
||||
string[5] memory nfts = [
|
||||
"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa",
|
||||
"bafkreifqztiwfutjik4wfs3gyfdyrff7cugi4mcctluunrrbp5cgareisq",
|
||||
"bafkreibffiehtv4ntajq5vjwpl7q44i6cjbg54lm5hkoa665ue2taspiyu",
|
||||
"bafkreidcf5baqb5wevs6vyd7dtd3j7rzrq65uyqasj4dbkcy6na4ig3ay",
|
||||
"bafkreiglyvpxwrxdvruit3oiw2lvkxqqxn7ojquw4gl7ck6szewz6t6cam"];
|
||||
|
||||
for(uint i; i < nfts.length; i++){
|
||||
dco2sc.safeMint(address(1), nfts[i]);
|
||||
}
|
||||
|
||||
assertEq(nfts.length, dco2sc.totalSupply());
|
||||
|
||||
// Test for token By Index 4
|
||||
uint tokenID = dco2sc.tokenByIndex(4);
|
||||
assertEq(nfts[4], nfts[tokenID]);
|
||||
|
||||
// Test for token By Index 3
|
||||
tokenID = dco2sc.tokenByIndex(3);
|
||||
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: testFailMintToZeroAddress test that cannot safe mint to address 0
|
||||
function testFailMintToZeroAddress() public {
|
||||
|
|
Loading…
Reference in New Issue