Skip to content

Commit 9aae5ff

Browse files
OttoAllmendingerllm-git
andcommitted
refactor(wasm-utxo): remove unused wallet_keys_helpers module
Remove WASM-specific test code and the helper module that is no longer needed after implementing wallet keys functionality in Rust rather than JavaScript/TypeScript. Issue: BTC-2786 Co-authored-by: llm-git <[email protected]>
1 parent 483cccb commit 9aae5ff

File tree

3 files changed

+0
-267
lines changed

3 files changed

+0
-267
lines changed

packages/wasm-utxo/src/fixed_script_wallet/wallet_keys.rs

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -142,129 +142,3 @@ pub mod tests {
142142
assert!(keys.derive_for_chain_and_index(0, 0).is_ok());
143143
}
144144
}
145-
146-
#[cfg(test)]
147-
#[cfg(target_arch = "wasm32")]
148-
pub mod wasm_tests {
149-
use super::tests::get_test_wallet_xprvs;
150-
use crate::bitcoin::bip32::Xpub;
151-
use crate::wasm::wallet_keys_helpers::root_wallet_keys_from_jsvalue;
152-
use wasm_bindgen::JsValue;
153-
use wasm_bindgen_test::*;
154-
155-
wasm_bindgen_test_configure!(run_in_browser);
156-
157-
#[wasm_bindgen_test]
158-
fn test_from_jsvalue_valid_keys_wasm() {
159-
// Get test xpubs as strings
160-
let xpubs = get_test_wallet_xprvs("test");
161-
let secp = crate::bitcoin::key::Secp256k1::new();
162-
let xpub_strings: Vec<String> = xpubs
163-
.iter()
164-
.map(|xprv| Xpub::from_priv(&secp, xprv).to_string())
165-
.collect();
166-
167-
// Create a JS array with the xpub strings
168-
let js_array = js_sys::Array::new();
169-
for xpub_str in xpub_strings.iter() {
170-
js_array.push(&JsValue::from_str(xpub_str));
171-
}
172-
173-
// Test from_jsvalue with actual JsValue
174-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
175-
assert!(result.is_ok());
176-
177-
let wallet_keys = result.unwrap();
178-
// Verify we can derive keys
179-
assert!(wallet_keys.derive_for_chain_and_index(0, 0).is_ok());
180-
assert!(wallet_keys.derive_for_chain_and_index(1, 5).is_ok());
181-
}
182-
183-
#[wasm_bindgen_test]
184-
fn test_from_jsvalue_invalid_count_wasm() {
185-
// Create a JS array with only 2 xpubs (should fail)
186-
let xpubs = get_test_wallet_xprvs("test");
187-
let secp = crate::bitcoin::key::Secp256k1::new();
188-
189-
let js_array = js_sys::Array::new();
190-
for i in 0..2 {
191-
let xpub_str = Xpub::from_priv(&secp, &xpubs[i]).to_string();
192-
js_array.push(&JsValue::from_str(&xpub_str));
193-
}
194-
195-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
196-
assert!(result.is_err());
197-
assert_eq!(
198-
result.unwrap_err().to_string(),
199-
"Expected exactly 3 xpub keys"
200-
);
201-
}
202-
203-
#[wasm_bindgen_test]
204-
fn test_from_jsvalue_too_many_keys_wasm() {
205-
// Create a JS array with 4 xpubs (should fail)
206-
let xpubs = get_test_wallet_xprvs("test");
207-
let secp = crate::bitcoin::key::Secp256k1::new();
208-
209-
let js_array = js_sys::Array::new();
210-
for i in 0..3 {
211-
let xpub_str = Xpub::from_priv(&secp, &xpubs[i]).to_string();
212-
js_array.push(&JsValue::from_str(&xpub_str));
213-
}
214-
// Add one more
215-
js_array.push(&JsValue::from_str(
216-
&Xpub::from_priv(&secp, &xpubs[0]).to_string(),
217-
));
218-
219-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
220-
assert!(result.is_err());
221-
assert_eq!(
222-
result.unwrap_err().to_string(),
223-
"Expected exactly 3 xpub keys"
224-
);
225-
}
226-
227-
#[wasm_bindgen_test]
228-
fn test_from_jsvalue_invalid_xpub_wasm() {
229-
// Create a JS array with 3 values, all of which are not valid xpubs
230-
let js_array = js_sys::Array::new();
231-
js_array.push(&JsValue::from_str("not-a-valid-xpub"));
232-
js_array.push(&JsValue::from_str("also-not-valid"));
233-
js_array.push(&JsValue::from_str("still-not-valid"));
234-
235-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
236-
assert!(result.is_err());
237-
assert!(result
238-
.unwrap_err()
239-
.to_string()
240-
.contains("Failed to parse xpub"));
241-
}
242-
243-
#[wasm_bindgen_test]
244-
fn test_from_jsvalue_non_string_element_wasm() {
245-
// Create a JS array with a non-string element
246-
let js_array = js_sys::Array::new();
247-
js_array.push(&JsValue::from_f64(123.0)); // number instead of string
248-
js_array.push(&JsValue::from_str("xpub2"));
249-
js_array.push(&JsValue::from_str("xpub3"));
250-
251-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
252-
assert!(result.is_err());
253-
assert!(result
254-
.unwrap_err()
255-
.to_string()
256-
.contains("Key at index 0 is not a string"));
257-
}
258-
259-
#[wasm_bindgen_test]
260-
fn test_from_jsvalue_mixed_invalid_wasm() {
261-
// Create a JS array with mixed invalid values
262-
let js_array = js_sys::Array::new();
263-
js_array.push(&JsValue::NULL);
264-
js_array.push(&JsValue::UNDEFINED);
265-
js_array.push(&JsValue::from_bool(true));
266-
267-
let result = root_wallet_keys_from_jsvalue(&js_array.into());
268-
assert!(result.is_err());
269-
}
270-
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod try_from_js_value;
1010
mod try_into_js_value;
1111
mod utxolib_compat;
1212
mod wallet_keys;
13-
pub(crate) mod wallet_keys_helpers;
1413

1514
pub use address::AddressNamespace;
1615
pub use bip32::WasmBIP32;

packages/wasm-utxo/src/wasm/wallet_keys_helpers.rs

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)