tests: fix shadowed/unused variable warnings
This commit is contained in:
parent
cdb518686f
commit
4d6928a68b
5 changed files with 19 additions and 19 deletions
|
@ -50,14 +50,14 @@ describe('ecdsa', function () {
|
||||||
.onCall(2).returns(new BigInteger('42')) // valid, but 'bad' signature
|
.onCall(2).returns(new BigInteger('42')) // valid, but 'bad' signature
|
||||||
.onCall(3).returns(new BigInteger('53')) // valid, good signature
|
.onCall(3).returns(new BigInteger('53')) // valid, good signature
|
||||||
|
|
||||||
var checkSig = this.mock()
|
var mockCheckSig = this.mock()
|
||||||
checkSig.exactly(2)
|
mockCheckSig.exactly(2)
|
||||||
checkSig.onCall(0).returns(false) // bad signature
|
mockCheckSig.onCall(0).returns(false) // bad signature
|
||||||
checkSig.onCall(1).returns(true) // good signature
|
mockCheckSig.onCall(1).returns(true) // good signature
|
||||||
|
|
||||||
var x = new BigInteger('1').toBuffer(32)
|
var x = new BigInteger('1').toBuffer(32)
|
||||||
var h1 = new Buffer(32)
|
var h1 = new Buffer(32)
|
||||||
var k = ecdsa.deterministicGenerateK(h1, x, checkSig)
|
var k = ecdsa.deterministicGenerateK(h1, x, mockCheckSig)
|
||||||
|
|
||||||
assert.strictEqual(k.toString(), '53')
|
assert.strictEqual(k.toString(), '53')
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -298,7 +298,7 @@ describe('HDNode', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
// FIXME: test data is only testing Private -> private for now
|
// FIXME: test data is only testing Private -> private for now
|
||||||
f.children.forEach(function (c, i) {
|
f.children.forEach(function (c) {
|
||||||
if (c.m === undefined) return
|
if (c.m === undefined) return
|
||||||
|
|
||||||
it(c.path + ' from ' + f.master.fingerprint, function () {
|
it(c.path + ' from ' + f.master.fingerprint, function () {
|
||||||
|
|
|
@ -25,7 +25,7 @@ function fundAddress (unspents, outputs, callback) {
|
||||||
txb.addOutput(x.address || kpAddress, x.value)
|
txb.addOutput(x.address || kpAddress, x.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
result.inputs.forEach(function (x, i) {
|
result.inputs.forEach(function (_, i) {
|
||||||
txb.sign(i, keyPair)
|
txb.sign(i, keyPair)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ function fundAddress (unspents, outputs, callback) {
|
||||||
|
|
||||||
// FIXME: @blocktrail can be very slow, give it time
|
// FIXME: @blocktrail can be very slow, give it time
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
callback(null, outputs.map(function (x, i) {
|
callback(null, outputs.map(function (_, i) {
|
||||||
return { txId: txId, vout: i }
|
return { txId: txId, vout: i }
|
||||||
}))
|
}))
|
||||||
}, 3000)
|
}, 3000)
|
||||||
|
|
|
@ -62,8 +62,8 @@ describe('bitcoinjs-lib (multisig)', function () {
|
||||||
// check that the above transaction included the intended address
|
// check that the above transaction included the intended address
|
||||||
blockchain.t.addresses.unspents(blockchain.t.RETURN, function (err, unspents) {
|
blockchain.t.addresses.unspents(blockchain.t.RETURN, function (err, unspents) {
|
||||||
if (err) return callback(err)
|
if (err) return callback(err)
|
||||||
if (!unspents.some(function (unspent) {
|
if (!unspents.some(function (x) {
|
||||||
return unspent.txId === txId && unspent.value === 1e4
|
return x.txId === txId && x.value === 1e4
|
||||||
})) return callback(new Error('Could not find unspent after broadcast'))
|
})) return callback(new Error('Could not find unspent after broadcast'))
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
|
|
|
@ -101,9 +101,9 @@ describe('TransactionBuilder', function () {
|
||||||
var tx = new Transaction()
|
var tx = new Transaction()
|
||||||
|
|
||||||
f.inputs.forEach(function (input) {
|
f.inputs.forEach(function (input) {
|
||||||
var txHash = new Buffer(input.txId, 'hex').reverse()
|
var txHash2 = new Buffer(input.txId, 'hex').reverse()
|
||||||
|
|
||||||
tx.addInput(txHash, input.vout, undefined, bscript.fromASM(input.scriptSig))
|
tx.addInput(txHash2, input.vout, undefined, bscript.fromASM(input.scriptSig))
|
||||||
})
|
})
|
||||||
|
|
||||||
f.outputs.forEach(function (output) {
|
f.outputs.forEach(function (output) {
|
||||||
|
@ -281,7 +281,7 @@ describe('TransactionBuilder', function () {
|
||||||
f.inputs.forEach(function (input, index) {
|
f.inputs.forEach(function (input, index) {
|
||||||
input.signs.forEach(function (sign) {
|
input.signs.forEach(function (sign) {
|
||||||
var keyPairNetwork = NETWORKS[sign.network || f.network]
|
var keyPairNetwork = NETWORKS[sign.network || f.network]
|
||||||
var keyPair = ECPair.fromWIF(sign.keyPair, keyPairNetwork)
|
var keyPair2 = ECPair.fromWIF(sign.keyPair, keyPairNetwork)
|
||||||
var redeemScript
|
var redeemScript
|
||||||
|
|
||||||
if (sign.redeemScript) {
|
if (sign.redeemScript) {
|
||||||
|
@ -289,10 +289,10 @@ describe('TransactionBuilder', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sign.throws) {
|
if (!sign.throws) {
|
||||||
txb.sign(index, keyPair, redeemScript, sign.hashType, sign.value)
|
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value)
|
||||||
} else {
|
} else {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
txb.sign(index, keyPair, redeemScript, sign.hashType, sign.value)
|
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value)
|
||||||
}, new RegExp(f.exception))
|
}, new RegExp(f.exception))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -386,8 +386,8 @@ describe('TransactionBuilder', function () {
|
||||||
txb = TransactionBuilder.fromTransaction(tx, network)
|
txb = TransactionBuilder.fromTransaction(tx, network)
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyPair = ECPair.fromWIF(sign.keyPair, network)
|
var keyPair2 = ECPair.fromWIF(sign.keyPair, network)
|
||||||
txb.sign(i, keyPair, redeemScript, sign.hashType)
|
txb.sign(i, keyPair2, redeemScript, sign.hashType)
|
||||||
|
|
||||||
// update the tx
|
// update the tx
|
||||||
tx = txb.buildIncomplete()
|
tx = txb.buildIncomplete()
|
||||||
|
@ -417,8 +417,8 @@ describe('TransactionBuilder', function () {
|
||||||
// now import the Transaction
|
// now import the Transaction
|
||||||
var txb = TransactionBuilder.fromTransaction(tx, NETWORKS.testnet)
|
var txb = TransactionBuilder.fromTransaction(tx, NETWORKS.testnet)
|
||||||
|
|
||||||
var keyPair = ECPair.fromWIF('91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe', network)
|
var keyPair2 = ECPair.fromWIF('91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe', network)
|
||||||
txb.sign(0, keyPair, redeemScript)
|
txb.sign(0, keyPair2, redeemScript)
|
||||||
|
|
||||||
var tx2 = txb.build()
|
var tx2 = txb.build()
|
||||||
assert.equal(tx2.getId(), 'eab59618a564e361adef6d918bd792903c3d41bcf1220137364fb847880467f9')
|
assert.equal(tx2.getId(), 'eab59618a564e361adef6d918bd792903c3d41bcf1220137364fb847880467f9')
|
||||||
|
|
Loading…
Add table
Reference in a new issue