Skip to content

Commit

Permalink
Update ERC165Checker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashhanai committed Jun 27, 2022
1 parent e5d327d commit bef6832
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/mocks/ERC165CheckerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ contract ERC165CheckerMock {
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool[] memory) {
return account.getSupportedInterfaces(interfaceIds);
}

function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) public view returns (bool) {
return account.supportsERC165InterfaceUnchecked(interfaceId);
}
}
32 changes: 32 additions & 0 deletions test/utils/introspection/ERC165Checker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ contract('ERC165Checker', function (accounts) {
expect(supported.length).to.equal(1);
expect(supported[0]).to.equal(false);
});

it('does not support mock interface via supportsERC165InterfaceUnchecked', async function () {
const supported = await this.mock.supportsERC165InterfaceUnchecked(this.target.address, DUMMY_ID);
expect(supported).to.equal(false);
});
});

context('ERC165 not supported', function () {
Expand Down Expand Up @@ -71,6 +76,11 @@ contract('ERC165Checker', function (accounts) {
expect(supported.length).to.equal(1);
expect(supported[0]).to.equal(false);
});

it('does not support mock interface via supportsERC165InterfaceUnchecked', async function () {
const supported = await this.mock.supportsERC165InterfaceUnchecked(this.target.address, DUMMY_ID);
expect(supported).to.equal(false);
});
});

context('ERC165 supported', function () {
Expand Down Expand Up @@ -98,6 +108,11 @@ contract('ERC165Checker', function (accounts) {
expect(supported.length).to.equal(1);
expect(supported[0]).to.equal(false);
});

it('does not support mock interface via supportsERC165InterfaceUnchecked', async function () {
const supported = await this.mock.supportsERC165InterfaceUnchecked(this.target.address, DUMMY_ID);
expect(supported).to.equal(false);
});
});

context('ERC165 and single interface supported', function () {
Expand Down Expand Up @@ -125,6 +140,11 @@ contract('ERC165Checker', function (accounts) {
expect(supported.length).to.equal(1);
expect(supported[0]).to.equal(true);
});

it('supports mock interface via supportsERC165InterfaceUnchecked', async function () {
const supported = await this.mock.supportsERC165InterfaceUnchecked(this.target.address, DUMMY_ID);
expect(supported).to.equal(true);
});
});

context('ERC165 and many interfaces supported', function () {
Expand Down Expand Up @@ -191,6 +211,13 @@ contract('ERC165Checker', function (accounts) {
expect(supported[2]).to.equal(true);
expect(supported[3]).to.equal(false);
});

it('supports each interfaceId via supportsERC165InterfaceUnchecked', async function () {
for (const interfaceId of this.supportedInterfaces) {
const supported = await this.mock.supportsERC165InterfaceUnchecked(this.target.address, interfaceId);
expect(supported).to.equal(true);
};
});
});

context('account address does not support ERC165', function () {
Expand All @@ -214,5 +241,10 @@ contract('ERC165Checker', function (accounts) {
expect(supported.length).to.equal(1);
expect(supported[0]).to.equal(false);
});

it('does not support mock interface via supportsERC165InterfaceUnchecked', async function () {
const supported = await this.mock.supportsERC165InterfaceUnchecked(DUMMY_ACCOUNT, DUMMY_ID);
expect(supported).to.equal(false);
});
});
});

0 comments on commit bef6832

Please sign in to comment.