Refactor buidler config

This commit is contained in:
Francisco Giordano
2020-11-06 14:12:33 -03:00
parent fcdf8f4618
commit 1e78adc28c
2 changed files with 16 additions and 9 deletions

View File

@ -1,15 +1,12 @@
const fs = require('fs');
const path = require('path');
usePlugin('solidity-coverage'); usePlugin('solidity-coverage');
usePlugin('@nomiclabs/buidler-truffle5'); usePlugin('@nomiclabs/buidler-truffle5');
extendEnvironment(env => { for (const f of fs.readdirSync(path.join(__dirname, 'buidler'))) {
const { contract } = env; require(path.join(__dirname, 'buidler', f));
env.contract = function (name, body) { }
// remove the default account from the accounts list used in tests, in order
// to protect tests against accidentally passing due to the contract
// deployer being used subsequently as function caller
contract(name, accounts => body(accounts.slice(1)));
};
});
module.exports = { module.exports = {
networks: { networks: {

10
buidler/env-contract.js Normal file
View File

@ -0,0 +1,10 @@
extendEnvironment(env => {
const { contract } = env;
env.contract = function (name, body) {
// remove the default account from the accounts list used in tests, in order
// to protect tests against accidentally passing due to the contract
// deployer being used subsequently as function caller
contract(name, accounts => body(accounts.slice(1)));
};
});