From 2c3e379a687d533d0a9b76cd1699fbc467592416 Mon Sep 17 00:00:00 2001 From: RenanSouza2 Date: Thu, 4 Jan 2024 15:19:04 -0300 Subject: [PATCH 1/2] Refactor supports interface --- test/governance/Governor.test.js | 2 +- test/token/ERC1155/ERC1155.behavior.js | 2 +- test/token/ERC1155/utils/ERC1155Holder.test.js | 2 +- test/token/ERC721/ERC721.behavior.js | 2 +- test/utils/introspection/ERC165.test.js | 2 +- test/utils/introspection/SupportsInterface.behavior.js | 4 +++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/governance/Governor.test.js b/test/governance/Governor.test.js index 4668e33d562..e097ef0eff4 100644 --- a/test/governance/Governor.test.js +++ b/test/governance/Governor.test.js @@ -96,7 +96,7 @@ describe('Governor', function () { ); }); - shouldSupportInterfaces(['ERC165', 'ERC1155Receiver', 'Governor']); + shouldSupportInterfaces(['ERC1155Receiver', 'Governor']); shouldBehaveLikeERC6372(mode); it('deployment check', async function () { diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index cdf62b50d10..ebcfc602a30 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -754,7 +754,7 @@ function shouldBehaveLikeERC1155() { }); }); - shouldSupportInterfaces(['ERC165', 'ERC1155', 'ERC1155MetadataURI']); + shouldSupportInterfaces(['ERC1155', 'ERC1155MetadataURI']); }); } diff --git a/test/token/ERC1155/utils/ERC1155Holder.test.js b/test/token/ERC1155/utils/ERC1155Holder.test.js index 52705fc4542..9bff487adad 100644 --- a/test/token/ERC1155/utils/ERC1155Holder.test.js +++ b/test/token/ERC1155/utils/ERC1155Holder.test.js @@ -24,7 +24,7 @@ describe('ERC1155Holder', function () { Object.assign(this, await loadFixture(fixture)); }); - shouldSupportInterfaces(['ERC165', 'ERC1155Receiver']); + shouldSupportInterfaces(['ERC1155Receiver']); it('receives ERC1155 tokens from a single ID', async function () { await this.token.connect(this.owner).safeTransferFrom(this.owner, this.mock, ids[0], values[0], data); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index b9fd56f0618..594a52fb970 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -20,7 +20,7 @@ function shouldBehaveLikeERC721() { Object.assign(this, { owner, newOwner, approved, operator, other }); }); - shouldSupportInterfaces(['ERC165', 'ERC721']); + shouldSupportInterfaces(['ERC721']); describe('with minted tokens', function () { beforeEach(async function () { diff --git a/test/utils/introspection/ERC165.test.js b/test/utils/introspection/ERC165.test.js index 83d861ba1c8..8117c695ebd 100644 --- a/test/utils/introspection/ERC165.test.js +++ b/test/utils/introspection/ERC165.test.js @@ -14,5 +14,5 @@ describe('ERC165', function () { Object.assign(this, await loadFixture(fixture)); }); - shouldSupportInterfaces(['ERC165']); + shouldSupportInterfaces(); }); diff --git a/test/utils/introspection/SupportsInterface.behavior.js b/test/utils/introspection/SupportsInterface.behavior.js index 27d153170b2..f5703c960d4 100644 --- a/test/utils/introspection/SupportsInterface.behavior.js +++ b/test/utils/introspection/SupportsInterface.behavior.js @@ -85,9 +85,11 @@ const SIGNATURES = { const INTERFACE_IDS = mapValues(SIGNATURES, interfaceId); function shouldSupportInterfaces(interfaces = []) { + interfaces = ['ERC165', ...interfaces]; + describe('ERC165', function () { beforeEach(function () { - this.contractUnderTest = this.mock || this.token || this.holder; + this.contractUnderTest = this.mock || this.token; }); describe('when the interfaceId is supported', function () { From 85c645fe5cf5836ed91442a6987681031314262f Mon Sep 17 00:00:00 2001 From: RenanSouza2 Date: Wed, 10 Jan 2024 09:36:11 -0300 Subject: [PATCH 2/2] Use interfaces.unshift --- test/utils/introspection/SupportsInterface.behavior.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/introspection/SupportsInterface.behavior.js b/test/utils/introspection/SupportsInterface.behavior.js index f5703c960d4..5b52a794675 100644 --- a/test/utils/introspection/SupportsInterface.behavior.js +++ b/test/utils/introspection/SupportsInterface.behavior.js @@ -85,7 +85,7 @@ const SIGNATURES = { const INTERFACE_IDS = mapValues(SIGNATURES, interfaceId); function shouldSupportInterfaces(interfaces = []) { - interfaces = ['ERC165', ...interfaces]; + interfaces.unshift('ERC165'); describe('ERC165', function () { beforeEach(function () {