2019-06-28 12:17:18 +02:00
|
|
|
const { describe, it } = require('mocha')
|
2019-06-26 13:20:49 +02:00
|
|
|
const assert = require('assert')
|
|
|
|
|
|
|
|
const ECPair = require('../src/ecpair')
|
|
|
|
const Psbt = require('..').Psbt
|
|
|
|
|
2019-06-28 11:55:00 +02:00
|
|
|
const fixtures = require('./fixtures/psbt')
|
2019-06-26 13:20:49 +02:00
|
|
|
|
|
|
|
describe(`Psbt`, () => {
|
|
|
|
describe('signInput', () => {
|
2019-06-28 11:55:00 +02:00
|
|
|
fixtures.signInput.checks.forEach(f => {
|
|
|
|
it(f.description, () => {
|
|
|
|
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt)
|
|
|
|
assert.doesNotThrow(() => {
|
2019-07-02 13:15:30 +02:00
|
|
|
psbtThatShouldsign.signInput(
|
|
|
|
f.shouldSign.inputToCheck,
|
|
|
|
ECPair.fromWIF(f.shouldSign.WIF),
|
|
|
|
)
|
2019-06-28 11:55:00 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt)
|
|
|
|
assert.throws(() => {
|
2019-07-02 13:15:30 +02:00
|
|
|
psbtThatShouldThrow.signInput(
|
|
|
|
f.shouldThrow.inputToCheck,
|
|
|
|
ECPair.fromWIF(f.shouldThrow.WIF),
|
|
|
|
)
|
2019-06-28 11:55:00 +02:00
|
|
|
}, {message: f.shouldThrow.errorMessage})
|
2019-06-27 13:20:19 +02:00
|
|
|
})
|
|
|
|
})
|
2019-06-26 13:20:49 +02:00
|
|
|
})
|
|
|
|
})
|