Refactor ERC165 to use function overriding instead of storage (#2505)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
Hadrien Croubois
2021-02-18 20:02:28 +01:00
committed by GitHub
parent f7c8252611
commit e733b24dfe
12 changed files with 116 additions and 54 deletions

View File

@ -0,0 +1,25 @@
const { expectRevert } = require('@openzeppelin/test-helpers');
const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
const ERC165Mock = artifacts.require('ERC165StorageMock');
contract('ERC165Storage', function (accounts) {
beforeEach(async function () {
this.mock = await ERC165Mock.new();
});
it('register interface', async function () {
expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(false);
await this.mock.registerInterface('0x00000001');
expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(true);
});
it('does not allow 0xffffffff', async function () {
await expectRevert(this.mock.registerInterface('0xffffffff'), 'ERC165: invalid interface id');
});
shouldSupportInterfaces([
'ERC165',
]);
});