Skip to content

Commit c229e63

Browse files
OttoAllmendingerllm-git
andcommitted
feat(utxo-lib): add includeP2trMusig2ScriptPath option to AcidTest
Adds configuration option to exclude p2trMusig2 script path inputs from ACID test suites, as they often require special handling. Issue: BTC-2806 Co-authored-by: llm-git <[email protected]>
1 parent e9d2c33 commit c229e63

File tree

1 file changed

+15
-3
lines changed
  • modules/utxo-lib/src/testutil

1 file changed

+15
-3
lines changed

modules/utxo-lib/src/testutil/psbt.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ export function constructPsbt(
258258
export const txFormats = ['psbt', 'psbt-lite'] as const;
259259
export type TxFormat = (typeof txFormats)[number];
260260

261+
type SuiteConfig = {
262+
/**
263+
* By default, we include p2trMusig2 script path in the inputs.
264+
* This input is a bit of a weirdo because it is signed by the user and the
265+
* backup key, which usually is not mixed with other inputs and outputs.
266+
*
267+
* This option allows to exclude this input from the inputs.
268+
*/
269+
includeP2trMusig2ScriptPath?: boolean;
270+
};
271+
261272
/**
262273
* Creates a valid PSBT with as many features as possible.
263274
*
@@ -297,7 +308,7 @@ export class AcidTest {
297308
this.outputs = outputs;
298309
}
299310

300-
static withDefaults(network: Network, signStage: SignStage, txFormat: TxFormat): AcidTest {
311+
static withConfig(network: Network, signStage: SignStage, txFormat: TxFormat, suiteConfig: SuiteConfig): AcidTest {
301312
const rootWalletKeys = getDefaultWalletKeys();
302313

303314
const otherWalletKeys = getWalletKeysForSeed('too many secrets');
@@ -307,6 +318,7 @@ export class AcidTest {
307318
? isSupportedScriptType(network, 'p2trMusig2')
308319
: isSupportedScriptType(network, scriptType)
309320
)
321+
.filter((scriptType) => (suiteConfig.includeP2trMusig2ScriptPath ?? true) || scriptType !== 'p2trMusig2')
310322
.map((scriptType) => ({ scriptType, value: BigInt(2000) }));
311323

312324
const outputs: Output[] = outputScriptTypes
@@ -345,12 +357,12 @@ export class AcidTest {
345357
return psbt;
346358
}
347359

348-
static suite(): AcidTest[] {
360+
static suite(suiteConfig: SuiteConfig = {}): AcidTest[] {
349361
return getNetworkList()
350362
.filter((network) => isMainnet(network) && network !== networks.bitcoinsv)
351363
.flatMap((network) =>
352364
signStages.flatMap((signStage) =>
353-
txFormats.flatMap((txFormat) => AcidTest.withDefaults(network, signStage, txFormat))
365+
txFormats.flatMap((txFormat) => AcidTest.withConfig(network, signStage, txFormat, suiteConfig))
354366
)
355367
);
356368
}

0 commit comments

Comments
 (0)