A user cannot collect their present if they already have one because they have been gifted one.
A user cannot collect their present if they already have one because they have been gifted one.
function testCannotCollectPresentIfGifted() public {
address userCollector = makeAddr("userCollector");
address userGifter = makeAddr("userGifter");
vm.startPrank(santa);
santasList.checkList(userCollector, SantasList.Status.NICE);
santasList.checkTwice(userCollector, SantasList.Status.NICE);
santasList.checkList(userGifter, SantasList.Status.EXTRA_NICE);
santasList.checkTwice(userGifter, SantasList.Status.EXTRA_NICE);
vm.stopPrank();
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() + 1);
vm.startPrank(userGifter);
santasList.collectPresent();
santasList.buyPresent(userGifter);
assertEq(santasList.balanceOf(userGifter), 2);
santasList.transferFrom(userGifter, userCollector, 0);
assertEq(santasList.balanceOf(userGifter), 1);
vm.stopPrank();
vm.startPrank(userCollector);
vm.expectRevert();
santasList.collectPresent();
vm.stopPrank();
assertEq(santasList.balanceOf(userCollector), 1);
}
A user cannot collect their present if they already have one because they have been gifted one.
Manual review.
Track whether users have collected instead of checking their balance.