Skip to content

Commit

Permalink
Merge pull request #510 from JoinColony/maintenance/317-test-refactoring
Browse files Browse the repository at this point in the history
Upgrade to babel 7 and resolve source map support failure in tests
  • Loading branch information
elenadimitrova authored Jan 26, 2019
2 parents 32fdd6b + 74c5c6a commit 2b58d6a
Show file tree
Hide file tree
Showing 15 changed files with 920 additions and 259 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

job_common: &job_common
docker:
- image: circleci/node:9.11.2-stretch
- image: circleci/node:10.12-stretch
working_directory: ~/colonyNetwork
step_save_cache: &step_save_cache
save_cache:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.11.2
10.12
8 changes: 8 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const babelConfig = {
presets: ["@babel/preset-env"]
};

module.exports = babel => {
babel.cache.never();
return babelConfig;
};
7 changes: 6 additions & 1 deletion helpers/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,13 @@ export async function advanceMiningCycleNoContest({ colonyNetwork, client, miner
} else {
const accounts = await web3GetAccounts();
minerAddress = minerAddress || accounts[5]; // eslint-disable-line no-param-reassign
await repCycle.submitRootHash("0x00", 0, "0x00", 10, { from: minerAddress });
try {
await repCycle.submitRootHash("0x00", 0, "0x00", 10, { from: minerAddress });
} catch (err) {
console.log("advanceMiningCycleNoContest error thrown by .submitRootHash", err);
}
}

await repCycle.confirmNewHash(0);
}

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"eslint-staged": "bash ./scripts/eslint.sh",
"eslint": "eslint .",
"solium": "solium --dir .",
"check:storagevars": "./node_modules/babel-cli/bin/babel-node.js ./scripts/check-storage.js",
"check:recoverymods": "./node_modules/babel-cli/bin/babel-node.js ./scripts/check-recovery.js",
"check:storagevars": "./node_modules/@babel/node/bin/babel-node.js ./scripts/check-storage.js",
"check:recoverymods": "./node_modules/@babel/node/bin/babel-node.js ./scripts/check-recovery.js",
"version:contracts": "bash ./scripts/version-contracts.sh",
"generate:test:contracts": "bash ./scripts/generate-test-contracts.sh",
"clean:test:contracts": "rimraf ./contracts/*Updated*.*",
Expand Down Expand Up @@ -52,15 +52,15 @@
},
"homepage": "https://github.com/JoinColony/colonyNetwork#readme",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/node": "^7.2.2",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"@colony/colony-js-contract-loader-fs": "1.8.1",
"@colony/eslint-config-colony": "7.0.0",
"async-request": "^1.2.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"bn-chai": "^1.0.1",
"bn.js": "^4.11.8",
"chai": "^4.2.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/colony-js-contract-loader-network/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"env": {
"test": {
"presets": ["@babel/preset-env"]
}
}
}
11 changes: 6 additions & 5 deletions packages/colony-js-contract-loader-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"author": "Christian Maniewski <[email protected]>",
"license": "GPL-3.0",
"dependencies": {
"@babel/runtime": "^7.0.0",
"@colony/colony-js-contract-loader": "1.8.1",
"assert": "^1.4.1",
"babel-runtime": "^6.26.0"
"assert": "^1.4.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-jest": "^23.0.1",
"jest": "^23.1.0",
"@babel/cli": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"jest": "^23.6.0",
"shx": "^0.3.0"
}
}
5 changes: 4 additions & 1 deletion packages/reputation-miner/ReputationMiner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PatriciaTreeNoHash from "./patriciaNoHashKey";

const BN = require("bn.js");
const web3Utils = require("web3-utils");
const ganache = require("ganache-core");
const ethers = require("ethers");
const sqlite = require("sqlite");

Expand All @@ -26,6 +25,10 @@ class ReputationMiner {

this.useJsTree = useJsTree;
if (!this.useJsTree) {
// If this require is global, line numbers are broken in all our tests. If we move it here, it's only an issue if we're not
// using the JS tree. There is an issue open at ganache-core about this, and this require will have to remain here until it's fixed.
// https://github.com/trufflesuite/ganache-core/issues/287
const ganache = require("ganache-core"); // eslint-disable-line global-require
const ganacheProvider = ganache.provider({
network_id: 515,
vmErrorsOnRPCResponse: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/reputation-miner/bin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require("babel-register")({
presets: ["env"]
require("@babel/register")({
presets: ["@babel/preset-env"]
});

const path = require("path");
Expand Down
4 changes: 2 additions & 2 deletions packages/reputation-miner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"yargs": "^12.0.1"
},
"devDependencies": {
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0"
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ReputationMinerTestWrapper from "./ReputationMinerTestWrapper";

class MaliciousReputationMinerClaimNew extends ReputationMinerTestWrapper {
class MaliciousReputationMinerUnsure extends ReputationMinerTestWrapper {
// Not really sure how to describe this malicous mining client...
// It ends up proving a too-large newest reputation for the nNodes it claimed in the
// JRH (so in the test in question, the intermediate value had 6 nodes, but it proves
Expand Down Expand Up @@ -38,4 +38,4 @@ class MaliciousReputationMinerClaimNew extends ReputationMinerTestWrapper {
}
}

export default MaliciousReputationMinerClaimNew;
export default MaliciousReputationMinerUnsure;
11 changes: 8 additions & 3 deletions test-gas-costs/gasCosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,19 @@ contract("All", function(accounts) {
await advanceMiningCycleNoContest({ colonyNetwork, test: this });
await advanceMiningCycleNoContest({ colonyNetwork, test: this, minerAddress: STAKER1 });

const goodClient = new ReputationMinerTestWrapper({ loader: contractLoader, minerAddress: STAKER1, realProviderPort: REAL_PROVIDER_PORT });
const goodClient = new ReputationMinerTestWrapper({
loader: contractLoader,
minerAddress: STAKER1,
realProviderPort: REAL_PROVIDER_PORT,
useJsTree: true
});
const badClient = new MaliciousReputationMinerExtraRep(
{ loader: contractLoader, minerAddress: STAKER2, realProviderPort: REAL_PROVIDER_PORT },
{ loader: contractLoader, minerAddress: STAKER2, realProviderPort: REAL_PROVIDER_PORT, useJsTree: true },
1,
0xfffffffff
);
const badClient2 = new MaliciousReputationMinerExtraRep(
{ loader: contractLoader, minerAddress: STAKER3, realProviderPort: REAL_PROVIDER_PORT },
{ loader: contractLoader, minerAddress: STAKER3, realProviderPort: REAL_PROVIDER_PORT, useJsTree: true },
2,
0xfffffffff
);
Expand Down
3 changes: 2 additions & 1 deletion truffle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require("babel-register");
require("@babel/register");
require("@babel/polyfill");

module.exports = {
networks: {
Expand Down
Loading

0 comments on commit 2b58d6a

Please sign in to comment.