ERC165Storage.test.js 801 B

12345678910111213141516171819202122232425
  1. const { expectRevert } = require('@openzeppelin/test-helpers');
  2. const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
  3. const ERC165Mock = artifacts.require('ERC165StorageMock');
  4. contract('ERC165Storage', function () {
  5. beforeEach(async function () {
  6. this.mock = await ERC165Mock.new();
  7. });
  8. it('register interface', async function () {
  9. expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(false);
  10. await this.mock.registerInterface('0x00000001');
  11. expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(true);
  12. });
  13. it('does not allow 0xffffffff', async function () {
  14. await expectRevert(this.mock.registerInterface('0xffffffff'), 'ERC165: invalid interface id');
  15. });
  16. shouldSupportInterfaces([
  17. 'ERC165',
  18. ]);
  19. });