From 1e01d18ec03f44a788eccd73313eacaf76fe3f64 Mon Sep 17 00:00:00 2001 From: zuies Date: Thu, 6 Jun 2024 14:27:00 +0300 Subject: [PATCH] close #30 --- contracts/Engagement.sol | 6 +++++- test/engagements.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/contracts/Engagement.sol b/contracts/Engagement.sol index ccd1c32..029c039 100644 --- a/contracts/Engagement.sol +++ b/contracts/Engagement.sol @@ -64,7 +64,11 @@ contract EngagementContract is IEngagement, ERC1155, AccessControl { uint date, uint id, string memory account - ) external view override returns (string memory) {} + ) external view override returns (string memory) { + if (id >= _counter) { + revert NotFound(id); + } + } function updateScores(uint date, string memory cid) external override {} diff --git a/test/engagements.ts b/test/engagements.ts index 136c3aa..59b6ed1 100644 --- a/test/engagements.ts +++ b/test/engagements.ts @@ -310,4 +310,23 @@ describe("Engage", function () { }); }); }); + + describe("Get score", function () { + describe("Revert", async function () { + it("Should revert with NotFound (token doesn't exist)", async function () { + const { contract, otherAccount } = await loadFixture(deployFixture); + const date = BigInt(new Date().getTime()); + const tokenId = parseUnits("999", 0); + + await expect( + contract.read.getScores( + [date, tokenId, getAddress(otherAccount.account.address)], + { + account: otherAccount.account.address, + } + ) + ).to.be.rejectedWith("NotFound(999)"); + }); + }); + }); });