change another storage test

This commit is contained in:
Jonathan Rainville 2018-05-30 17:35:54 -04:00
parent 049af73294
commit 3555575ff9
3 changed files with 22 additions and 16 deletions

View File

@ -81,6 +81,9 @@ class Test {
if (!callback) { if (!callback) {
callback = function () {}; callback = function () {};
} }
if (!options.contracts) {
throw new Error(__('No contracts specified in the options'));
}
this.options = utils.recursiveMerge(this.options, options); this.options = utils.recursiveMerge(this.options, options);
this.simOptions = this.options.simulatorOptions || {}; this.simOptions = this.options.simulatorOptions || {};
this.ready = false; this.ready = false;
@ -145,8 +148,8 @@ class Test {
} }
require(module) { require(module) {
if (module.startsWith('contracts/')) { if (module.startsWith('Embark/contracts/')) {
const contractName = module.substr(10); const contractName = module.substr(17);
if (!this.engine.contractsManager.contracts[contractName]) { if (!this.engine.contractsManager.contracts[contractName]) {
throw new Error(__('No contract with the name %s', contractName)); throw new Error(__('No contract with the name %s', contractName));
} }

View File

@ -1,21 +1,24 @@
contract("AnotherStorage", function() { /*global contract, config, it, embark*/
this.timeout(0); const assert = require('assert');
before(function(done) { const AnotherStorage = embark.require('Embark/contracts/AnotherStorage');
this.timeout(0); const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
var contractsConfig = {
config({
contracts: {
"SimpleStorage": { "SimpleStorage": {
args: [100] args: [100]
}, },
"AnotherStorage": { "AnotherStorage": {
args: ["$SimpleStorage"] args: ["$SimpleStorage"]
} }
}; }
EmbarkSpec.deployAll(contractsConfig, () => { done() });
}); });
contract("AnotherStorage", function() {
this.timeout(0);
it("set SimpleStorage address", async function() { it("set SimpleStorage address", async function() {
let result = await AnotherStorage.methods.simpleStorageAddress().call(); let result = await AnotherStorage.methods.simpleStorageAddress().call();
assert.equal(result.toString(), SimpleStorage.options.address); assert.equal(result.toString(), SimpleStorage.options.address);
}); });
}); });

View File

@ -1,6 +1,6 @@
/*global contract, config, it, embark*/ /*global contract, config, it, embark*/
const assert = require('assert'); const assert = require('assert');
const SimpleStorage = embark.require('contracts/SimpleStorage'); const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
config({ config({
contracts: { contracts: {