feat(@embark/test-runner): show interface contract message in tests

But only show it if the contract was in the contract config
This commit is contained in:
Jonathan Rainville 2019-05-08 09:45:54 -04:00
parent 334d3bcdc5
commit f9d7a3f41b
3 changed files with 16 additions and 7 deletions

View File

@ -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();
},

View File

@ -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);
});
},

View File

@ -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