diff --git a/web3tests/testEvent.js b/web3tests/testEvent.js index 752fef7..0271853 100644 --- a/web3tests/testEvent.js +++ b/web3tests/testEvent.js @@ -1,7 +1,7 @@ const { assert } = require('chai'); const Web3 = require('web3'); const EventContract = require('../build/contracts/EventContract.json'); -const { deployContract, account, initWeb3, privKey } = require('../utils'); +const { deployContract, account, initWeb3, privKey, GAS_PRICE, GAS_LIMIT } = require('../utils'); const sub_account = '0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b'; const contract = require("@truffle/contract"); @@ -28,7 +28,7 @@ describe("EventContract test", async () => { const cAddress = c._address; // init subscription - await new Promise(async (resolve) => { + await new Promise(async (resolve, reject) => { c.events.allEvents((error, data) => { assert.equal(data.event, 'e'); assert.equal(data.address, cAddress); @@ -38,7 +38,10 @@ describe("EventContract test", async () => { assert.equal(data.address, cAddress); resolve(); }) - .on('error', console.error); + .on('error', (err) => { + console.error(err); + reject(); + }); // initialize another web3 connection with dev signer and fire tx'es to subscribe to const anotherWeb3 = initWeb3(); @@ -47,8 +50,13 @@ describe("EventContract test", async () => { unlinked_binary: EventContract.bytecode, }); EC.setProvider(anotherWeb3.currentProvider); - const cc = await EC.at(cAddress); - const tx = await cc.emitEvent({ from: account }); + try { + const cc = await EC.at(cAddress); + const tx = await cc.emitEvent({ from: account }); + } catch (err) { + console.error(err); + reject(err); + } }); }) });