fix web3 being reseted every test and fix ens failing on web3 reset

This commit is contained in:
Jonathan Rainville 2018-10-18 10:59:12 -04:00 committed by Pascal Precht
parent ce3f9bdf25
commit 985358b088
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
4 changed files with 15 additions and 3 deletions

View File

@ -77,6 +77,9 @@ class ENS {
this.registerConsoleCommands(); this.registerConsoleCommands();
} }
reset() {
this.configured = false;
}
registerConsoleCommands() { registerConsoleCommands() {
this.embark.registerConsoleCommand((cmd, _options) => { this.embark.registerConsoleCommand((cmd, _options) => {
@ -106,6 +109,7 @@ class ENS {
registerEvents() { registerEvents() {
this.embark.registerActionForEvent("deploy:beforeAll", this.configureContractsAndRegister.bind(this)); this.embark.registerActionForEvent("deploy:beforeAll", this.configureContractsAndRegister.bind(this));
this.events.setCommandHandler('blockchain:reset', this.reset.bind(this));
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this)); this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
} }

View File

@ -128,7 +128,8 @@ class Test {
return callback(__("contracts config error: unknown deployment type %s", type)); return callback(__("contracts config error: unknown deployment type %s", type));
} }
if (accounts || port !== this.simOptions.port || type !== this.simOptions.type || host !== this.simOptions.host) { if (accounts || (port && port !== this.simOptions.port) || (type && type !== this.simOptions.type) ||
(host && host !== this.simOptions.host)) {
resetServices = true; resetServices = true;
} }

View File

@ -16,7 +16,7 @@ contract("AnotherStorageWithInterface", function() {
it("sets an empty address because ERC20 is an interface", async function() { it("sets an empty address because ERC20 is an interface", async function() {
let result = await AnotherStorage.methods.simpleStorageAddress().call(); let result = await AnotherStorage.methods.simpleStorageAddress().call();
assert.equal(result.toString(), '0x0000000000000000000000000000000000000000'); assert.strictEqual(result.toString(), '0x0000000000000000000000000000000000000000');
}); });
}); });

View File

@ -1,4 +1,4 @@
/*global describe, config, it*/ /*global describe, config, it, web3*/
const assert = require('assert'); const assert = require('assert');
const Token = require('Embark/contracts/Token'); const Token = require('Embark/contracts/Token');
const MyToken = require('Embark/contracts/MyToken'); const MyToken = require('Embark/contracts/MyToken');
@ -85,4 +85,11 @@ describe("Token", function () {
it("should not deploy if deployIf returns false", function() { it("should not deploy if deployIf returns false", function() {
assert.ok(!SomeContract.options.address); assert.ok(!SomeContract.options.address);
}); });
it("should set the ens attr to the address of embark.eth", async function() {
let result = await Test.methods.ens().call();
// Testing that it is an address as we don't really know the address
assert.strictEqual(web3.utils.isAddress(result), true);
assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000');
});
}); });