Browse Source

Merge pull request #1081 from bitcoinjs/fasttrav

Support Travis running tests concurrently
addLowRGrinding
Daniel Cousens 7 years ago
committed by GitHub
parent
commit
0d76f00917
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      test/integration/cltv.js

49
test/integration/cltv.js

@ -105,28 +105,29 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
], redeemScript) ], redeemScript)
tx.setInputScript(0, redeemScriptSig) tx.setInputScript(0, redeemScriptSig)
regtestUtils.broadcast(tx.toHex(), function (err) { // TODO: test that it failures _prior_ to expiry, unfortunately, race conditions when run concurrently
// fails before the expiry // regtestUtils.broadcast(tx.toHex(), function (err) {
assert.throws(function () { // // fails before the expiry
if (err) throw err // assert.throws(function () {
}, /Error: 64: non-final/) // if (err) throw err
// }, /Error: 64: non-final/)
// into the future!
regtestUtils.mine(51, function (err) { // into the future!
regtestUtils.mine(51, function (err) {
if (err) return done(err)
regtestUtils.broadcast(tx.toHex(), function (err) {
if (err) return done(err) if (err) return done(err)
regtestUtils.broadcast(tx.toHex(), function (err) { regtestUtils.verify({
if (err) return done(err) txId: tx.getId(),
address: regtestUtils.RANDOM_ADDRESS,
regtestUtils.verify({ vout: 0,
txId: tx.getId(), value: 7e4
address: regtestUtils.RANDOM_ADDRESS, }, done)
vout: 0,
value: 7e4
}, done)
})
}) })
}) })
// })
}) })
}) })
}) })
@ -136,8 +137,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
this.timeout(30000) this.timeout(30000)
// two hours ago // two hours ago
var timeUtc = utcNow() - (3600 * 2) var lockTime = bip65.encode({ utc: utcNow() - (3600 * 2) })
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc) var redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript)) var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest) var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest)
@ -146,7 +147,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
if (err) return done(err) if (err) return done(err)
var txb = new bitcoin.TransactionBuilder(regtest) var txb = new bitcoin.TransactionBuilder(regtest)
txb.setLockTime(timeUtc) txb.setLockTime(lockTime)
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe) txb.addInput(unspent.txId, unspent.vout, 0xfffffffe)
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 8e4) txb.addOutput(regtestUtils.RANDOM_ADDRESS, 8e4)
@ -178,8 +179,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
this.timeout(30000) this.timeout(30000)
// two hours from now // two hours from now
var timeUtc = utcNow() + (3600 * 2) var lockTime = bip65.encode({ utc: utcNow() + (3600 * 2) })
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc) var redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript)) var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest) var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest)
@ -188,7 +189,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
if (err) return done(err) if (err) return done(err)
var txb = new bitcoin.TransactionBuilder(regtest) var txb = new bitcoin.TransactionBuilder(regtest)
txb.setLockTime(timeUtc) txb.setLockTime(lockTime)
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe) txb.addInput(unspent.txId, unspent.vout, 0xfffffffe)
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 1e4) txb.addOutput(regtestUtils.RANDOM_ADDRESS, 1e4)

Loading…
Cancel
Save