浏览代码

perf: replace the console.logs with Errors

test: set a deterministic mnemonic for the coverage network
Paul Razvan Berg 4 年之前
父节点
当前提交
5df9c857b8
共有 2 个文件被更改,包括 11 次插入4 次删除
  1. 9 0
      .solcover.js
  2. 2 4
      buidler.config.ts

+ 9 - 0
.solcover.js

@@ -1,5 +1,11 @@
 const shell = require("shelljs");
 
+/* The environment variables are loaded in buidler.config.ts */
+const mnemonic = process.env.MNEMONIC;
+if (!mnemonic) {
+  throw new Error("Please set your MNEMONIC in a .env file");
+}
+
 module.exports = {
   istanbulReporter: ["html"],
   mocha: {
@@ -13,5 +19,8 @@ module.exports = {
     shell.rm("-rf", "./artifacts");
     shell.rm("-rf", "./typechain");
   },
+  providerOptions: {
+    mnemonic,
+  },
   skipFiles: ["mocks", "test"],
 };

+ 2 - 4
buidler.config.ts

@@ -17,13 +17,11 @@ usePlugin("solidity-coverage");
  */
 function createNetworkConfig(network?: string): { accounts: HDAccountsConfig; url: string | undefined } {
   if (!process.env.MNEMONIC) {
-    console.log("Please set your MNEMONIC in a .env file");
-    process.exit(1);
+    throw new Error("Please set your MNEMONIC in a .env file");
   }
 
   if (!process.env.INFURA_API_KEY) {
-    console.log("Please set your INFURA_API_KEY");
-    process.exit(1);
+    throw new Error("Please set your INFURA_API_KEY");
   }
 
   return {