Skip to content

Commit

Permalink
integration: throw meaningful errors if no unspent is found
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Aug 25, 2015
1 parent 845c1dc commit 3be5dc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/integration/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ describe('bitcoinjs-lib (advanced)', function () {
blockchain.t.addresses.unspents(address, function (err, unspents) {
if (err) return done(err)

// filter small unspents
unspents = unspents.filter(function (unspent) {
return unspent.value > 1e4
})

// use the oldest unspent
var unspent = unspents.pop()
if (!unspent) throw new Error('Faucet didn\'t provide an unspent')

var tx = new bitcoin.TransactionBuilder(network)
var data = new Buffer('bitcoinjs-lib')
var dataScript = bitcoin.script.nullDataOutput(data)

var unspent = unspents.pop()

tx.addInput(unspent.txId, unspent.vout)
tx.addOutput(dataScript, 1000)
tx.sign(0, keyPair)
Expand Down
1 change: 1 addition & 0 deletions test/integration/multisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('bitcoinjs-lib (multisig)', function () {

// use the oldest unspent
var unspent = unspents.pop()
if (!unspent) throw new Error('Faucet didn\'t provide an unspent')

// make a random destination address
var targetAddress = bitcoin.ECPair.makeRandom({
Expand Down

1 comment on commit 3be5dc8

@dcousens
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.