diff --git a/script/DCO2s.s.sol b/script/DCO2s.s.sol new file mode 100644 index 0000000..50eeda7 --- /dev/null +++ b/script/DCO2s.s.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; +import { DCO2s } from "src/DCO2s.sol"; + +contract DCO2sScript is Script { + DCO2s public dco2sc; + + function setUp() public { + dco2sc = new DCO2s(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "DCO2s", "DCO2"); + } + + // run is the entry point + function run() public { + // startBroadcast and stopBraodcast will let us execute transactions anything between them + vm.startBroadcast(); + // here we just need to deploy a new contract + string memory URI = "bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa"; + dco2sc.safeMint(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, URI); + string memory tokenURI = dco2sc.tokenURI(0); + console.log(tokenURI); + vm.stopBroadcast(); + } +} diff --git a/test/DCO2s.t.sol b/test/DCO2s.t.sol index d3a5c8e..cc2076b 100644 --- a/test/DCO2s.t.sol +++ b/test/DCO2s.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; -import {Test, console2} from "forge-std/Test.sol"; +import {Test, console} from "forge-std/Test.sol"; import {DCO2s} from "../src/DCO2s.sol"; contract DCO2sTest is Test { @@ -19,14 +19,32 @@ contract DCO2sTest is Test { } // @notice: here we test getting the Base and full URIS - //function testGetURI() public {} + 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)); + + } + + // @notice: checkFailed token Index + function testFailTokenIndex() public { + dco2sc.tokenURI(0); + } + // @notice: checkFailed token Index + //function testTokenIndex() public { + // vm.expectRevert(bytes("ERC721NonexistentToken(0)")); + // dco2sc.tokenURI(0); + //} // @notice use the basic Enumerable properties // function testEnumerable() public {} // @notice: testFailMintToZeroAddress test that cannot safe mint to address 0 function testFailMintToZeroAddress() public { - dco2sc.safeMint(address(0),"qnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa"); + dco2sc.safeMint(address(0),"bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa"); } // @notice testMintAll mints all the NFTs URIS and distribute to wallets @@ -110,8 +128,6 @@ contract DCO2sTest is Test { // assertEq(NFTs[i], dco2sc.) // } // } - - }