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)"); + }); + }); + }); });