Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Created July 20, 2019 00:07
Show Gist options
  • Save pinheadmz/6cc0238d8263b88d86bb87aa5f2a1788 to your computer and use it in GitHub Desktop.
Save pinheadmz/6cc0238d8263b88d86bb87aa5f2a1788 to your computer and use it in GitHub Desktop.
it('should fund both wallets', async () => {
wdb.on('balance', (wallet, balance) => {
if (balance.confirmed === 2000 * 10 * 1e6)
wdb.emit(`balance trigger ${wallet.wid}`);
});
const waitForBalance1 = new Promise( (resolve) => {
wdb.once('balance trigger 1', () => {
resolve();
});
});
const waitForBalance2 = new Promise( (resolve) => {
wdb.once('balance trigger 2', () => {
resolve();
});
});
await mineBlocks(10, ownerAddr);
await mineBlocks(10, buyerAddr);
await waitForBalance1;
await waitForBalance2;
const ownerBal = await owner.getBalance();
const buyerBal = await owner.getBalance();
assert(ownerBal.confirmed === 2000 * 10 * 1e6);
assert(buyerBal.confirmed === 2000 * 10 * 1e6);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment