diff --git a/lib/core/config.js b/lib/core/config.js index 75e5b86f3..89dd2b499 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -301,7 +301,7 @@ Config.prototype.loadPluginContractFiles = function() { contractsPlugins.forEach(function(plugin) { plugin.contractsFiles.forEach(function(file) { var filename = file.replace('./',''); - self.contractsFiles.push(new File({filename: filename, type: File.types.custom, resolver: function(callback) { + self.contractsFiles.push(new File({filename: filename, type: File.types.custom, path: filename, resolver: function(callback) { callback(plugin.loadPluginFile(file)); }})); }); diff --git a/test_apps/test_app/extensions/embark-service/contracts/pluginSimpleStorage.sol b/test_apps/test_app/extensions/embark-service/contracts/pluginSimpleStorage.sol new file mode 100644 index 000000000..4d01d6b32 --- /dev/null +++ b/test_apps/test_app/extensions/embark-service/contracts/pluginSimpleStorage.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.4.18; +contract PluginStorage { + address public simpleStorageAddress; + address simpleStorageAddress2; + + function PluginStorage(address addr) public { + simpleStorageAddress = addr; + } + +} diff --git a/test_apps/test_app/extensions/embark-service/index.js b/test_apps/test_app/extensions/embark-service/index.js index 0ca3ff1d5..7b0d62613 100644 --- a/test_apps/test_app/extensions/embark-service/index.js +++ b/test_apps/test_app/extensions/embark-service/index.js @@ -1,12 +1,22 @@ -var Haml = require('haml'); +const Haml = require('haml'); -module.exports = function(embark) { - embark.registerServiceCheck('PluginService', function(cb) { +module.exports = function (embark) { + embark.registerServiceCheck('PluginService', function (cb) { cb({name: "ServiceName", status: "on"}); }); - embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function(opts) { - var source = opts.source; - return Haml.render(source); + embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function (opts) { + return Haml.render(opts.source); }); + + embark.registerContractConfiguration({ + "default": { + "contracts": { + "PluginStorage": { + "args": ["$SimpleStorage"] + } + } + } + }); + embark.addContractFile("./contracts/pluginSimpleStorage.sol"); }; diff --git a/test_apps/test_app/test/plugin_storage_spec.js b/test_apps/test_app/test/plugin_storage_spec.js new file mode 100644 index 000000000..24a58c4e8 --- /dev/null +++ b/test_apps/test_app/test/plugin_storage_spec.js @@ -0,0 +1,26 @@ +/*global contract, before, EmbarkSpec, PluginStorage, SimpleStorage, it*/ +const assert = require('assert'); + +contract("PluginSimpleStorage", function () { + this.timeout(0); + + before((done) => { + const contractsConfig = { + "SimpleStorage": { + args: [100] + }, + "PluginStorage": { + args: ["$SimpleStorage"] + } + }; + EmbarkSpec.deployAll(contractsConfig, () => { + done(); + }); + }); + + it("set SimpleStorage address", async function () { + let result = await PluginStorage.methods.simpleStorageAddress().call(); + assert.equal(result.toString(), SimpleStorage.options.address); + }); + +});