Skip to content

Commit

Permalink
[#6] Add test for registry: return false if invalid interfaceId is pa…
Browse files Browse the repository at this point in the history
…ssed
  • Loading branch information
akshay-ap committed Jul 7, 2023
1 parent 26a7d11 commit 44b0747
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/SafeProtocolRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,22 @@ describe("SafeProtocolRegistry", async () => {

it("Should return true when valid interfaceId is passed", async () => {
const { safeProtocolRegistry } = await loadFixture(deployContractFixture);
expect(await safeProtocolRegistry.supportsInterface("0x01ffc9a7")).to.be.equal(true);
expect(await safeProtocolRegistry.supportsInterface("0xc23697a8")).to.be.equal(true);
expect(await safeProtocolRegistry.supportsInterface("0x01ffc9a7")).to.be.true;
expect(await safeProtocolRegistry.supportsInterface("0xc23697a8")).to.be.true;
});

it("Should return false when invalid interfaceId is passed", async () => {
const { safeProtocolRegistry } = await loadFixture(deployContractFixture);
expect(await safeProtocolRegistry.supportsInterface("0x00000000")).to.be.false;

// Generate random interfaceId remove supported interfaceIds
const excludedWords = ["0x01ffc9a7", "0xc23697a8"];
const randomHexString =
"0x" +
(Math.random().toString(16).slice(2, 10) + "00000000")
.substring(0, 8)
.replace(new RegExp(`(${excludedWords.join("|")})|0x`, "gi"), "");

expect(await safeProtocolRegistry.supportsInterface(randomHexString)).to.be.false;
});
});

0 comments on commit 44b0747

Please sign in to comment.