Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions test/utils/introspection/SupportsInterface.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const SIGNATURES = {

const INTERFACE_IDS = mapValues(SIGNATURES, interfaceId);

function shouldSupportInterfaces(interfaces = []) {
function shouldSupportInterfaces(interfaces = [], signatures = SIGNATURES, interfaceIds = INTERFACE_IDS) {
interfaces.unshift('ERC165');

describe('ERC165', function () {
Expand All @@ -103,14 +103,14 @@ function shouldSupportInterfaces(interfaces = []) {
describe('when the interfaceId is supported', function () {
it('uses less than 30k gas', async function () {
for (const k of interfaces) {
const interfaceId = INTERFACE_IDS[k] ?? k;
const interfaceId = interfaceIds[k] ?? k;
expect(await this.contractUnderTest.supportsInterface.estimateGas(interfaceId)).to.lte(30_000n);
}
});

it('returns true', async function () {
for (const k of interfaces) {
const interfaceId = INTERFACE_IDS[k] ?? k;
const interfaceId = interfaceIds[k] ?? k;
expect(await this.contractUnderTest.supportsInterface(interfaceId), `does not support ${k}`).to.be.true;
}
});
Expand All @@ -129,10 +129,10 @@ function shouldSupportInterfaces(interfaces = []) {
it('all interface functions are in ABI', async function () {
for (const k of interfaces) {
// skip interfaces for which we don't have a function list
if (SIGNATURES[k] === undefined) continue;
if (signatures[k] === undefined) continue;

// Check the presence of each function in the contract's interface
for (const fnSig of SIGNATURES[k]) {
for (const fnSig of signatures[k]) {
expect(this.contractUnderTest.interface.hasFunction(fnSig), `did not find ${fnSig}`).to.be.true;
}
}
Expand All @@ -141,5 +141,7 @@ function shouldSupportInterfaces(interfaces = []) {
}

module.exports = {
SIGNATURES,
INTERFACE_IDS,
shouldSupportInterfaces,
};
Loading