Skip to content

Commit

Permalink
cannot bid during pauseBids
Browse files Browse the repository at this point in the history
  • Loading branch information
drikssy committed Oct 29, 2024
1 parent 7402400 commit f793486
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions contracts/LottFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ contract LottFund is VRFConsumerBaseV2Plus, ILottFund, AddressProviderResolver,
error LottFund__TokenBidAmountDepleted();
error LottFund__TokenCannotBeBidded();
error LottFund__AddressHasBiddedTooManyTimes(address caller);
error LottFund__BiddingIsPaused();

constructor(
address addressProvider,
Expand Down Expand Up @@ -121,6 +122,7 @@ contract LottFund is VRFConsumerBaseV2Plus, ILottFund, AddressProviderResolver,
}

function bid(uint256 tokenId) public whenNotPaused nonReentrant {
if (pausedBids) revert LottFund__BiddingIsPaused();
if (bidCountPerRound[currentRound][msg.sender] >= maxBidsPerAddress) {
revert LottFund__AddressHasBiddedTooManyTimes(msg.sender);
}
Expand All @@ -146,6 +148,7 @@ contract LottFund is VRFConsumerBaseV2Plus, ILottFund, AddressProviderResolver,
}

function batchBid(uint256[] memory tokenIds) public whenNotPaused nonReentrant {
if (pausedBids) revert LottFund__BiddingIsPaused();
ITraitForgeNft traitForgeNft = _getTraitForgeNft();
address sender = msg.sender;

Expand Down
14 changes: 13 additions & 1 deletion test/integration/concrete/lottFund/LottFundTest_BatchBid.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LottFundTest } from "test/integration/concrete/lottFund/LottFundTest.t.
import { LottFund } from "contracts/LottFund.sol";

contract LottFundTest_BatchBid is LottFundTest {
function testRevert_lottFund_Batchbid_whenPaused() public {
function testRevert_lottFund_batchBid_whenPaused() public {
vm.prank(_protocolMaintainer);
_lottFund.pause();
uint256[] memory tokenIds = new uint256[](1);
Expand All @@ -16,6 +16,18 @@ contract LottFundTest_BatchBid is LottFundTest {
_lottFund.batchBid(tokenIds);
}

function testRevert_lottFund_batchBid_whenPausedBids() public {
vm.prank(_protocolMaintainer);
_lottFund.setPausedBids(true);

uint256[] memory tokenIds = new uint256[](1);
tokenIds[0] = 1;

vm.expectRevert(LottFund.LottFund__BiddingIsPaused.selector);
vm.prank(_randomUser);
_lottFund.batchBid(tokenIds);
}

function testRevert_lottFund_batchBid_whenCallerAddressHasBiddedTwoManyTimes() public {
uint256 maxBidsPerAddress = _lottFund.maxBidsPerAddress();
_mintTraitForgeNft(user, 1000);
Expand Down
9 changes: 9 additions & 0 deletions test/integration/concrete/lottFund/LottFundTest_Bid.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ contract LottFundTest_Bid is LottFundTest {
_lottFund.bid(1);
}

function testRevert_lottFund_bid_whenPausedBids() public {
vm.prank(_protocolMaintainer);
_lottFund.setPausedBids(true);

vm.expectRevert(LottFund.LottFund__BiddingIsPaused.selector);
vm.prank(_randomUser);
_lottFund.bid(1);
}

function testRevert_lottFund_bid_whenCallerAddressHasBiddedTwoManyTimes() public {
uint256 maxBidsPerAddress = _lottFund.maxBidsPerAddress();
_mintTraitForgeNft(user, 1000);
Expand Down

0 comments on commit f793486

Please sign in to comment.