tests: supply TransactionBuilder with network from fixtures
This commit is contained in:
parent
d3579289bd
commit
9513b26e8c
1 changed files with 8 additions and 5 deletions
|
@ -14,8 +14,9 @@ var NETWORKS = require('../src/networks')
|
||||||
|
|
||||||
var fixtures = require('./fixtures/transaction_builder')
|
var fixtures = require('./fixtures/transaction_builder')
|
||||||
|
|
||||||
function construct (txb, f, sign) {
|
function construct (f, sign) {
|
||||||
var network = NETWORKS[f.network]
|
var network = NETWORKS[f.network]
|
||||||
|
var txb = new TransactionBuilder(network)
|
||||||
|
|
||||||
f.inputs.forEach(function (input) {
|
f.inputs.forEach(function (input) {
|
||||||
var prevTxScript
|
var prevTxScript
|
||||||
|
@ -56,6 +57,8 @@ function construct (txb, f, sign) {
|
||||||
if (f.locktime !== undefined) {
|
if (f.locktime !== undefined) {
|
||||||
txb.tx.locktime = f.locktime
|
txb.tx.locktime = f.locktime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return txb
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('TransactionBuilder', function () {
|
describe('TransactionBuilder', function () {
|
||||||
|
@ -165,7 +168,7 @@ describe('TransactionBuilder', function () {
|
||||||
describe('sign', function () {
|
describe('sign', function () {
|
||||||
fixtures.invalid.sign.forEach(function (f) {
|
fixtures.invalid.sign.forEach(function (f) {
|
||||||
it('throws on ' + f.exception + (f.description ? ' (' + f.description + ')' : ''), function () {
|
it('throws on ' + f.exception + (f.description ? ' (' + f.description + ')' : ''), function () {
|
||||||
construct(txb, f, false)
|
txb = construct(f, false)
|
||||||
|
|
||||||
f.inputs.forEach(function (input, index) {
|
f.inputs.forEach(function (input, index) {
|
||||||
input.signs.forEach(function (sign) {
|
input.signs.forEach(function (sign) {
|
||||||
|
@ -193,7 +196,7 @@ describe('TransactionBuilder', function () {
|
||||||
describe('build', function () {
|
describe('build', function () {
|
||||||
fixtures.valid.build.forEach(function (f) {
|
fixtures.valid.build.forEach(function (f) {
|
||||||
it('builds "' + f.description + '"', function () {
|
it('builds "' + f.description + '"', function () {
|
||||||
construct(txb, f)
|
txb = construct(f)
|
||||||
|
|
||||||
var tx = txb.build()
|
var tx = txb.build()
|
||||||
assert.strictEqual(tx.toHex(), f.txHex)
|
assert.strictEqual(tx.toHex(), f.txHex)
|
||||||
|
@ -207,7 +210,7 @@ describe('TransactionBuilder', function () {
|
||||||
var tx = Transaction.fromHex(f.txHex)
|
var tx = Transaction.fromHex(f.txHex)
|
||||||
txb = TransactionBuilder.fromTransaction(tx)
|
txb = TransactionBuilder.fromTransaction(tx)
|
||||||
} else {
|
} else {
|
||||||
construct(txb, f)
|
txb = construct(f)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -228,7 +231,7 @@ describe('TransactionBuilder', function () {
|
||||||
describe('multisig', function () {
|
describe('multisig', function () {
|
||||||
fixtures.valid.multisig.forEach(function (f) {
|
fixtures.valid.multisig.forEach(function (f) {
|
||||||
it(f.description, function () {
|
it(f.description, function () {
|
||||||
construct(txb, f, false)
|
txb = construct(f, false)
|
||||||
|
|
||||||
var tx
|
var tx
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue