Skip to content

Commit

Permalink
feat(@embark/test-runner): show interface contract message in tests
Browse files Browse the repository at this point in the history
But only show it if the contract was in the contract config
  • Loading branch information
jrainville committed May 10, 2019
1 parent 334d3bc commit f9d7a3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
20 changes: 14 additions & 6 deletions packages/embark-contracts-manager/src/index.js
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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;
Expand All @@ -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();
},
Expand Down
1 change: 1 addition & 0 deletions packages/embark-test-runner/src/test.js
Expand Up @@ -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);
});
},
Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/troubleshooting.md
Expand Up @@ -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
Expand Down

0 comments on commit f9d7a3f

Please sign in to comment.