diff --git a/lib/modules/blockchain_connector/provider.js b/lib/modules/blockchain_connector/provider.js index 59b1bdb9..27576c46 100644 --- a/lib/modules/blockchain_connector/provider.js +++ b/lib/modules/blockchain_connector/provider.js @@ -20,6 +20,8 @@ class Provider { self.provider = new this.web3.providers.HttpProvider(self.web3Endpoint); } else if (this.type === 'ws') { 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 { return callback(__("contracts config error: unknown deployment type %s", this.type)); } diff --git a/lib/modules/blockchain_process/proxy.js b/lib/modules/blockchain_process/proxy.js index 2ff60b0c..38c7c531 100644 --- a/lib/modules/blockchain_process/proxy.js +++ b/lib/modules/blockchain_process/proxy.js @@ -40,6 +40,10 @@ const parseResponse = function (ipc, resBody) { commList[jsonO.id].transactionHash = jsonO.result; transactions[jsonO.result] = {commListId: jsonO.id}; } 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]].gasUsed = jsonO.result.gasUsed; commList[receipts[jsonO.id]].status = jsonO.result.status; diff --git a/lib/tests/test.js b/lib/tests/test.js index 6646ee14..1e7cc774 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -327,11 +327,13 @@ class Test { if (newContract.options) { newContract.options.from = self.web3.eth.defaultAccount; newContract.options.data = contract.code; + if (!newContract.options.data.startsWith('0x')) { + newContract.options.data = '0x' + newContract.options.data; + } newContract.options.gas = 6000000; } Object.setPrototypeOf(self.contracts[contract.className], newContract); - Object.assign(self.contracts[contract.className], newContract); eachCb(); }, (err) => { diff --git a/test_apps/test_app/app/contracts/simple_storage.sol b/test_apps/test_app/app/contracts/simple_storage.sol index 05808ddb..608b3af9 100644 --- a/test_apps/test_app/app/contracts/simple_storage.sol +++ b/test_apps/test_app/app/contracts/simple_storage.sol @@ -23,9 +23,6 @@ contract SimpleStorage is Ownable { function set(uint x) public { storedData = x; - for(uint i = 0; i < 1000; i++) { - storedData += i; - } Assert.triggerEvent(true, "hi"); } diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index cab91835..b81c8178 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -16,7 +16,7 @@ contract("SimpleStorage Deploy", function () { it("set storage value", async function () { await SimpleStorageInstance.methods.set(150).send(); let result = await SimpleStorageInstance.methods.get().call(); - assert.strictEqual(parseInt(result, 10), 499650); + assert.strictEqual(parseInt(result, 10), 150); }); }); diff --git a/test_apps/test_app/test/simple_storage_spec.js b/test_apps/test_app/test/simple_storage_spec.js index 22c3f7af..5596da69 100644 --- a/test_apps/test_app/test/simple_storage_spec.js +++ b/test_apps/test_app/test/simple_storage_spec.js @@ -1,6 +1,7 @@ /*global contract, config, it, assert, web3*/ const SimpleStorage = require('Embark/contracts/SimpleStorage'); let accounts; +const Utils = require('embarkjs').Utils; config({ contracts: { @@ -21,10 +22,16 @@ contract("SimpleStorage", function () { assert.strictEqual(parseInt(result, 10), 100); }); - it("set storage value", async function () { - await SimpleStorage.methods.set(150).send(); - let result = await SimpleStorage.methods.get().call(); - assert.strictEqual(parseInt(result, 10), 499650); + it("set storage value", function (done) { + // 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(); + assert.strictEqual(parseInt(result, 10), 150); + done(); + }); }); it("should set defaultAccount", async function () {