Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kulkarohan committed Jun 27, 2023
1 parent 1add7b8 commit 5c3eee6
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/ERC721Drop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,66 @@ contract ERC721DropTest is Test {
}
}

function test_PurchaseWithRecipientAndComment(uint64 salePrice, uint32 purchaseQuantity) public setupZoraNFTBase(purchaseQuantity) {
vm.assume(purchaseQuantity < 100 && purchaseQuantity > 0);
vm.prank(DEFAULT_OWNER_ADDRESS);
zoraNFTBase.setSaleConfiguration({
publicSaleStart: 0,
publicSaleEnd: type(uint64).max,
presaleStart: 0,
presaleEnd: 0,
publicSalePrice: salePrice,
maxSalePurchasePerAddress: purchaseQuantity + 1,
presaleMerkleRoot: bytes32(0)
});

(, uint256 zoraFee) = zoraNFTBase.zoraFeeForAmount(purchaseQuantity);
uint256 paymentAmount = uint256(salePrice) * purchaseQuantity + zoraFee;

address minter = makeAddr("minter");
address recipient = makeAddr("recipient");

vm.deal(minter, paymentAmount);

vm.expectEmit(true, true, true, true);
emit MintComment(
minter,
address(zoraNFTBase),
0,
purchaseQuantity,
"test comment"
);
vm.prank(minter);
zoraNFTBase.purchaseWithRecipient{value: paymentAmount}(recipient, purchaseQuantity, "test comment");
}

function testRevert_PurchaseWithInvalidRecipient(uint64 salePrice, uint32 purchaseQuantity) public setupZoraNFTBase(purchaseQuantity) {
vm.assume(purchaseQuantity < 100 && purchaseQuantity > 0);
vm.prank(DEFAULT_OWNER_ADDRESS);
zoraNFTBase.setSaleConfiguration({
publicSaleStart: 0,
publicSaleEnd: type(uint64).max,
presaleStart: 0,
presaleEnd: 0,
publicSalePrice: salePrice,
maxSalePurchasePerAddress: purchaseQuantity + 1,
presaleMerkleRoot: bytes32(0)
});

(, uint256 zoraFee) = zoraNFTBase.zoraFeeForAmount(purchaseQuantity);
uint256 paymentAmount = uint256(salePrice) * purchaseQuantity + zoraFee;


address minter = makeAddr("minter");
address recipient = address(0);

vm.deal(minter, paymentAmount);

vm.expectRevert(abi.encodeWithSignature("MintToZeroAddress()"));
vm.prank(minter);
zoraNFTBase.purchaseWithRecipient{value: paymentAmount}(recipient, purchaseQuantity, "");
}

function test_UpgradeApproved() public setupZoraNFTBase(10) {
address newImpl = address(
new ERC721Drop(
Expand Down

0 comments on commit 5c3eee6

Please sign in to comment.