Skip to content

Commit 0d76f00

Browse files
authored
Merge pull request bitcoinjs#1081 from bitcoinjs/fasttrav
Support Travis running tests concurrently
2 parents 5a11f70 + b267a9e commit 0d76f00

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

test/integration/cltv.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,29 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
105105
], redeemScript)
106106
tx.setInputScript(0, redeemScriptSig)
107107

108-
regtestUtils.broadcast(tx.toHex(), function (err) {
109-
// fails before the expiry
110-
assert.throws(function () {
111-
if (err) throw err
112-
}, /Error: 64: non-final/)
113-
114-
// into the future!
115-
regtestUtils.mine(51, function (err) {
108+
// TODO: test that it failures _prior_ to expiry, unfortunately, race conditions when run concurrently
109+
// regtestUtils.broadcast(tx.toHex(), function (err) {
110+
// // fails before the expiry
111+
// assert.throws(function () {
112+
// if (err) throw err
113+
// }, /Error: 64: non-final/)
114+
115+
// into the future!
116+
regtestUtils.mine(51, function (err) {
117+
if (err) return done(err)
118+
119+
regtestUtils.broadcast(tx.toHex(), function (err) {
116120
if (err) return done(err)
117121

118-
regtestUtils.broadcast(tx.toHex(), function (err) {
119-
if (err) return done(err)
120-
121-
regtestUtils.verify({
122-
txId: tx.getId(),
123-
address: regtestUtils.RANDOM_ADDRESS,
124-
vout: 0,
125-
value: 7e4
126-
}, done)
127-
})
122+
regtestUtils.verify({
123+
txId: tx.getId(),
124+
address: regtestUtils.RANDOM_ADDRESS,
125+
vout: 0,
126+
value: 7e4
127+
}, done)
128128
})
129129
})
130+
// })
130131
})
131132
})
132133
})
@@ -136,8 +137,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
136137
this.timeout(30000)
137138

138139
// two hours ago
139-
var timeUtc = utcNow() - (3600 * 2)
140-
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc)
140+
var lockTime = bip65.encode({ utc: utcNow() - (3600 * 2) })
141+
var redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
141142
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
142143
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest)
143144

@@ -146,7 +147,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
146147
if (err) return done(err)
147148

148149
var txb = new bitcoin.TransactionBuilder(regtest)
149-
txb.setLockTime(timeUtc)
150+
txb.setLockTime(lockTime)
150151
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe)
151152
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 8e4)
152153

@@ -178,8 +179,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
178179
this.timeout(30000)
179180

180181
// two hours from now
181-
var timeUtc = utcNow() + (3600 * 2)
182-
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc)
182+
var lockTime = bip65.encode({ utc: utcNow() + (3600 * 2) })
183+
var redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
183184
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
184185
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest)
185186

@@ -188,7 +189,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
188189
if (err) return done(err)
189190

190191
var txb = new bitcoin.TransactionBuilder(regtest)
191-
txb.setLockTime(timeUtc)
192+
txb.setLockTime(lockTime)
192193
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe)
193194
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 1e4)
194195

0 commit comments

Comments
 (0)