Skip to content

Commit c818326

Browse files
committed
test add config and contract and add test
1 parent acf1fa4 commit c818326

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

lib/core/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Config.prototype.loadPluginContractFiles = function() {
301301
contractsPlugins.forEach(function(plugin) {
302302
plugin.contractsFiles.forEach(function(file) {
303303
var filename = file.replace('./','');
304-
self.contractsFiles.push(new File({filename: filename, type: File.types.custom, resolver: function(callback) {
304+
self.contractsFiles.push(new File({filename: filename, type: File.types.custom, path: filename, resolver: function(callback) {
305305
callback(plugin.loadPluginFile(file));
306306
}}));
307307
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pragma solidity ^0.4.18;
2+
contract PluginStorage {
3+
address public simpleStorageAddress;
4+
address simpleStorageAddress2;
5+
6+
function PluginStorage(address addr) public {
7+
simpleStorageAddress = addr;
8+
}
9+
10+
}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
var Haml = require('haml');
1+
const Haml = require('haml');
22

3-
module.exports = function(embark) {
4-
embark.registerServiceCheck('PluginService', function(cb) {
3+
module.exports = function (embark) {
4+
embark.registerServiceCheck('PluginService', function (cb) {
55
cb({name: "ServiceName", status: "on"});
66
});
77

8-
embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function(opts) {
9-
var source = opts.source;
10-
return Haml.render(source);
8+
embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function (opts) {
9+
return Haml.render(opts.source);
1110
});
11+
12+
embark.registerContractConfiguration({
13+
"default": {
14+
"contracts": {
15+
"PluginStorage": {
16+
"args": ["$SimpleStorage"]
17+
}
18+
}
19+
}
20+
});
21+
embark.addContractFile("./contracts/pluginSimpleStorage.sol");
1222
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*global contract, before, EmbarkSpec, PluginStorage, SimpleStorage, it*/
2+
const assert = require('assert');
3+
4+
contract("PluginSimpleStorage", function () {
5+
this.timeout(0);
6+
7+
before((done) => {
8+
const contractsConfig = {
9+
"SimpleStorage": {
10+
args: [100]
11+
},
12+
"PluginStorage": {
13+
args: ["$SimpleStorage"]
14+
}
15+
};
16+
EmbarkSpec.deployAll(contractsConfig, () => {
17+
done();
18+
});
19+
});
20+
21+
it("set SimpleStorage address", async function () {
22+
let result = await PluginStorage.methods.simpleStorageAddress().call();
23+
assert.equal(result.toString(), SimpleStorage.options.address);
24+
});
25+
26+
});

0 commit comments

Comments
 (0)