mirror of
https://github.com/supleed2/COMP70017-PoDL-CW.git
synced 2024-12-22 05:35:50 +00:00
Fix expiry boundry condition
This commit is contained in:
parent
3afe735333
commit
dfde0b0320
|
@ -121,7 +121,7 @@ contract TicketNFT is ITicketNFT, IPrimaryMarket, ISecondaryMarket {
|
|||
require(ticketID <= _totalSupply, "setUsed: ticket doesn't exist");
|
||||
require(_ticketUsed[ticketID] == false, "setUsed: ticket already used");
|
||||
require(
|
||||
_expiryTimes[ticketID] > block.timestamp,
|
||||
_expiryTimes[ticketID] >= block.timestamp,
|
||||
"setUsed: ticket expired"
|
||||
);
|
||||
_ticketUsed[ticketID] = true;
|
||||
|
@ -133,7 +133,7 @@ contract TicketNFT is ITicketNFT, IPrimaryMarket, ISecondaryMarket {
|
|||
"isExpiredOrUsed: ticket doesn't exist"
|
||||
);
|
||||
return (_ticketUsed[ticketID] ||
|
||||
_expiryTimes[ticketID] <= block.timestamp);
|
||||
_expiryTimes[ticketID] < block.timestamp);
|
||||
}
|
||||
|
||||
function admin() external view returns (address) {
|
||||
|
@ -159,7 +159,7 @@ contract TicketNFT is ITicketNFT, IPrimaryMarket, ISecondaryMarket {
|
|||
);
|
||||
require(
|
||||
_ticketUsed[ticketID] == false &&
|
||||
_expiryTimes[ticketID] > block.timestamp,
|
||||
_expiryTimes[ticketID] >= block.timestamp,
|
||||
"listTicket: ticket is expired/used"
|
||||
);
|
||||
require(price > 0, "listTicket: price cannot be 0");
|
||||
|
@ -179,7 +179,7 @@ contract TicketNFT is ITicketNFT, IPrimaryMarket, ISecondaryMarket {
|
|||
uint256 ticketRevenue = ticketPrice - ticketFee;
|
||||
require(
|
||||
_ticketUsed[ticketID] == false &&
|
||||
_expiryTimes[ticketID] > block.timestamp,
|
||||
_expiryTimes[ticketID] >= block.timestamp,
|
||||
"purchase: ticket is expired/used"
|
||||
);
|
||||
require(
|
||||
|
|
|
@ -220,7 +220,7 @@ contract TicketNFTTest is BaseTicketNFTTest {
|
|||
function testExpiry() public {
|
||||
_buyTicket(alice, "alice");
|
||||
assertEq(nft.isExpiredOrUsed(1), false);
|
||||
vm.warp(block.timestamp + 10 days - 1);
|
||||
vm.warp(block.timestamp + 10 days);
|
||||
assertEq(nft.isExpiredOrUsed(1), false);
|
||||
vm.warp(block.timestamp + 1);
|
||||
assertEq(nft.isExpiredOrUsed(1), true);
|
||||
|
@ -253,7 +253,7 @@ contract TicketNFTTest is BaseTicketNFTTest {
|
|||
function testSetUsedExpired() public {
|
||||
_buyTicket(alice, "alice");
|
||||
assertEq(nft.isExpiredOrUsed(1), false);
|
||||
vm.warp(block.timestamp + 10 days);
|
||||
vm.warp(block.timestamp + 10 days + 1);
|
||||
vm.prank(address(this));
|
||||
vm.expectRevert("setUsed: ticket expired");
|
||||
nft.setUsed(1);
|
||||
|
@ -377,7 +377,7 @@ contract SecondaryMarketTest is BaseTicketNFTTest {
|
|||
|
||||
function testListExpired() public {
|
||||
_buyTicket(alice, "alice");
|
||||
vm.warp(block.timestamp + 10 days);
|
||||
vm.warp(block.timestamp + 10 days + 1);
|
||||
vm.prank(alice);
|
||||
vm.expectRevert("listTicket: ticket is expired/used");
|
||||
nft.listTicket(1, 200e19);
|
||||
|
@ -473,7 +473,7 @@ contract SecondaryMarketTest is BaseTicketNFTTest {
|
|||
vm.prank(alice);
|
||||
nft.listTicket(1, 200e18);
|
||||
_topUpTokens(bob, 2);
|
||||
vm.warp(block.timestamp + 10 days);
|
||||
vm.warp(block.timestamp + 10 days + 1);
|
||||
vm.prank(bob);
|
||||
token.approve(address(nft), 200e18);
|
||||
vm.prank(bob);
|
||||
|
|
Loading…
Reference in a new issue