tests: enforce something threw for invalid cases
This commit is contained in:
parent
4616d24016
commit
43f52c452b
1 changed files with 7 additions and 3 deletions
|
@ -340,6 +340,7 @@ describe('TransactionBuilder', function () {
|
||||||
it('throws ' + f.exception + (f.description ? ' (' + f.description + ')' : ''), function () {
|
it('throws ' + f.exception + (f.description ? ' (' + f.description + ')' : ''), function () {
|
||||||
const txb = construct(f, true)
|
const txb = construct(f, true)
|
||||||
|
|
||||||
|
let threw = false
|
||||||
f.inputs.forEach(function (input, index) {
|
f.inputs.forEach(function (input, index) {
|
||||||
input.signs.forEach(function (sign) {
|
input.signs.forEach(function (sign) {
|
||||||
const keyPairNetwork = NETWORKS[sign.network || f.network]
|
const keyPairNetwork = NETWORKS[sign.network || f.network]
|
||||||
|
@ -355,15 +356,18 @@ describe('TransactionBuilder', function () {
|
||||||
witnessScript = bscript.fromASM(sign.witnessScript)
|
witnessScript = bscript.fromASM(sign.witnessScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sign.throws) {
|
if (sign.throws) {
|
||||||
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value, witnessScript)
|
|
||||||
} else {
|
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value, witnessScript)
|
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value, witnessScript)
|
||||||
}, new RegExp(f.exception))
|
}, new RegExp(f.exception))
|
||||||
|
threw = true
|
||||||
|
} else {
|
||||||
|
txb.sign(index, keyPair2, redeemScript, sign.hashType, sign.value, witnessScript)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
assert.equal(threw, true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue