diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index b74b7f55c..7e30d94dc 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -225,12 +225,14 @@ class ContractsManager { if (arg[0] === "$") { self.contractDependencies[className] = self.contractDependencies[className] || []; self.contractDependencies[className].push(arg.substr(1)); + self.checkDependency(className, arg.substr(1)); } if (Array.isArray(arg)) { for (let sub_arg of arg) { if (sub_arg[0] === "$") { self.contractDependencies[className] = self.contractDependencies[className] || []; self.contractDependencies[className].push(sub_arg.substr(1)); + self.checkDependency(className, sub_arg.substr(1)); } } } @@ -259,6 +261,21 @@ class ContractsManager { }); } + checkDependency(className, dependencyName) { + if (!this.contractDependencies[className]) { + return; + } + if (!this.contracts[dependencyName]) { + this.logger.warn(__('{{className}} has a dependency on {{dependencyName}}', {className, dependencyName}) + + __(', but it is not present in the contracts')); + return; + } + if (!this.contracts[dependencyName].deploy) { + this.logger.warn(__('{{className}} has a dependency on {{dependencyName}}', {className, dependencyName}) + + __(', but it is not set to deploy. It could be an interface.')); + } + } + getContract(className) { return this.contracts[className]; } diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index 5bdc738cb..c054c3534 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -44,10 +44,4 @@ contract("AnotherStorage", function() { let result = await AnotherStorage.simpleStorageAddress(); assert.equal(result.toString(), SimpleStorage.options.address); }); - - it('should set the balance correctly', async function () { - const balance = await web3.eth.getBalance(accounts[0]); - assert.ok(balance < 5000000000000000000); - assert.ok(balance > 4000000000000000000); - }); }); diff --git a/test_apps/test_app/test/interface_spec.js b/test_apps/test_app/test/interface_spec.js new file mode 100644 index 000000000..f546c2a83 --- /dev/null +++ b/test_apps/test_app/test/interface_spec.js @@ -0,0 +1,22 @@ +/*global contract, config, it*/ +const assert = require('assert'); +const AnotherStorage = require('Embark/contracts/AnotherStorage'); + +config({ + contracts: { + AnotherStorage: { + args: ['$ERC20'] + } + } +}); + + +contract("AnotherStorageWithInterface", function() { + this.timeout(0); + + it("sets an empty address because ERC20 is an interface", async function() { + let result = await AnotherStorage.methods.simpleStorageAddress().call(); + assert.equal(result.toString(), '0x0000000000000000000000000000000000000000'); + }); +}); + diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index c194dda60..cab91835d 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -1,6 +1,5 @@ -/*global contract, config, it, embark, assert, web3*/ +/*global contract, it, embark, assert, before*/ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); -let accounts; contract("SimpleStorage Deploy", function () { let SimpleStorageInstance;