rm potential race conditions in non-final mixed test
This commit is contained in:
parent
1bd10dc979
commit
b267a9e606
1 changed files with 24 additions and 23 deletions
|
@ -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!
|
// into the future!
|
||||||
regtestUtils.mine(51, function (err) {
|
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…
Add table
Reference in a new issue