Skip to content

Commit

Permalink
Merge 61ee99c into 1a086e4
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz authored Jan 18, 2021
2 parents 1a086e4 + 61ee99c commit d926f8b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ describe('Wallet HTTP', function() {
});

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

const json = await wallet.createOpen({
name: name
});

let entered = false;
node.mempool.on('tx', () => entered = true);

// wait for tx event on mempool
await common.event(node.mempool, 'tx');

Expand All @@ -269,20 +270,21 @@ describe('Wallet HTTP', function() {

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

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

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

const json = await wallet.createOpen({
name: name,
broadcast: false
});

let entered = false;
node.mempool.on('tx', () => {
entered = true;
assert.ok(false);
});

await sleep(500);

// tx is not in the mempool
Expand All @@ -305,21 +307,22 @@ describe('Wallet HTTP', function() {

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

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

it('should create an open and not sign the transaction', async () => {
let entered = false;
const handler = () => entered = true;
node.mempool.on('tx', handler);

const json = await wallet.createOpen({
name: name,
broadcast: false,
sign: false
});

let entered = false;
node.mempool.on('tx', () => {
entered = true;
assert.ok(false);
});

await sleep(500);

// tx is not in the mempool
Expand All @@ -341,6 +344,9 @@ describe('Wallet HTTP', function() {

// transaction not valid
assert.equal(mtx.verify(), false);

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

it('should throw error with incompatible broadcast and sign options', async () => {
Expand Down

0 comments on commit d926f8b

Please sign in to comment.