From b907461ea1871fe656e10133e505d65e01c04c4f Mon Sep 17 00:00:00 2001 From: zuies Date: Thu, 6 Jun 2024 13:23:34 +0300 Subject: [PATCH] close #25 --- contracts/Engagement.sol | 3 +++ test/engagements.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/contracts/Engagement.sol b/contracts/Engagement.sol index 8b98bac..ccd1c32 100644 --- a/contracts/Engagement.sol +++ b/contracts/Engagement.sol @@ -53,6 +53,9 @@ contract EngagementContract is IEngagement, ERC1155, AccessControl { if (account != msg.sender) { revert NotAllowed(account, tokenId); } + if (tokenId >= _counter) { + revert NotFound(tokenId); + } _burn(account, tokenId, 1); emit Burn(account, tokenId, 1); } diff --git a/test/engagements.ts b/test/engagements.ts index 6a57b20..136c3aa 100644 --- a/test/engagements.ts +++ b/test/engagements.ts @@ -295,6 +295,18 @@ describe("Engage", function () { )}", ${tokenId})` ); }); + it("Should revert with NotFound (token doesn't exist)", async function () { + tokenId = parseUnits("999", 0); + + await expect( + contract.write.burn( + [getAddress(otherAccount.account.address), tokenId, amount], + { + account: otherAccount.account.address, + } + ) + ).to.be.rejectedWith("NotFound(999)"); + }); }); }); });