tests: flatten construct function
This commit is contained in:
parent
9dcf4d4b8b
commit
f07ccabe6e
@ -34,7 +34,8 @@ function construct (f, sign) {
|
|||||||
txb.addOutput(bscript.fromASM(output.script), output.value)
|
txb.addOutput(bscript.fromASM(output.script), output.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (sign === undefined || sign) {
|
if (sign === false) return txb
|
||||||
|
|
||||||
f.inputs.forEach(function (input, index) {
|
f.inputs.forEach(function (input, index) {
|
||||||
input.signs.forEach(function (sign) {
|
input.signs.forEach(function (sign) {
|
||||||
var keyPair = ECPair.fromWIF(sign.keyPair, network)
|
var keyPair = ECPair.fromWIF(sign.keyPair, network)
|
||||||
@ -47,7 +48,6 @@ function construct (f, sign) {
|
|||||||
txb.sign(index, keyPair, redeemScript, sign.hashType)
|
txb.sign(index, keyPair, redeemScript, sign.hashType)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
return txb
|
return txb
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ describe('TransactionBuilder', function () {
|
|||||||
|
|
||||||
describe('fromTransaction', function () {
|
describe('fromTransaction', function () {
|
||||||
fixtures.valid.build.forEach(function (f) {
|
fixtures.valid.build.forEach(function (f) {
|
||||||
it('builds TransactionBuilder, with ' + f.description, function () {
|
it('returns TransactionBuilder, with ' + f.description, function () {
|
||||||
var network = NETWORKS[f.network || 'bitcoin']
|
var network = NETWORKS[f.network || 'bitcoin']
|
||||||
var tx = Transaction.fromHex(f.txHex)
|
var tx = Transaction.fromHex(f.txHex)
|
||||||
var txb = TransactionBuilder.fromTransaction(tx, network)
|
var txb = TransactionBuilder.fromTransaction(tx, network)
|
||||||
@ -76,7 +76,7 @@ describe('TransactionBuilder', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
fixtures.valid.fromTransaction.forEach(function (f) {
|
fixtures.valid.fromTransaction.forEach(function (f) {
|
||||||
it('builds TransactionBuilder, with ' + f.description, function () {
|
it('returns TransactionBuilder, with ' + f.description, function () {
|
||||||
var tx = new Transaction()
|
var tx = new Transaction()
|
||||||
|
|
||||||
f.inputs.forEach(function (input) {
|
f.inputs.forEach(function (input) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user