Skip to content

Commit

Permalink
test: count 'tx' events emitted by mempool in wallet-http-test
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Jan 18, 2021
1 parent 61ee99c commit c36f270
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ describe('Wallet HTTP', function() {
});

it('should create an open and broadcast the tx', async () => {
let entered = false;
const handler = () => entered = true;
let emitted = 0;
const handler = () => emitted++;
node.mempool.on('tx', handler);

const json = await wallet.createOpen({
Expand All @@ -263,14 +263,15 @@ describe('Wallet HTTP', function() {
// wait for tx event on mempool
await common.event(node.mempool, 'tx');

assert.equal(entered, true);
const mempool = await nclient.getMempool();

assert.ok(mempool.includes(json.hash));

const opens = json.outputs.filter(output => output.covenant.type === types.OPEN);
assert.equal(opens.length, 1);

assert.equal(emitted, 1);

// reset for next test
node.mempool.removeListener('tx', handler);
});
Expand Down

0 comments on commit c36f270

Please sign in to comment.