Added Basic & Mood NFT
CI / Foundry project (push) Waiting to run

This commit is contained in:
2024-08-19 13:34:51 +08:00
parent 11e41de86a
commit b0c330b3a4
17 changed files with 279 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {Test} from "forge-std/Test.sol";
import {BasicNft} from "src/BasicNft.sol";
import {DeployBasicNft} from "script/DeployBasicNft.s.sol";
contract BasicNftTest is Test {
DeployBasicNft public deployer;
BasicNft public basicNft;
address public USER = makeAddr("USER");
string public constant ipfsHoeleeImage =
"ipfs://QmW1aRxvAngY22wrxyrUYSriekkHQMcXA3D1mjHgBc5ge6?filename=MrHoelee.png";
function setUp() public {
deployer = new DeployBasicNft();
basicNft = deployer.run();
}
function testNameIsCorrect() public view {
string memory expectedName = "Hoelee";
string memory actualName = basicNft.name();
// string is array of bytes can't directly compare
// we can compare: bool, uint256, address, bytes32
// Solution: compare the hash of array of bytes
assert(
keccak256(abi.encodePacked(expectedName)) ==
keccak256(abi.encodePacked(actualName))
);
}
function testCanMintAndHaveABalance() public {
vm.prank(USER);
basicNft.mintNft(ipfsHoeleeImage);
assert(basicNft.balanceOf(USER) == 1);
assert(
keccak256(abi.encodePacked(basicNft.tokenURI(0))) ==
keccak256(abi.encodePacked(ipfsHoeleeImage))
);
}
}