From f9d7a3f41be7b602a9c0213548ae6bfc5e250b1e Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 8 May 2019 09:45:54 -0400 Subject: [PATCH] feat(@embark/test-runner): show interface contract message in tests But only show it if the contract was in the contract config --- .../embark-contracts-manager/src/index.js | 20 +++++++++++++------ packages/embark-test-runner/src/test.js | 1 + site/source/docs/troubleshooting.md | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/embark-contracts-manager/src/index.js b/packages/embark-contracts-manager/src/index.js index cb99e23a2..e0e5ac1c5 100644 --- a/packages/embark-contracts-manager/src/index.js +++ b/packages/embark-contracts-manager/src/index.js @@ -14,6 +14,7 @@ class ContractsManager { this.events = embark.events; this.fs = embark.fs; this.plugins = options.plugins; + this.currentContext = embark.currentContext || []; this.contracts = {}; this.contractDependencies = {}; @@ -376,7 +377,11 @@ class ContractsManager { }, function setDeployIntention(callback) { let className, contract; - let showInterfaceMessage = false; + let showInterfaceMessageTrace = false; + let showInterfaceMessageWarn = false; + const isTest = self.currentContext.includes(constants.contexts.test); + const contractsInConfig = Object.keys(self.contractsConfig.contracts); + for (className in self.contracts) { contract = self.contracts[className]; contract.deploy = (contract.deploy === undefined) || contract.deploy; @@ -390,17 +395,20 @@ class ContractsManager { if (contract.code === "") { const message = __("assuming %s to be an interface", className); - showInterfaceMessage = true; - if (contract.silent) { + if (contract.silent || (isTest && !contractsInConfig.includes(className))) { + showInterfaceMessageTrace = true; self.logger.trace(message); } else { - self.logger.info(message); + showInterfaceMessageWarn = true; + self.logger.warn(message); } contract.deploy = false; } } - if (showInterfaceMessage) { - self.logger.warn(__('To get more details on interface contracts, go here: %s', 'https://embark.status.im/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface'.underline)); + if (showInterfaceMessageTrace || showInterfaceMessageWarn) { + let logFunction = showInterfaceMessageWarn ? self.logger.warn : self.logger.trace; + logFunction.call(self.logger, __('To get more details on interface Smart contracts, go here: %s', 'https://embark.status.im/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface'.underline)); + } callback(); }, diff --git a/packages/embark-test-runner/src/test.js b/packages/embark-test-runner/src/test.js index 2ac5e9864..9c5353d17 100644 --- a/packages/embark-test-runner/src/test.js +++ b/packages/embark-test-runner/src/test.js @@ -216,6 +216,7 @@ class Test { console.info('Compiling contracts'.cyan); self.events.request("contracts:build", false, (err) => { self.firstDeployment = false; + console.info('Compilation done\n'.cyan); next(err); }); }, diff --git a/site/source/docs/troubleshooting.md b/site/source/docs/troubleshooting.md index 09e5c52be..b16611899 100644 --- a/site/source/docs/troubleshooting.md +++ b/site/source/docs/troubleshooting.md @@ -18,7 +18,7 @@ Issues typically occur if NodeJS and/or Embark are installed using `sudo`, avoid ## Assuming Contract to be an interface -This warning happens when Embark can't deploy one of your contracts because the compiler did not return a bytecode. +This warning happens when Embark can't deploy one of your Smart Contracts because the compiler did not return a bytecode. Here are some of the reasons: - If it inherits from an interface, it must have all the functions implemented