Replace chai.should with chai.expect (#1780)

* changed exxpect to expect wherever applicable

* Merged with latest branch

* Updated merkleTree helper to latest master branch

* Made linting fixes

* Fix for test build

* updated for Coverage

* Updated Address.test.js

* Undo package-lock changes.
This commit is contained in:
Yohann Pereira
2019-06-24 16:40:05 -04:00
committed by Francisco Giordano
parent 852e11c2db
commit 489d2e85f1
57 changed files with 564 additions and 453 deletions

View File

@ -1,5 +1,7 @@
require('openzeppelin-test-helpers');
const { expect } = require('chai');
const ERC165CheckerMock = artifacts.require('ERC165CheckerMock');
const ERC165NotSupported = artifacts.require('ERC165NotSupported');
const ERC165InterfacesSupported = artifacts.require('ERC165InterfacesSupported');
@ -23,17 +25,17 @@ contract('ERC165Checker', function () {
it('does not support ERC165', async function () {
const supported = await this.mock.supportsERC165(this.target.address);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('does not support mock interface via supportsInterface', async function () {
const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('does not support mock interface via supportsAllInterfaces', async function () {
const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]);
supported.should.equal(false);
expect(supported).to.equal(false);
});
});
@ -44,17 +46,17 @@ contract('ERC165Checker', function () {
it('supports ERC165', async function () {
const supported = await this.mock.supportsERC165(this.target.address);
supported.should.equal(true);
expect(supported).to.equal(true);
});
it('does not support mock interface via supportsInterface', async function () {
const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('does not support mock interface via supportsAllInterfaces', async function () {
const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]);
supported.should.equal(false);
expect(supported).to.equal(false);
});
});
@ -65,17 +67,17 @@ contract('ERC165Checker', function () {
it('supports ERC165', async function () {
const supported = await this.mock.supportsERC165(this.target.address);
supported.should.equal(true);
expect(supported).to.equal(true);
});
it('supports mock interface via supportsInterface', async function () {
const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID);
supported.should.equal(true);
expect(supported).to.equal(true);
});
it('supports mock interface via supportsAllInterfaces', async function () {
const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]);
supported.should.equal(true);
expect(supported).to.equal(true);
});
});
@ -87,50 +89,50 @@ contract('ERC165Checker', function () {
it('supports ERC165', async function () {
const supported = await this.mock.supportsERC165(this.target.address);
supported.should.equal(true);
expect(supported).to.equal(true);
});
it('supports each interfaceId via supportsInterface', async function () {
for (const interfaceId of this.supportedInterfaces) {
const supported = await this.mock.supportsInterface(this.target.address, interfaceId);
supported.should.equal(true);
expect(supported).to.equal(true);
};
});
it('supports all interfaceIds via supportsAllInterfaces', async function () {
const supported = await this.mock.supportsAllInterfaces(this.target.address, this.supportedInterfaces);
supported.should.equal(true);
expect(supported).to.equal(true);
});
it('supports none of the interfaces queried via supportsAllInterfaces', async function () {
const interfaceIdsToTest = [DUMMY_UNSUPPORTED_ID, DUMMY_UNSUPPORTED_ID_2];
const supported = await this.mock.supportsAllInterfaces(this.target.address, interfaceIdsToTest);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('supports not all of the interfaces queried via supportsAllInterfaces', async function () {
const interfaceIdsToTest = [...this.supportedInterfaces, DUMMY_UNSUPPORTED_ID];
const supported = await this.mock.supportsAllInterfaces(this.target.address, interfaceIdsToTest);
supported.should.equal(false);
expect(supported).to.equal(false);
});
});
context('account address does not support ERC165', function () {
it('does not support ERC165', async function () {
const supported = await this.mock.supportsERC165(DUMMY_ACCOUNT);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('does not support mock interface via supportsInterface', async function () {
const supported = await this.mock.supportsInterface(DUMMY_ACCOUNT, DUMMY_ID);
supported.should.equal(false);
expect(supported).to.equal(false);
});
it('does not support mock interface via supportsAllInterfaces', async function () {
const supported = await this.mock.supportsAllInterfaces(DUMMY_ACCOUNT, [DUMMY_ID]);
supported.should.equal(false);
expect(supported).to.equal(false);
});
});
});

View File

@ -1,6 +1,8 @@
const { expectRevert, singletons } = require('openzeppelin-test-helpers');
const { bufferToHex, keccak256 } = require('ethereumjs-util');
const { expect } = require('chai');
const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock');
contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]) {
@ -16,8 +18,8 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]
context('with no registered interfaces', function () {
it('returns false when interface implementation is queried', async function () {
(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee))
.should.not.equal(ERC1820_ACCEPT_MAGIC);
expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee))
.to.not.equal(ERC1820_ACCEPT_MAGIC);
});
it('reverts when attempting to set as implementer in the registry', async function () {
@ -36,18 +38,18 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]
});
it('returns true when interface implementation is queried', async function () {
(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee))
.should.equal(ERC1820_ACCEPT_MAGIC);
expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee))
.to.equal(ERC1820_ACCEPT_MAGIC);
});
it('returns false when interface implementation for non-supported interfaces is queried', async function () {
(await this.implementer.canImplementInterfaceForAddress(this.interfaceB, implementee))
.should.not.equal(ERC1820_ACCEPT_MAGIC);
expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceB, implementee))
.to.not.equal(ERC1820_ACCEPT_MAGIC);
});
it('returns false when interface implementation for non-supported addresses is queried', async function () {
(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, other))
.should.not.equal(ERC1820_ACCEPT_MAGIC);
expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, other))
.to.not.equal(ERC1820_ACCEPT_MAGIC);
});
it('can be set as an implementer for supported interfaces in the registry', async function () {
@ -55,8 +57,8 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]
implementee, this.interfaceA, this.implementer.address, { from: implementee }
);
(await this.registry.getInterfaceImplementer(implementee, this.interfaceA))
.should.equal(this.implementer.address);
expect(await this.registry.getInterfaceImplementer(implementee, this.interfaceA))
.to.equal(this.implementer.address);
});
});
});

View File

@ -1,5 +1,7 @@
const { makeInterfaceId } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const INTERFACES = {
ERC165: [
'supportsInterface(bytes4)',
@ -48,11 +50,11 @@ function shouldSupportInterfaces (interfaces = []) {
describe(k, function () {
describe('ERC165\'s supportsInterface(bytes4)', function () {
it('should use less than 30k gas', async function () {
(await this.contractUnderTest.supportsInterface.estimateGas(interfaceId)).should.be.lte(30000);
expect(await this.contractUnderTest.supportsInterface.estimateGas(interfaceId)).to.be.lte(30000);
});
it('should claim support', async function () {
(await this.contractUnderTest.supportsInterface(interfaceId)).should.equal(true);
expect(await this.contractUnderTest.supportsInterface(interfaceId)).to.equal(true);
});
});
@ -60,7 +62,7 @@ function shouldSupportInterfaces (interfaces = []) {
const fnSig = FN_SIGNATURES[fnName];
describe(fnName, function () {
it('should be implemented', function () {
this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length.should.equal(1);
expect(this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length).to.equal(1);
});
});
}