diff --git a/contracts/LottFund.sol b/contracts/LottFund.sol index 65206ab..635dd96 100644 --- a/contracts/LottFund.sol +++ b/contracts/LottFund.sol @@ -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, @@ -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); } @@ -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; diff --git a/test/integration/concrete/lottFund/LottFundTest_BatchBid.t.sol b/test/integration/concrete/lottFund/LottFundTest_BatchBid.t.sol index 475a171..0197a87 100644 --- a/test/integration/concrete/lottFund/LottFundTest_BatchBid.t.sol +++ b/test/integration/concrete/lottFund/LottFundTest_BatchBid.t.sol @@ -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); @@ -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); diff --git a/test/integration/concrete/lottFund/LottFundTest_Bid.t.sol b/test/integration/concrete/lottFund/LottFundTest_Bid.t.sol index 719a940..f5d5852 100644 --- a/test/integration/concrete/lottFund/LottFundTest_Bid.t.sol +++ b/test/integration/concrete/lottFund/LottFundTest_Bid.t.sol @@ -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);