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

@ -2,6 +2,8 @@ const { constants, expectRevert } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;
const { toEthSignedMessageHash, fixSignature } = require('../helpers/sign');
const { expect } = require('chai');
const ECDSAMock = artifacts.require('ECDSAMock');
const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin');
@ -23,7 +25,7 @@ contract('ECDSA', function ([_, other]) {
it('returns 0', async function () {
const version = '00';
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS);
});
});
@ -31,7 +33,7 @@ contract('ECDSA', function ([_, other]) {
it('works', async function () {
const version = '1b'; // 27 = 1b.
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(signer);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer);
});
});
@ -41,7 +43,7 @@ contract('ECDSA', function ([_, other]) {
// The only valid values are 0, 1, 27 and 28.
const version = '02';
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS);
});
});
});
@ -55,7 +57,7 @@ contract('ECDSA', function ([_, other]) {
it('returns 0', async function () {
const version = '01';
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS);
});
});
@ -63,7 +65,7 @@ contract('ECDSA', function ([_, other]) {
it('works', async function () {
const version = '1c'; // 28 = 1c.
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(signer);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer);
});
});
@ -73,7 +75,7 @@ contract('ECDSA', function ([_, other]) {
// The only valid values are 0, 1, 27 and 28.
const version = '02';
const signature = signatureWithoutVersion + version;
(await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS);
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS);
});
});
});
@ -84,7 +86,7 @@ contract('ECDSA', function ([_, other]) {
// eslint-disable-next-line max-len
const highSSignature = '0xe742ff452d41413616a5bf43fe15dd88294e983d3d36206c2712f39083d638bde0a0fc89be718fbc1033e1d30d78be1c68081562ed2e97af876f286f3453231d1b';
(await this.ecdsa.recover(message, highSSignature)).should.equal(ZERO_ADDRESS);
expect(await this.ecdsa.recover(message, highSSignature)).to.equal(ZERO_ADDRESS);
});
});
@ -95,10 +97,10 @@ contract('ECDSA', function ([_, other]) {
const signature = fixSignature(await web3.eth.sign(TEST_MESSAGE, other));
// Recover the signer address from the generated message and signature.
(await this.ecdsa.recover(
expect(await this.ecdsa.recover(
toEthSignedMessageHash(TEST_MESSAGE),
signature
)).should.equal(other);
)).to.equal(other);
});
});
@ -108,7 +110,7 @@ contract('ECDSA', function ([_, other]) {
const signature = await web3.eth.sign(TEST_MESSAGE, other);
// Recover the signer address from the generated message and wrong signature.
(await this.ecdsa.recover(WRONG_MESSAGE, signature)).should.not.equal(other);
expect(await this.ecdsa.recover(WRONG_MESSAGE, signature)).to.not.equal(other);
});
});
});
@ -129,6 +131,7 @@ contract('ECDSA', function ([_, other]) {
context('toEthSignedMessage', function () {
it('should prefix hashes correctly', async function () {
(await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).should.equal(toEthSignedMessageHash(TEST_MESSAGE));
expect(await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).to.equal(toEthSignedMessageHash(TEST_MESSAGE));
});
});
});

View File

@ -3,6 +3,8 @@ require('openzeppelin-test-helpers');
const { MerkleTree } = require('../helpers/merkleTree.js');
const { keccak256, bufferToHex } = require('ethereumjs-util');
const { expect } = require('chai');
const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
contract('MerkleProof', function () {
@ -21,7 +23,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(keccak256(elements[0]));
(await this.merkleProof.verify(proof, root, leaf)).should.equal(true);
expect(await this.merkleProof.verify(proof, root, leaf)).to.equal(true);
});
it('should return false for an invalid Merkle proof', async function () {
@ -37,7 +39,7 @@ contract('MerkleProof', function () {
const badProof = badMerkleTree.getHexProof(badElements[0]);
(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false);
expect(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).to.equal(false);
});
it('should return false for a Merkle proof of invalid length', async function () {
@ -51,7 +53,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(keccak256(elements[0]));
(await this.merkleProof.verify(badProof, root, leaf)).should.equal(false);
expect(await this.merkleProof.verify(badProof, root, leaf)).to.equal(false);
});
});
});