-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from liquality/add-extra-outputs-to-send-tran…
…saction Add sendBatchTransactions
- Loading branch information
Showing
9 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-env mocha */ | ||
/* eslint-disable no-unused-expressions */ | ||
import chai, { expect } from 'chai' | ||
import chaiAsPromised from 'chai-as-promised' | ||
import { chains } from '../common' | ||
import config from '../config' | ||
|
||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0 | ||
|
||
chai.use(chaiAsPromised) | ||
chai.use(require('chai-bignumber')()) | ||
|
||
function testTransaction (chain) { | ||
it('Sent value to 1 address', async () => { | ||
const addr = (await chain.client.wallet.getUnusedAddress()).address | ||
const value = config[chain.name].value | ||
|
||
const balBefore = await chain.client.chain.getBalance(addr) | ||
await chain.client.chain.sendTransaction(addr, value) | ||
await chains.bitcoinWithNode.client.chain.generateBlock(1) | ||
const balAfter = await chain.client.chain.getBalance(addr) | ||
|
||
expect(balBefore.plus(value).toString()).to.equal(balAfter.toString()) | ||
}) | ||
} | ||
|
||
function testBatchTransaction (chain) { | ||
it('Sent value to 2 addresses', async () => { | ||
const addr1 = 'n2LYtVFhTMy7S924ff666uRF1qEvGb9nF6' | ||
const addr2 = 'n2gEtQHgtKoxUYyXzkzmVdbFPB3kt6Ea6R' | ||
const value = config[chain.name].value | ||
|
||
const bal1Before = await chain.client.chain.getBalance(addr1) | ||
const bal2Before = await chain.client.chain.getBalance(addr2) | ||
await chain.client.chain.sendBatchTransaction([{ to: addr1, value }, { to: addr2, value }]) | ||
await chains.bitcoinWithNode.client.chain.generateBlock(1) | ||
const bal1After = await chain.client.chain.getBalance(addr1) | ||
const bal2After = await chain.client.chain.getBalance(addr2) | ||
|
||
expect(bal1Before.plus(value).toString()).to.equal(bal1After.toString()) | ||
expect(bal2Before.plus(value).toString()).to.equal(bal2After.toString()) | ||
}) | ||
} | ||
|
||
describe('Send Transactions', function () { | ||
this.timeout(config.timeout) | ||
|
||
describe('Bitcoin - Ledger', () => { | ||
testTransaction(chains.bitcoinWithLedger) | ||
}) | ||
}) | ||
|
||
describe('Send Batch Transactions', function () { | ||
this.timeout(config.timeout) | ||
|
||
describe('Bitcoin - Ledger', () => { | ||
testBatchTransaction(chains.bitcoinWithLedger) | ||
}) | ||
}) |