tests: when importing, allow no witness importing for plain hex comparison
This commit is contained in:
parent
72fbd00762
commit
66ad980122
1 changed files with 8 additions and 4 deletions
|
@ -6,7 +6,7 @@ var fixtures = require('./fixtures/transaction')
|
|||
var Transaction = require('../src/transaction')
|
||||
|
||||
describe('Transaction', function () {
|
||||
function fromRaw (raw) {
|
||||
function fromRaw (raw, noWitness) {
|
||||
var tx = new Transaction()
|
||||
tx.version = raw.version
|
||||
tx.locktime = raw.locktime
|
||||
|
@ -23,7 +23,7 @@ describe('Transaction', function () {
|
|||
|
||||
tx.addInput(txHash, txIn.index, txIn.sequence, scriptSig)
|
||||
|
||||
if (txIn.witness) {
|
||||
if (!noWitness && txIn.witness) {
|
||||
var witness = txIn.witness.map(function (x) {
|
||||
return new Buffer(x, 'hex')
|
||||
})
|
||||
|
@ -90,9 +90,13 @@ describe('Transaction', function () {
|
|||
describe('toBuffer/toHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('exports ' + f.description + ' (' + f.id + ')', function () {
|
||||
var actual = fromRaw(f.raw)
|
||||
if (f.whex) {
|
||||
var wactual = fromRaw(f.raw)
|
||||
assert.strictEqual(wactual.toHex(), f.whex)
|
||||
}
|
||||
|
||||
assert.strictEqual(actual.toHex(), f.whex || f.hex, actual.toHex())
|
||||
var actual = fromRaw(f.raw, true)
|
||||
assert.strictEqual(actual.toHex(), f.hex)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue