test add config and contract and add test

This commit is contained in:
Jonathan Rainville 2018-04-25 13:05:58 -04:00
parent acf1fa427b
commit c818326f2e
4 changed files with 53 additions and 7 deletions

View File

@ -301,7 +301,7 @@ Config.prototype.loadPluginContractFiles = function() {
contractsPlugins.forEach(function(plugin) { contractsPlugins.forEach(function(plugin) {
plugin.contractsFiles.forEach(function(file) { plugin.contractsFiles.forEach(function(file) {
var filename = file.replace('./',''); 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)); callback(plugin.loadPluginFile(file));
}})); }}));
}); });

View File

@ -0,0 +1,10 @@
pragma solidity ^0.4.18;
contract PluginStorage {
address public simpleStorageAddress;
address simpleStorageAddress2;
function PluginStorage(address addr) public {
simpleStorageAddress = addr;
}
}

View File

@ -1,12 +1,22 @@
var Haml = require('haml'); const Haml = require('haml');
module.exports = function(embark) { module.exports = function (embark) {
embark.registerServiceCheck('PluginService', function(cb) { embark.registerServiceCheck('PluginService', function (cb) {
cb({name: "ServiceName", status: "on"}); cb({name: "ServiceName", status: "on"});
}); });
embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function(opts) { embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function (opts) {
var source = opts.source; return Haml.render(opts.source);
return Haml.render(source);
}); });
embark.registerContractConfiguration({
"default": {
"contracts": {
"PluginStorage": {
"args": ["$SimpleStorage"]
}
}
}
});
embark.addContractFile("./contracts/pluginSimpleStorage.sol");
}; };

View File

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