Skip to content

Commit 7d976ac

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): improve script names, suite names
Update ScriptType enum variants to have more consistent and descriptive naming that better reflects their purpose: - P2tr -> P2trLegacyScriptPath - P2trMusig2 -> P2trMusig2ScriptPath - TaprootKeypath -> P2trMusig2TaprootKeypath Rename test functions to use more concise and consistent naming pattern. Functions now use "suite" suffix instead of verbose "generation_from_fixture" descriptions. Issue: BTC-2652 Co-authored-by: llm-git <[email protected]>
1 parent b12c726 commit 7d976ac

File tree

3 files changed

+48
-40
lines changed

3 files changed

+48
-40
lines changed

packages/wasm-utxo/src/bitgo_psbt/mod.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,9 @@ mod tests {
614614

615615
let psbt_input_stages = psbt_input_stages.unwrap();
616616

617-
if script_type != fixtures::ScriptType::TaprootKeypath
618-
&& script_type != fixtures::ScriptType::P2trMusig2
619-
&& script_type != fixtures::ScriptType::P2tr
617+
if script_type != fixtures::ScriptType::P2trMusig2TaprootKeypath
618+
&& script_type != fixtures::ScriptType::P2trMusig2ScriptPath
619+
&& script_type != fixtures::ScriptType::P2trLegacyScriptPath
620620
{
621621
assert_half_sign(
622622
&psbt_stages
@@ -651,7 +651,7 @@ mod tests {
651651
Ok(())
652652
}
653653

654-
crate::test_psbt_fixtures!(test_p2sh_script_generation_from_fixture, network, format, {
654+
crate::test_psbt_fixtures!(test_p2sh_suite, network, format, {
655655
test_wallet_script_type(fixtures::ScriptType::P2sh, network, format).unwrap();
656656
}, ignore: [
657657
// TODO: sighash support
@@ -661,7 +661,7 @@ mod tests {
661661
]);
662662

663663
crate::test_psbt_fixtures!(
664-
test_p2sh_p2wsh_script_generation_from_fixture,
664+
test_p2sh_p2wsh_suite,
665665
network,
666666
format,
667667
{
@@ -672,7 +672,7 @@ mod tests {
672672
);
673673

674674
crate::test_psbt_fixtures!(
675-
test_p2wsh_script_generation_from_fixture,
675+
test_p2wsh_suite,
676676
network,
677677
format,
678678
{
@@ -682,27 +682,24 @@ mod tests {
682682
ignore: [BitcoinGold]
683683
);
684684

685-
crate::test_psbt_fixtures!(test_p2tr_script_generation_from_fixture, network, format, {
686-
test_wallet_script_type(fixtures::ScriptType::P2tr, network, format).unwrap();
685+
crate::test_psbt_fixtures!(test_p2tr_legacy_script_path_suite, network, format, {
686+
test_wallet_script_type(fixtures::ScriptType::P2trLegacyScriptPath, network, format)
687+
.unwrap();
687688
});
688689

689-
crate::test_psbt_fixtures!(
690-
test_p2tr_musig2_script_path_generation_from_fixture,
691-
network,
692-
format,
693-
{
694-
test_wallet_script_type(fixtures::ScriptType::P2trMusig2, network, format).unwrap();
695-
}
696-
);
690+
crate::test_psbt_fixtures!(test_p2tr_musig2_script_path_suite, network, format, {
691+
test_wallet_script_type(fixtures::ScriptType::P2trMusig2ScriptPath, network, format)
692+
.unwrap();
693+
});
697694

698-
crate::test_psbt_fixtures!(
699-
test_p2tr_musig2_key_path_spend_script_generation_from_fixture,
700-
network,
701-
format,
702-
{
703-
test_wallet_script_type(fixtures::ScriptType::TaprootKeypath, network, format).unwrap();
704-
}
705-
);
695+
crate::test_psbt_fixtures!(test_p2tr_musig2_key_path_suite, network, format, {
696+
test_wallet_script_type(
697+
fixtures::ScriptType::P2trMusig2TaprootKeypath,
698+
network,
699+
format,
700+
)
701+
.unwrap();
702+
});
706703

707704
crate::test_psbt_fixtures!(test_extract_transaction, network, format, {
708705
let fixture = fixtures::load_psbt_fixture_with_format(

packages/wasm-utxo/src/bitgo_psbt/p2tr_musig2_input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,12 @@ mod tests {
689689
.expect("Failed to load fixture");
690690

691691
let (input_index, input_fixture) = fixture
692-
.find_input_with_script_type(ScriptType::TaprootKeypath)
692+
.find_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
693693
.expect("Failed to find taprootKeyPathSpend input");
694694

695695
let finalized_input_fixture = if signature_state == SignatureState::Fullsigned {
696696
let (finalized_input_index, finalized_input_fixture) = fixture
697-
.find_finalized_input_with_script_type(ScriptType::TaprootKeypath)
697+
.find_finalized_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
698698
.expect("Failed to find taprootKeyPathSpend finalized input");
699699
assert_eq!(input_index, finalized_input_index);
700700
Some(finalized_input_fixture)

packages/wasm-utxo/src/fixed_script_wallet/test_utils/fixtures.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,12 @@ pub enum ScriptType {
11431143
P2sh,
11441144
P2shP2wsh,
11451145
P2wsh,
1146-
P2tr,
1147-
P2trMusig2,
1148-
TaprootKeypath,
1146+
// Chain 30 and 31 - we only support script path spending for these
1147+
P2trLegacyScriptPath,
1148+
// Chain 40 and 41 - script path spend
1149+
P2trMusig2ScriptPath,
1150+
// Chain 40 and 41 - keypath spend
1151+
P2trMusig2TaprootKeypath,
11491152
}
11501153

11511154
impl ScriptType {
@@ -1155,9 +1158,9 @@ impl ScriptType {
11551158
ScriptType::P2sh => "p2sh",
11561159
ScriptType::P2shP2wsh => "p2shP2wsh",
11571160
ScriptType::P2wsh => "p2wsh",
1158-
ScriptType::P2tr => "p2tr",
1159-
ScriptType::P2trMusig2 => "p2trMusig2",
1160-
ScriptType::TaprootKeypath => "taprootKeypath",
1161+
ScriptType::P2trLegacyScriptPath => "p2tr",
1162+
ScriptType::P2trMusig2ScriptPath => "p2trMusig2",
1163+
ScriptType::P2trMusig2TaprootKeypath => "taprootKeypath",
11611164
}
11621165
}
11631166

@@ -1168,13 +1171,16 @@ impl ScriptType {
11681171
(ScriptType::P2sh, PsbtInputFixture::P2sh(_))
11691172
| (ScriptType::P2shP2wsh, PsbtInputFixture::P2shP2wsh(_))
11701173
| (ScriptType::P2wsh, PsbtInputFixture::P2wsh(_))
1171-
| (ScriptType::P2tr, PsbtInputFixture::P2trLegacy(_))
11721174
| (
1173-
ScriptType::P2trMusig2,
1175+
ScriptType::P2trLegacyScriptPath,
1176+
PsbtInputFixture::P2trLegacy(_)
1177+
)
1178+
| (
1179+
ScriptType::P2trMusig2ScriptPath,
11741180
PsbtInputFixture::P2trMusig2ScriptPath(_)
11751181
)
11761182
| (
1177-
ScriptType::TaprootKeypath,
1183+
ScriptType::P2trMusig2TaprootKeypath,
11781184
PsbtInputFixture::P2trMusig2KeyPath(_)
11791185
)
11801186
)
@@ -1187,13 +1193,16 @@ impl ScriptType {
11871193
(ScriptType::P2sh, PsbtFinalInputFixture::P2sh(_))
11881194
| (ScriptType::P2shP2wsh, PsbtFinalInputFixture::P2shP2wsh(_))
11891195
| (ScriptType::P2wsh, PsbtFinalInputFixture::P2wsh(_))
1190-
| (ScriptType::P2tr, PsbtFinalInputFixture::P2trLegacy(_))
11911196
| (
1192-
ScriptType::P2trMusig2,
1197+
ScriptType::P2trLegacyScriptPath,
1198+
PsbtFinalInputFixture::P2trLegacy(_)
1199+
)
1200+
| (
1201+
ScriptType::P2trMusig2ScriptPath,
11931202
PsbtFinalInputFixture::P2trMusig2ScriptPath(_)
11941203
)
11951204
| (
1196-
ScriptType::TaprootKeypath,
1205+
ScriptType::P2trMusig2TaprootKeypath,
11971206
PsbtFinalInputFixture::P2trMusig2KeyPath(_)
11981207
)
11991208
)
@@ -1206,7 +1215,9 @@ impl ScriptType {
12061215
pub fn is_taproot(&self) -> bool {
12071216
matches!(
12081217
self,
1209-
ScriptType::P2tr | ScriptType::P2trMusig2 | ScriptType::TaprootKeypath
1218+
ScriptType::P2trLegacyScriptPath
1219+
| ScriptType::P2trMusig2ScriptPath
1220+
| ScriptType::P2trMusig2TaprootKeypath
12101221
)
12111222
}
12121223

@@ -1520,7 +1531,7 @@ mod tests {
15201531

15211532
// Test finding taproot key path finalized input
15221533
let (index, input) = fixture
1523-
.find_finalized_input_with_script_type(ScriptType::TaprootKeypath)
1534+
.find_finalized_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
15241535
.expect("Failed to find taproot key path finalized input");
15251536
assert_eq!(index, 5);
15261537
assert!(matches!(input, PsbtFinalInputFixture::P2trMusig2KeyPath(_)));

0 commit comments

Comments
 (0)