Skip to content

Commit 3587a0d

Browse files
committed
add test case for minting ipnft with POI
1 parent 88368b7 commit 3587a0d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/IPNFT.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser
129129
}
130130

131131
mintAuthorizer.redeem(authorization);
132+
symbol[computedTokenId] = _symbol;
132133
_mint(to, computedTokenId);
133134
_setTokenURI(computedTokenId, _tokenURI);
134135
emit IPNFTMinted(to, computedTokenId, _tokenURI, _symbol);

test/IPNFT.t.sol

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ contract IPNFTTest is IPNFTMintHelper {
7272
assertEq(ipnft.reservations(2), bob);
7373
}
7474

75+
function testMintWithPoi() public {
76+
bytes memory poiHash = "0x5d7ca63d6e6065ef928d3f7cf770062ddd621b84de99732662a71b966db97c3b";
77+
uint256 tokenId = uint256(keccak256(poiHash));
78+
bytes memory authorization = abi.encode("0xsignature");
79+
vm.startPrank(deployer);
80+
ipnft.setAuthorizer(new AcceptAllAuthorizer());
81+
vm.stopPrank();
82+
83+
vm.startPrank(alice);
84+
vm.expectRevert(IPNFT.MintingFeeTooLow.selector);
85+
ipnft.mintWithPOI(alice, poiHash, ipfsUri, DEFAULT_SYMBOL, authorization);
86+
87+
vm.expectEmit(true, true, false, true);
88+
emit IPNFTMinted(alice, tokenId, ipfsUri, DEFAULT_SYMBOL);
89+
ipnft.mintWithPOI{ value: MINTING_FEE }(alice, poiHash, ipfsUri, DEFAULT_SYMBOL, authorization);
90+
assertEq(ipnft.ownerOf(tokenId), alice);
91+
assertEq(ipnft.tokenURI(tokenId), ipfsUri);
92+
assertEq(ipnft.symbol(tokenId), DEFAULT_SYMBOL);
93+
vm.stopPrank();
94+
}
95+
7596
function testMintFromReservation() public {
7697
vm.startPrank(deployer);
7798
ipnft.setAuthorizer(new SignedMintAuthorizer(deployer));
@@ -145,7 +166,6 @@ contract IPNFTTest is IPNFTMintHelper {
145166
/**
146167
* ... but when set as heir of a self destruct operation the contract accepts the money.
147168
*/
148-
149169
function testOwnerCanWithdrawEthFunds() public {
150170
vm.deal(address(bob), 10 ether);
151171
vm.startPrank(bob);
@@ -232,15 +252,13 @@ contract IPNFTTest is IPNFTMintHelper {
232252
//the signoff only allows alice to call this
233253
vm.startPrank(charlie);
234254
vm.expectRevert(IPNFT.Unauthorized.selector);
235-
ipnft.amendMetadata(1, "ipfs://QmNewUri", authorization);
255+
ipnft.amendMetadata(1, "ipfs://QmNewUri", authorization);
236256

237257
vm.startPrank(alice);
238258
vm.expectEmit(true, true, false, false);
239259
emit MetadataUpdate(1);
240-
ipnft.amendMetadata(1, "ipfs://QmNewUri", authorization);
260+
ipnft.amendMetadata(1, "ipfs://QmNewUri", authorization);
241261
assertEq(ipnft.tokenURI(1), "ipfs://QmNewUri");
242262
vm.stopPrank();
243263
}
244-
245-
246264
}

0 commit comments

Comments
 (0)