Skip to content

Commit d610541

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
pull tests from origin
2 parents 1b11a72 + 7878ec3 commit d610541

File tree

1 file changed

+62
-30
lines changed

1 file changed

+62
-30
lines changed

src/test/drop/SignatureDrop.t.sol

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ contract SignatureDropTest is BaseTest {
209209
vm.stopPrank();
210210
}
211211

212+
/*
213+
* note: Fuzz testing; a batch of tokens, and nextTokenIdToMint
214+
*/
215+
function test_fuzz_lazyMint_batchMintAndNextTokenIdToMint(uint256 x) public {
216+
vm.startPrank(deployerSigner);
217+
218+
sigdrop.lazyMint(x, "ipfs://", "");
219+
220+
uint256 slot = stdstore.target(address(sigdrop)).sig("nextTokenIdToMint()").find();
221+
bytes32 loc = bytes32(slot);
222+
uint256 nextTokenIdToMint = uint256(vm.load(address(sigdrop), loc));
223+
224+
assertEq(nextTokenIdToMint, x);
225+
vm.stopPrank();
226+
}
227+
212228
/*///////////////////////////////////////////////////////////////
213229
Delayed Reveal Tests
214230
//////////////////////////////////////////////////////////////*/
@@ -283,6 +299,22 @@ contract SignatureDropTest is BaseTest {
283299
vm.stopPrank();
284300
}
285301

302+
/*
303+
* note: Testing revert condition; already revealed URI.
304+
*/
305+
function test_revert_delayedReveal_alreadyRevealed() public {
306+
vm.startPrank(deployerSigner);
307+
308+
bytes memory encryptedURI = sigdrop.encryptDecrypt("ipfs://", "key");
309+
sigdrop.lazyMint(100, "", encryptedURI);
310+
sigdrop.reveal(0, "key");
311+
312+
vm.expectRevert("nothing to reveal.");
313+
sigdrop.reveal(0, "key");
314+
315+
vm.stopPrank();
316+
}
317+
286318
/*
287319
* note: Testing state changes; revealing URI with an incorrect key.
288320
*/
@@ -608,6 +640,36 @@ contract SignatureDropTest is BaseTest {
608640
Claim Tests
609641
//////////////////////////////////////////////////////////////*/
610642

643+
/**
644+
* note: Testing revert condition; not allowed to claim again before wait time is over.
645+
*/
646+
function test_revert_claimCondition_waitTimeInSecondsBetweenClaims() public {
647+
vm.warp(1);
648+
649+
address receiver = getActor(0);
650+
bytes32[] memory proofs = new bytes32[](0);
651+
652+
SignatureDrop.AllowlistProof memory alp;
653+
alp.proof = proofs;
654+
655+
SignatureDrop.ClaimCondition[] memory conditions = new SignatureDrop.ClaimCondition[](1);
656+
conditions[0].maxClaimableSupply = 100;
657+
conditions[0].quantityLimitPerTransaction = 100;
658+
conditions[0].waitTimeInSecondsBetweenClaims = type(uint256).max;
659+
660+
vm.prank(deployerSigner);
661+
sigdrop.lazyMint(100, "ipfs://", "");
662+
vm.prank(deployerSigner);
663+
sigdrop.setClaimConditions(conditions, false, "");
664+
665+
vm.prank(getActor(5), getActor(5));
666+
sigdrop.claim(receiver, 1, address(0), 0, alp, "");
667+
668+
vm.expectRevert("cannot claim.");
669+
vm.prank(getActor(5), getActor(5));
670+
sigdrop.claim(receiver, 1, address(0), 0, alp, "");
671+
}
672+
611673
/**
612674
* note: Testing state changes; check startId and count after setting claim conditions.
613675
*/
@@ -690,36 +752,6 @@ contract SignatureDropTest is BaseTest {
690752
assertEq(sigdrop.getActiveClaimConditionId(), 2);
691753
}
692754

693-
/**
694-
* note: Testing revert condition; not allowed to claim again before wait time is over.
695-
*/
696-
function test_revert_claimCondition_waitTimeInSecondsBetweenClaims() public {
697-
vm.warp(1);
698-
699-
address receiver = getActor(0);
700-
bytes32[] memory proofs = new bytes32[](0);
701-
702-
SignatureDrop.AllowlistProof memory alp;
703-
alp.proof = proofs;
704-
705-
SignatureDrop.ClaimCondition[] memory conditions = new SignatureDrop.ClaimCondition[](1);
706-
conditions[0].maxClaimableSupply = 100;
707-
conditions[0].quantityLimitPerTransaction = 100;
708-
conditions[0].waitTimeInSecondsBetweenClaims = type(uint256).max;
709-
710-
vm.prank(deployerSigner);
711-
sigdrop.lazyMint(100, "ipfs://", "");
712-
vm.prank(deployerSigner);
713-
sigdrop.setClaimConditions(conditions, false, "");
714-
715-
vm.prank(getActor(5), getActor(5));
716-
sigdrop.claim(receiver, 1, address(0), 0, alp, "");
717-
718-
vm.expectRevert("cannot claim.");
719-
vm.prank(getActor(5), getActor(5));
720-
sigdrop.claim(receiver, 1, address(0), 0, alp, "");
721-
}
722-
723755
/**
724756
* note: Testing state changes; reset eligibility of claim conditions and claiming again for same condition id.
725757
*/

0 commit comments

Comments
 (0)