Skip to content

Commit e83ece1

Browse files
OttoAllmendingerllm-git
andcommitted
feat(utxo-core): extract TestParams type for cleaner PSBT tests
Extract a type definition for createPsbt test parameters to improve code organization and readability. Update function parameters to use the new type and refactor the function calls accordingly. Issue: BTC-1966 Co-authored-by: llm-git <[email protected]>
1 parent 0ea3211 commit e83ece1

File tree

1 file changed

+11
-16
lines changed
  • modules/utxo-core/test/descriptor/psbt

1 file changed

+11
-16
lines changed

modules/utxo-core/test/descriptor/psbt/psbt.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,24 @@ function getStages(
112112
);
113113
}
114114

115-
function describeCreatePsbt(
116-
name: string,
117-
{
118-
descriptorSelf,
119-
psbtParams,
120-
stages,
121-
}: {
122-
descriptorSelf: Descriptor;
123-
stages: PsbtStage[];
124-
psbtParams: Partial<PsbtParams>;
125-
}
126-
) {
115+
type TestParams = {
116+
descriptorSelf: Descriptor;
117+
psbtParams: Partial<PsbtParams>;
118+
stages: PsbtStage[];
119+
};
120+
121+
function describeCreatePsbt(name: string, testParams: TestParams) {
127122
describe(`createPsbt ${name}`, function () {
128123
it('creates psbt with expected properties', async function () {
129124
const psbtUnsigned = mockPsbtDefault({
130-
descriptorSelf,
125+
descriptorSelf: testParams.descriptorSelf,
131126
descriptorOther: getDescriptor('Wsh2Of3', otherKeys),
132-
params: psbtParams,
127+
params: testParams.psbtParams,
133128
});
134-
const descriptorMap = new Map([['self', descriptorSelf]]);
129+
const descriptorMap = new Map([['self', testParams.descriptorSelf]]);
135130
const parsed = parse(psbtUnsigned, descriptorMap, utxolib.networks.bitcoin);
136131
assert.strictEqual(parsed.spendAmount, psbtUnsigned.txOutputs[1].value);
137-
await assertEqualsFixture(name, 'psbtStages.json', getStages(psbtUnsigned, parsed, stages));
132+
await assertEqualsFixture(name, 'psbtStages.json', getStages(psbtUnsigned, parsed, testParams.stages));
138133
});
139134
});
140135
}

0 commit comments

Comments
 (0)