Skip to content

Commit bf85c2c

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 c2aa81d commit bf85c2c

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
@@ -616,9 +616,9 @@ mod tests {
616616

617617
let psbt_input_stages = psbt_input_stages.unwrap();
618618

619-
if script_type != fixtures::ScriptType::TaprootKeypath
620-
&& script_type != fixtures::ScriptType::P2trMusig2
621-
&& script_type != fixtures::ScriptType::P2tr
619+
if script_type != fixtures::ScriptType::P2trMusig2TaprootKeypath
620+
&& script_type != fixtures::ScriptType::P2trMusig2ScriptPath
621+
&& script_type != fixtures::ScriptType::P2trLegacyScriptPath
622622
{
623623
assert_half_sign(
624624
network,
@@ -655,7 +655,7 @@ mod tests {
655655
Ok(())
656656
}
657657

658-
crate::test_psbt_fixtures!(test_p2sh_script_generation_from_fixture, network, format, {
658+
crate::test_psbt_fixtures!(test_p2sh_suite, network, format, {
659659
test_wallet_script_type(fixtures::ScriptType::P2sh, network, format).unwrap();
660660
}, ignore: [
661661
// TODO: sighash support
@@ -665,7 +665,7 @@ mod tests {
665665
]);
666666

667667
crate::test_psbt_fixtures!(
668-
test_p2sh_p2wsh_script_generation_from_fixture,
668+
test_p2sh_p2wsh_suite,
669669
network,
670670
format,
671671
{
@@ -676,7 +676,7 @@ mod tests {
676676
);
677677

678678
crate::test_psbt_fixtures!(
679-
test_p2wsh_script_generation_from_fixture,
679+
test_p2wsh_suite,
680680
network,
681681
format,
682682
{
@@ -686,27 +686,24 @@ mod tests {
686686
ignore: [BitcoinGold]
687687
);
688688

689-
crate::test_psbt_fixtures!(test_p2tr_script_generation_from_fixture, network, format, {
690-
test_wallet_script_type(fixtures::ScriptType::P2tr, network, format).unwrap();
689+
crate::test_psbt_fixtures!(test_p2tr_legacy_script_path_suite, network, format, {
690+
test_wallet_script_type(fixtures::ScriptType::P2trLegacyScriptPath, network, format)
691+
.unwrap();
691692
});
692693

693-
crate::test_psbt_fixtures!(
694-
test_p2tr_musig2_script_path_generation_from_fixture,
695-
network,
696-
format,
697-
{
698-
test_wallet_script_type(fixtures::ScriptType::P2trMusig2, network, format).unwrap();
699-
}
700-
);
694+
crate::test_psbt_fixtures!(test_p2tr_musig2_script_path_suite, network, format, {
695+
test_wallet_script_type(fixtures::ScriptType::P2trMusig2ScriptPath, network, format)
696+
.unwrap();
697+
});
701698

702-
crate::test_psbt_fixtures!(
703-
test_p2tr_musig2_key_path_spend_script_generation_from_fixture,
704-
network,
705-
format,
706-
{
707-
test_wallet_script_type(fixtures::ScriptType::TaprootKeypath, network, format).unwrap();
708-
}
709-
);
699+
crate::test_psbt_fixtures!(test_p2tr_musig2_key_path_suite, network, format, {
700+
test_wallet_script_type(
701+
fixtures::ScriptType::P2trMusig2TaprootKeypath,
702+
network,
703+
format,
704+
)
705+
.unwrap();
706+
});
710707

711708
crate::test_psbt_fixtures!(test_extract_transaction, network, format, {
712709
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)