The protocol states that settling an auction without bids should return the NFT back to the seller. However, the protocol reverts and the NFT is locked.
The following test case proves that the protocol reverts when trying to settle an auction without bids
function test_reverts_when_trying_to_settle_without_bids() public {
vm.prank(PROTOCOL_OWNER);
nft.mint(SELLER);
assertEq(nft.ownerOf(0), SELLER);
vm.startPrank(SELLER);
nft.approve(address(market), 0);
vm.expectEmit(true, true, true, true);
emit NftListed(0, SELLER, MIN_PRICE + 1, 0);
market.listNFT(0, MIN_PRICE + 1, 0);
vm.stopPrank();
assertEq(nft.ownerOf(0), address(market));
BidBeastsNFTMarket.Listing memory listing = market.getListing(0);
assertEq(listing.listed, true);
assertEq(listing.seller, SELLER);
assertEq(listing.minPrice, MIN_PRICE + 1);
assertEq(listing.buyNowPrice, 0);
assertEq(listing.auctionEnd, 0);
BidBeastsNFTMarket.Bid memory bid = market.getHighestBid(0);
assertEq(bid.bidder, address(0));
assertEq(bid.amount, 0);
vm.warp(5 days);
vm.startPrank(BIDDER_2);
vm.expectRevert('Auction has not started (no bids)');
market.settleAuction(0);
vm.stopPrank();
}
function settleAuction(uint256 tokenId) external isListed(tokenId) {
Listing storage listing = listings[tokenId];
- require(listing.auctionEnd > 0, "Auction has not started (no bids)");
+ if(listing.auctionEnd) { _unlistNFT(tokenId); }
require(block.timestamp >= listing.auctionEnd, "Auction has not ended");
require(bids[tokenId].amount >= listing.minPrice, "Highest bid did not meet min price");
_executeSale(tokenId);
}