Merge pull request #746 from embark-framework/bug_fix/tests-ws-bug
Fix test_app with a WS node
This commit is contained in:
commit
a0d864b8ae
|
@ -20,6 +20,8 @@ class Provider {
|
||||||
self.provider = new this.web3.providers.HttpProvider(self.web3Endpoint);
|
self.provider = new this.web3.providers.HttpProvider(self.web3Endpoint);
|
||||||
} else if (this.type === 'ws') {
|
} else if (this.type === 'ws') {
|
||||||
self.provider = new this.web3.providers.WebsocketProvider(self.web3Endpoint, {headers: {Origin: "embark"}});
|
self.provider = new this.web3.providers.WebsocketProvider(self.web3Endpoint, {headers: {Origin: "embark"}});
|
||||||
|
self.provider.on('error', e => self.logger.error('Websocket Error', e));
|
||||||
|
self.provider.on('end', e => self.logger.error('Websocket connection ended', e));
|
||||||
} else {
|
} else {
|
||||||
return callback(__("contracts config error: unknown deployment type %s", this.type));
|
return callback(__("contracts config error: unknown deployment type %s", this.type));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ const parseResponse = function (ipc, resBody) {
|
||||||
commList[jsonO.id].transactionHash = jsonO.result;
|
commList[jsonO.id].transactionHash = jsonO.result;
|
||||||
transactions[jsonO.result] = {commListId: jsonO.id};
|
transactions[jsonO.result] = {commListId: jsonO.id};
|
||||||
} else if (receipts[jsonO.id] && jsonO.result && jsonO.result.blockNumber) {
|
} else if (receipts[jsonO.id] && jsonO.result && jsonO.result.blockNumber) {
|
||||||
|
// TODO find out why commList[receipts[jsonO.id]] is sometimes not defined
|
||||||
|
if (!commList[receipts[jsonO.id]]) {
|
||||||
|
commList[receipts[jsonO.id]] = {};
|
||||||
|
}
|
||||||
commList[receipts[jsonO.id]].blockNumber = jsonO.result.blockNumber;
|
commList[receipts[jsonO.id]].blockNumber = jsonO.result.blockNumber;
|
||||||
commList[receipts[jsonO.id]].gasUsed = jsonO.result.gasUsed;
|
commList[receipts[jsonO.id]].gasUsed = jsonO.result.gasUsed;
|
||||||
commList[receipts[jsonO.id]].status = jsonO.result.status;
|
commList[receipts[jsonO.id]].status = jsonO.result.status;
|
||||||
|
|
|
@ -327,11 +327,13 @@ class Test {
|
||||||
if (newContract.options) {
|
if (newContract.options) {
|
||||||
newContract.options.from = self.web3.eth.defaultAccount;
|
newContract.options.from = self.web3.eth.defaultAccount;
|
||||||
newContract.options.data = contract.code;
|
newContract.options.data = contract.code;
|
||||||
|
if (!newContract.options.data.startsWith('0x')) {
|
||||||
|
newContract.options.data = '0x' + newContract.options.data;
|
||||||
|
}
|
||||||
newContract.options.gas = 6000000;
|
newContract.options.gas = 6000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.setPrototypeOf(self.contracts[contract.className], newContract);
|
Object.setPrototypeOf(self.contracts[contract.className], newContract);
|
||||||
Object.assign(self.contracts[contract.className], newContract);
|
|
||||||
|
|
||||||
eachCb();
|
eachCb();
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
|
|
@ -23,9 +23,6 @@ contract SimpleStorage is Ownable {
|
||||||
|
|
||||||
function set(uint x) public {
|
function set(uint x) public {
|
||||||
storedData = x;
|
storedData = x;
|
||||||
for(uint i = 0; i < 1000; i++) {
|
|
||||||
storedData += i;
|
|
||||||
}
|
|
||||||
Assert.triggerEvent(true, "hi");
|
Assert.triggerEvent(true, "hi");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ contract("SimpleStorage Deploy", function () {
|
||||||
it("set storage value", async function () {
|
it("set storage value", async function () {
|
||||||
await SimpleStorageInstance.methods.set(150).send();
|
await SimpleStorageInstance.methods.set(150).send();
|
||||||
let result = await SimpleStorageInstance.methods.get().call();
|
let result = await SimpleStorageInstance.methods.get().call();
|
||||||
assert.strictEqual(parseInt(result, 10), 499650);
|
assert.strictEqual(parseInt(result, 10), 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*global contract, config, it, assert, web3*/
|
/*global contract, config, it, assert, web3*/
|
||||||
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
||||||
let accounts;
|
let accounts;
|
||||||
|
const Utils = require('embarkjs').Utils;
|
||||||
|
|
||||||
config({
|
config({
|
||||||
contracts: {
|
contracts: {
|
||||||
|
@ -21,10 +22,16 @@ contract("SimpleStorage", function () {
|
||||||
assert.strictEqual(parseInt(result, 10), 100);
|
assert.strictEqual(parseInt(result, 10), 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", async function () {
|
it("set storage value", function (done) {
|
||||||
await SimpleStorage.methods.set(150).send();
|
// await SimpleStorage.methods.set(150).send();
|
||||||
|
Utils.secureSend(web3, SimpleStorage.methods.set(150), {}, false, async function(err) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
let result = await SimpleStorage.methods.get().call();
|
let result = await SimpleStorage.methods.get().call();
|
||||||
assert.strictEqual(parseInt(result, 10), 499650);
|
assert.strictEqual(parseInt(result, 10), 150);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set defaultAccount", async function () {
|
it("should set defaultAccount", async function () {
|
||||||
|
|
Loading…
Reference in New Issue