Skip to content

Commit

Permalink
test(contracts): update tests to use buidler's waffle provider
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 28, 2020
1 parent c0b01e2 commit 29956c0
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 55 deletions.
3 changes: 0 additions & 3 deletions packages/contracts/.waffle.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"deploy": "buidler run scripts/deploy.js",
"export": "buidler export",
"has:changed": "bash ../monorepo-scripts/ci/hasChanged.sh contracts",
"test": "waffle .waffle.json && mocha test/runTests.js --timeout 5000",
"test": "buidler test test/runTests.js",
"lint:js": "eslint --config .eslintrc.js ./scripts ./test"
},
"files": [
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/NoteStream/cancelStream.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const { waffle } = require('@nomiclabs/buidler');
const { use, expect } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { bigNumberify, Interface } = require('ethers/utils');

const { devConstants, mochaContexts } = require('@notestream/dev-utils');
Expand All @@ -28,7 +25,7 @@ const {

use(solidity);

const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient, attacker] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
5 changes: 3 additions & 2 deletions packages/contracts/test/NoteStream/constructor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { waffle } = require('@nomiclabs/buidler');
const { use, expect } = require('chai');
const { solidity, MockProvider, deployContract } = require('ethereum-waffle');
const { solidity, deployContract } = require('ethereum-waffle');

const { devConstants } = require('@notestream/dev-utils');
const NoteStream = require('../../build/NoteStream.json');
Expand All @@ -10,7 +11,7 @@ use(solidity);

// eslint-disable-next-line no-undef
describe('NoteStream - constructor', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [deployer] = provider.getWallets();

it('reverts when the ACE contract is the zero address', async function () {
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/NoteStream/createStream.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// const { devConstants } = require("@notestream/dev-utils");
const { waffle } = require('@nomiclabs/buidler');
const { use, expect } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { bigNumberify, Interface } = require('ethers/utils');

const { devConstants } = require('@notestream/dev-utils');
Expand All @@ -25,7 +22,7 @@ use(solidity);

// eslint-disable-next-line no-undef
describe('NoteStream - createStream', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/NoteStream/getStream.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// const { devConstants } = require("@notestream/dev-utils");
const { waffle } = require('@nomiclabs/buidler');
const { use, expect } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { bigNumberify } = require('ethers/utils');

const { noteStreamFixture } = require('../fixtures');
Expand All @@ -13,7 +10,7 @@ use(solidity);

// eslint-disable-next-line no-undef
describe('NoteStream - getStream', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/test/NoteStream/withdrawFromStream.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { waffle } = require('@nomiclabs/buidler');
const { use, expect } = require('chai');
const {
solidity,
Expand Down Expand Up @@ -29,7 +30,7 @@ const {
use(solidity);

function runTests() {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/StreamUtilities/getRatio.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { waffle } = require('@nomiclabs/buidler');
const { use } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { StreamUtilitiesFixture } = require('../fixtures');

use(solidity);

describe('StreamUtilities - getRatio', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { waffle } = require('@nomiclabs/buidler');
const { use } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { StreamUtilitiesFixture } = require('../fixtures');

use(solidity);

describe('StreamUtilities - processCancellation', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/StreamUtilities/processWithdrawal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { waffle } = require('@nomiclabs/buidler');
const { use } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { StreamUtilitiesFixture } = require('../fixtures');

use(solidity);

describe('StreamUtilities - processWithdrawal', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { waffle } = require('@nomiclabs/buidler');
const { use } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { StreamUtilitiesFixture } = require('../fixtures');

use(solidity);

describe('StreamUtilities - validateJoinSplitProof', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/test/StreamUtilities/validateRatioProof.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { waffle } = require('@nomiclabs/buidler');
const { use } = require('chai');
const {
solidity,
MockProvider,
createFixtureLoader,
} = require('ethereum-waffle');
const { solidity, createFixtureLoader } = require('ethereum-waffle');
const { StreamUtilitiesFixture } = require('../fixtures');

use(solidity);

describe('StreamUtilities - validateRatioProof', function () {
const provider = new MockProvider();
const { provider } = waffle;
const [sender, recipient] = provider.getWallets();
const loadFixture = createFixtureLoader(provider, [sender, recipient]);

Expand Down

0 comments on commit 29956c0

Please sign in to comment.