integration: throw meaningful errors if no unspent is found

This commit is contained in:
Daniel Cousens 2015-08-25 14:11:49 +10:00
parent 845c1dc199
commit 3be5dc88a1
2 changed files with 10 additions and 2 deletions

View file

@ -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)

View file

@ -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({