Skip to content

Commit fb8f402

Browse files
OttoAllmendingerllm-git
andcommitted
feat(utxo-lib): add round-trip PSBT buffer test
Add a test to ensure PSBTs can be serialized to buffer and back without any loss of information. Issue: BTC-2732 Co-authored-by: llm-git <[email protected]>
1 parent 2c3a6c9 commit fb8f402

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/utxo-lib/test/bitgo/psbt/SignVerifyPsbtAndTx.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as assert from 'assert';
33
import {
44
addXpubsToPsbt,
55
clonePsbtWithoutNonWitnessUtxo,
6+
createPsbtFromBuffer,
67
getPsbtInputSignatureCount,
78
getSignatureValidationArrayPsbt,
89
getStrictSignatureCount,
@@ -136,9 +137,16 @@ function runPsbt(
136137
describe(`psbt build, sign and verify for ${coin} ${inputTypes.join('-')} ${sign}`, function () {
137138
let psbt: UtxoPsbt;
138139

139-
it(`getSignatureValidationArray with globalXpub ${coin} ${sign}`, function () {
140+
before(function () {
140141
psbt = constructPsbt(inputs, outputs, network, rootWalletKeys, sign, { deterministic: true });
141142
addXpubsToPsbt(psbt, rootWalletKeysXpubs);
143+
});
144+
145+
it('round-trip test', function () {
146+
assert.deepStrictEqual(psbt.toBuffer(), createPsbtFromBuffer(psbt.toBuffer(), network).toBuffer());
147+
});
148+
149+
it(`getSignatureValidationArray with globalXpub ${coin} ${sign}`, function () {
142150
psbt.data.inputs.forEach((input, inputIndex) => {
143151
const isP2shP2pk = inputs[inputIndex].scriptType === 'p2shP2pk';
144152
const expectedSigValid = getSigValidArray(inputs[inputIndex].scriptType, sign);

0 commit comments

Comments
 (0)