41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const { describe, it } = require('mocha')
|
|
const assert = require('assert')
|
|
|
|
const ECPair = require('../src/ecpair')
|
|
const Psbt = require('..').Psbt
|
|
|
|
const fixtures = require('./fixtures/psbt')
|
|
|
|
describe(`Psbt`, () => {
|
|
describe('BIP174 Test Vectors', () => {
|
|
fixtures.bip174.invalid.forEach((f, i) => {
|
|
it(`Invalid #${i + 1}: "${f.errorMessage}"`, () => {
|
|
assert.throws(() => {
|
|
Psbt.fromBase64(f.psbt)
|
|
}, {message: f.errorMessage})
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('signInput', () => {
|
|
fixtures.signInput.checks.forEach(f => {
|
|
it(f.description, () => {
|
|
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt)
|
|
assert.doesNotThrow(() => {
|
|
psbtThatShouldsign.signInput(
|
|
f.shouldSign.inputToCheck,
|
|
ECPair.fromWIF(f.shouldSign.WIF),
|
|
)
|
|
})
|
|
|
|
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt)
|
|
assert.throws(() => {
|
|
psbtThatShouldThrow.signInput(
|
|
f.shouldThrow.inputToCheck,
|
|
ECPair.fromWIF(f.shouldThrow.WIF),
|
|
)
|
|
}, {message: f.shouldThrow.errorMessage})
|
|
})
|
|
})
|
|
})
|
|
})
|