fix websocket test, but still some hangs on second test run

This commit is contained in:
Jonathan Rainville 2018-08-24 12:09:38 -04:00
parent 5fe86e35d1
commit 13e0d453ae
6 changed files with 14 additions and 6 deletions

View File

@ -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));
}

View File

@ -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;

View File

@ -326,11 +326,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) => {

View File

@ -23,9 +23,9 @@ contract SimpleStorage is Ownable {
function set(uint x) public {
storedData = x;
for(uint i = 0; i < 1000; i++) {
storedData += i;
}
// for(uint i = 0; i < 1000; i++) {
// storedData += i;
// }
Assert.triggerEvent(true, "hi");
}

View File

@ -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);
});
});

View File

@ -24,7 +24,7 @@ contract("SimpleStorage", function () {
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);
assert.strictEqual(parseInt(result, 10), 150);
});
it("should set defaultAccount", async function () {