Skip to content

Commit 01e86e3

Browse files
Split tests into truffle-test, mocha-test
Summary: Certain things are hard to test with truffle, so we need a separate test set. Reviewers: barath Reviewed By: barath Differential Revision: https://phabricator.bitgo.com/D7174
1 parent a2b0f33 commit 01e86e3

File tree

7 files changed

+140
-21
lines changed

7 files changed

+140
-21
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"extends": "eslint:recommended",
1414
"parserOptions": {
1515
"sourceType": "module",
16-
"ecmaVersion": 6
16+
"ecmaVersion": 2017
1717
},
1818
"rules": {
1919
"indent": ["error", 2, {"SwitchCase": 1, "MemberExpression": "off"}],

mocha-test/compile.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const fs = require('fs');
2+
const { promisify } = require('util');
3+
4+
const _ = require('lodash');
5+
const should = require('should');
6+
7+
const solc = require('solc');
8+
9+
// Useful when async func goes wrong
10+
process.on('unhandledRejection', (r) => {
11+
console.log('UnhandledRejection');
12+
console.error(r);
13+
});
14+
15+
describe('Contracts', async () => {
16+
const contracts = [
17+
'ERC20Interface.sol',
18+
'FixedSupplyToken.sol',
19+
'Forwarder.sol',
20+
'WalletSimple.sol'
21+
];
22+
23+
let result;
24+
25+
before(async function () {
26+
// solc takes a while
27+
this.timeout(10000);
28+
const contents = await Promise.all(contracts.map(async (filename) =>
29+
(await promisify(fs.readFile)('./contracts/' + filename)).toString()
30+
));
31+
const sources = _.zipObject(contracts, contents);
32+
result = solc.compile({ sources }, 1);
33+
});
34+
35+
it('compile without warnings and errors', () => {
36+
should.equal(
37+
(result.errors || []).length, 0,
38+
(result.errors || []).join('\n')
39+
);
40+
});
41+
});

package-lock.json

+94-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"test": "test"
1010
},
1111
"scripts": {
12-
"testrpc": "./testrpc/run.js",
13-
"test": "./node_modules/truffle/build/cli.bundled.js test"
12+
"truffle-testrpc": "./testrpc/run.js",
13+
"mocha-test": "./node_modules/mocha/bin/mocha mocha-test",
14+
"truffle-test": "./node_modules/truffle/build/cli.bundled.js truffle-test"
1415
},
1516
"keywords": [
1617
"multi-sig",
@@ -26,6 +27,7 @@
2627
"ethereumjs-testrpc": "^6.0.3",
2728
"ethereumjs-util": "^5.1.2",
2829
"lodash": "^4.12.0",
30+
"mocha": "^4.0.1",
2931
"q": "^1.5.1",
3032
"should": "^8.3.1",
3133
"truffle": "^4.0.1",
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)