From cd78c20e0ea368737c728e64232c428ffa8ad5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Eklo=CC=88f?= Date: Fri, 21 Apr 2017 20:08:17 +0300 Subject: [PATCH] await event handling result in Bounty test. Fixes #202 --- test/Bounty.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Bounty.js b/test/Bounty.js index 191179c42..286845036 100644 --- a/test/Bounty.js +++ b/test/Bounty.js @@ -52,7 +52,7 @@ contract('Bounty', function(accounts) { let bounty = await SecureTargetBounty.new(); let event = bounty.TargetCreated({}); - event.watch(async function(err, result) { + let watcher = async function(err, result) { event.stopWatching(); if (err) { throw err; } @@ -66,8 +66,8 @@ contract('Bounty', function(accounts) { await bounty.claim(targetAddress, {from:researcher}); assert.isTrue(false); // should never reach here } catch(error) { - let reClaimedBounty = await bounty.claimed.call(); - assert.isFalse(reClaimedBounty); + let reClaimedBounty = await bounty.claimed.call(); + assert.isFalse(reClaimedBounty); } try { @@ -77,8 +77,9 @@ contract('Bounty', function(accounts) { assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()); } - }); + }; bounty.createTarget({from:researcher}); + await awaitEvent(event, watcher); }); });