Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Buidler tests to Hardhat #561

Merged
merged 7 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ workflows:
build:
jobs:
- unit-test
- e2e-zeppelin
# Temporarily disabled due to unskipped GSN gas measurement tests
# - e2e-zeppelin
- e2e-metacoin
- e2e-metacoin-windows
- e2e-buidler
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"buidler-gas-reporter": "^0.1.3",
"decache": "^4.5.1",
"hardhat": "^2.0.2",
"hardhat-gas-reporter": "^1.0.1",
"mocha": "5.2.0",
"nyc": "^14.1.1",
"solc": "^0.5.10",
Expand Down
2 changes: 1 addition & 1 deletion plugins/buidler.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function plugin() {
pkg.version
]);

ui.report('network', [
ui.report('ganache-network', [
env.network.name,
api.port
]);
Expand Down
19 changes: 15 additions & 4 deletions plugins/hardhat.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const death = require('death');
const path = require('path');

const { task, types } = require("hardhat/config");
const { HardhatPluginError } = require("hardhat/plugins")

const {
TASK_TEST,
Expand Down Expand Up @@ -72,6 +73,7 @@ async function plugin(args, env) {
let client;
let address;
let web3;
let failedTests = 0;

instrumentedSources = {};
measureCoverage = true;
Expand All @@ -86,6 +88,15 @@ async function plugin(args, env) {
// Version Info
ui.report('hardhat-versions', [pkg.version]);

// Merge non-null flags into hardhatArguments
const flags = {};
for (const key of Object.keys(args)){
if (args[key] && args[key].length){
flags[key] = args[key]
}
}
env.hardhatArguments = Object.assign(env.hardhatArguments, flags)

// ================
// Instrumentation
// ================
Expand Down Expand Up @@ -137,7 +148,7 @@ async function plugin(args, env) {
env.network.name,
]);
} else {
const Web3 = require('Web3');
const Web3 = require('web3');
client = api.client || require('ganache-cli');
address = await api.ganache(client);
web3 = new Web3(address);
Expand Down Expand Up @@ -165,7 +176,7 @@ async function plugin(args, env) {
: [];

try {
await env.run(TASK_TEST, {testFiles: testfiles})
failedTests = await env.run(TASK_TEST, {testFiles: testfiles})
} catch (e) {
error = e;
}
Expand All @@ -185,8 +196,8 @@ async function plugin(args, env) {

await nomiclabsUtils.finish(config, api);

if (error !== undefined ) throw error;
if (process.exitCode > 0) throw new Error(ui.generate('tests-fail', [process.exitCode]));
if (error !== undefined ) throw new HardhatPluginError(error);
if (failedTests > 0) throw new HardhatPluginError(ui.generate('tests-fail', [failedTests]));
}

module.exports = plugin;
19 changes: 11 additions & 8 deletions plugins/resources/nomiclabs.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ class PluginUI extends UI {
`${ct} ${c.bold('HardhatEVM')}: v${args[0]}\n` +
`${ct} ${c.bold('network')}: ${args[1]}\n`,

'network': `\n${c.bold('Network Info')}` +
`\n${c.bold('============')}\n` +
`${ct} ${c.bold('ganache-core')}: ${args[0]}\n` +
`${ct} ${c.bold('port')}: ${args[2]}\n` +
`${ct} ${c.bold('network')}: ${args[1]}\n`,

'port-clash': `${w} ${c.red("The 'port' values in your Buidler url ")}` +
`${c.red("and .solcover.js are different. Using Buidler's: ")} ${c.bold(args[0])}.\n`,
'ganache-network': `\n${c.bold('Network Info')}` +
`\n${c.bold('============')}\n` +
`${ct} ${c.bold('ganache-core')}: ${args[0]}\n` +
`${ct} ${c.bold('port')}: ${args[2]}\n` +
`${ct} ${c.bold('network')}: ${args[1]}\n`,

'port-clash': `${w} ${c.red("The 'port' values in your config's network url ")}` +
`${c.red("and .solcover.js are different. Using network's: ")} ${c.bold(args[0])}.\n`,

'port-clash-hardhat': `${w} ${c.red("The 'port' values in your Hardhat network's url ")}` +
`${c.red("and .solcover.js are different. Using Hardhat's: ")} ${c.bold(args[0])}.\n`,

}

Expand Down
8 changes: 0 additions & 8 deletions test/integration/projects/bad-solcoverjs/buidler.config.js

This file was deleted.

6 changes: 6 additions & 0 deletions test/integration/projects/bad-solcoverjs/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports={
logger: process.env.SILENT ? { log: () => {} } : console,
};

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions test/integration/projects/ganache-solcoverjs/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
networks: {
coverage: {
url: "http://127.0.0.1:8555"
}
}.
logger: process.env.SILENT ? { log: () => {} } : console,
};
10 changes: 10 additions & 0 deletions test/integration/projects/hardhat-gas-reporter/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require("hardhat-gas-reporter");
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
8 changes: 0 additions & 8 deletions test/integration/projects/import-paths/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/import-paths/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
7 changes: 0 additions & 7 deletions test/integration/projects/libraries/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/libraries/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
12 changes: 0 additions & 12 deletions test/integration/projects/multiple-suites/buidler.config.js

This file was deleted.

14 changes: 14 additions & 0 deletions test/integration/projects/multiple-suites/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports={
networks: {
hardhat: {
gasPrice: 2
}
},
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
7 changes: 0 additions & 7 deletions test/integration/projects/no-sources/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/no-sources/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
8 changes: 0 additions & 8 deletions test/integration/projects/skipping/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/skipping/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
10 changes: 0 additions & 10 deletions test/integration/projects/solc-6/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/solc-6/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.6.7"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
4 changes: 0 additions & 4 deletions test/integration/projects/solc-6/test/b_wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ contract('B_Wallet', accounts => {
await walletA.transferPayment(0, walletB.address, {
from: accounts[0],
});

// Throws invalid opcode if compiled w/ solc >= 0.5.14 & default EVM version
const balance = await walletB.getBalance();
assert.equal(balance.toNumber(), 100);
});
});

7 changes: 0 additions & 7 deletions test/integration/projects/test-files/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/test-files/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
8 changes: 0 additions & 8 deletions test/integration/projects/tests-folder/buidler.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/projects/tests-folder/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");

module.exports = {
solidity: {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
Loading