Add builder-ethers test to CI (#441)

* Let plugins manage which client is used
* Use requested network name
pull/443/head
cgewecke 5 years ago committed by GitHub
parent 4f73e1585c
commit 97de9c6012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      dist/buidler.plugin.js
  2. 20
      dist/plugin-assets/buidler.utils.js
  3. 3
      dist/truffle.plugin.js
  4. 9
      lib/api.js
  5. 32
      scripts/run-buidler.sh
  6. 1
      scripts/run-moloch.sh
  7. 13
      test/units/buidler/flags.js
  8. 19
      test/units/buidler/standard.js

@ -46,14 +46,10 @@ function plugin() {
// ==============
// Server launch
// ==============
const network = buidlerUtils.setupNetwork(
env,
api,
args,
ui
);
const address = await api.ganache(ganache);
const network = buidlerUtils.setupNetwork(env, api, ui);
const client = api.client || ganache;
const address = await api.ganache(client);
const web3 = new Web3(address);
const accounts = await web3.eth.getAccounts();
const nodeInfo = await web3.eth.getNodeInfo();
@ -68,9 +64,8 @@ function plugin() {
pkg.version
]);
// Network Info
ui.report('network', [
api.defaultNetworkName,
env.network.name,
api.port
]);

@ -16,7 +16,7 @@ const { createProvider } = require("@nomiclabs/buidler/internal/core/providers/c
* @param {BuidlerConfig} config
* @return {BuidlerConfig} updated config
*/
function normalizeConfig(config, args){
function normalizeConfig(config, args={}){
config.workingDir = config.paths.root;
config.contractsDir = config.paths.sources;
config.testDir = config.paths.tests;
@ -27,11 +27,15 @@ function normalizeConfig(config, args){
return config;
}
function setupNetwork(env, api, taskArgs, ui){
function setupNetwork(env, api, ui){
let networkConfig = {};
if (taskArgs.network){
networkConfig = env.config.networks[taskArgs.network];
let networkName = (env.buidlerArguments.network !== 'buidlerevm')
? env.buidlerArguments.network
: api.defaultNetworkName;
if (networkName !== api.defaultNetworkName){
networkConfig = env.config.networks[networkName];
const configPort = networkConfig.url.split(':')[2];
@ -48,13 +52,13 @@ function setupNetwork(env, api, taskArgs, ui){
networkConfig.gas = api.gasLimit;
networkConfig.gasPrice = api.gasPrice;
const provider = createProvider(api.defaultNetworkName, networkConfig);
const provider = createProvider(networkName, networkConfig);
env.config.networks[api.defaultNetworkName] = networkConfig;
env.config.defaultNetwork = api.defaultNetworkName;
env.config.networks[networkName] = networkConfig;
env.config.defaultNetwork = networkName;
env.network = {
name: api.defaultNetworkName,
name: networkName,
config: networkConfig,
provider: provider,
}

@ -36,7 +36,8 @@ async function plugin(config){
truffleUtils.setNetwork(config, api);
// Server launch
const address = await api.ganache(truffle.ganache);
const client = api.client || truffle.ganache;
const address = await api.ganache(client);
const web3 = new Web3(address);
const accounts = await web3.eth.getAccounts();

@ -39,10 +39,9 @@ class API {
this.onIstanbulComplete = config.onIstanbulComplete || this.defaultHook;
this.server = null;
this.provider = null;
this.defaultPort = 8555;
this.defaultNetworkName = 'soliditycoverage';
this.client = config.client;
this.defaultNetworkName = 'soliditycoverage';
this.port = config.port || this.defaultPort;
this.host = config.host || "127.0.0.1";
this.providerOptions = config.providerOptions || {};
@ -224,9 +223,9 @@ class API {
async attachToVM(client){
const self = this;
// Prefer client from options
if(!this.client) this.client = client;
this.server = this.client.server(this.providerOptions);
// Fallback to client from options
if(!client) client = this.client;
this.server = client.server(this.providerOptions);
this.assertHasBlockchain(this.server.provider);
await this.vmIsResolved(this.server.provider);

@ -21,6 +21,12 @@ fi
echo "PR_PATH >>>>> $PR_PATH"
echo ""
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Simple buidler/buidler-trufflev5 "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo ""
# Install buidler e2e test
git clone https://github.com/sc-forks/buidler-e2e.git
cd buidler-e2e
@ -28,10 +34,34 @@ npm install
# Install and run solidity-coverage @ PR
npm install --save-dev $PR_PATH
cat package.json
npx buidler coverage
# Test that coverage/ was generated
if [ ! -d "coverage" ]; then
echo "ERROR: no coverage folder was created for buidler-trufflev5."
exit 1
fi
echo ""
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Simple buidler/buidler-ethers "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo ""
cd ..
git clone https://github.com/sc-forks/example-buidler-ethers.git
cd example-buidler-ethers
npm install
# Install and run solidity-coverage @ PR
npm install --save-dev $PR_PATH
cat package.json
npx buidler coverage
# Test that coverage/ was generated
if [ ! -d "coverage" ]; then
echo "ERROR: no coverage folder was created."
echo "ERROR: no coverage folder was created for buidler-ethers."
exit 1
fi

@ -28,6 +28,7 @@ npm install
npm uninstall --save-dev solidity-coverage
# Install and run solidity-coverage @ PR
# Should run on network 'localhost'
npm install --save-dev $PR_PATH
npm run coverage

@ -53,16 +53,14 @@ describe('Buidler Plugin: command line options', function() {
});
it('--network (declared port mismatches)', async function(){
const taskArgs = {
network: 'development' // 8545
}
solcoverConfig.port = 8222;
mock.install('Simple', 'simple.js', solcoverConfig);
mock.buidlerSetupEnv(this);
await this.env.run("coverage", taskArgs);
this.env.buidlerArguments.network = "development";
await this.env.run("coverage");
assert(
mock.loggerOutput.val.includes("The 'port' values"),
@ -74,6 +72,11 @@ describe('Buidler Plugin: command line options', function() {
`Should have used default coverage port 8545: ${mock.loggerOutput.val}`
);
assert(
mock.loggerOutput.val.includes("development"),
`Should have used specified network name: ${mock.loggerOutput.val}`
);
const expected = [{
file: mock.pathToContract(buidlerConfig, 'Simple.sol'),
pct: 100

@ -51,6 +51,25 @@ describe('Buidler Plugin: standard use cases', function() {
);
});
it('default network ("buidlerevm")', async function(){
mock.install('Simple', 'simple.js', solcoverConfig);
mock.buidlerSetupEnv(this);
this.env.buidlerArguments.network = "buidlerevm"
await this.env.run("coverage");
assert(
mock.loggerOutput.val.includes("8555"),
`Should have used default coverage port 8555: ${mock.loggerOutput.val}`
);
assert(
mock.loggerOutput.val.includes("soliditycoverage"),
`Should have used specified network name: ${mock.loggerOutput.val}`
);
});
it('with relative path solidity imports', async function() {
mock.installFullProject('import-paths');
mock.buidlerSetupEnv(this);

Loading…
Cancel
Save