summaryrefslogtreecommitdiff
path: root/impls/monero.rs/tests
diff options
context:
space:
mode:
authorsneurlax <sneurlax@gmail.com>2024-10-20 20:17:22 -0500
committersneurlax <sneurlax@gmail.com>2024-10-20 20:17:22 -0500
commit755749eda4f86500026ce6b790a5eeefe143b34d (patch)
tree4be7e7bb123cd0ecb1a77824b71d7e67b8653d39 /impls/monero.rs/tests
parent8c25f0dccbb9867f5444dd16baf3db0687ffd062 (diff)
add restore_mnemonic
Diffstat (limited to 'impls/monero.rs/tests')
-rw-r--r--impls/monero.rs/tests/integration_tests.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/impls/monero.rs/tests/integration_tests.rs b/impls/monero.rs/tests/integration_tests.rs
index d791706..22bcfda 100644
--- a/impls/monero.rs/tests/integration_tests.rs
+++ b/impls/monero.rs/tests/integration_tests.rs
@@ -109,6 +109,49 @@ fn test_wallet_creation() {
teardown(&temp_dir).expect("Failed to clean up after test");
}
+
+#[test]
+fn test_restore_mnemonic_integration() {
+ let (manager, temp_dir) = setup().expect("Failed to set up test environment");
+
+ let wallet_path = temp_dir.path().join("test_wallet");
+ let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string").to_string();
+
+ // Example mnemonic seed (ensure this is a valid seed for your context).
+ let mnemonic_seed = "hemlock jubilee eden hacksaw boil superior inroads epoxy exhale orders cavernous second brunt saved richly lower upgrade hitched launching deepest mostly playful layout lower eden".to_string();
+
+ let restored_wallet = manager.restore_mnemonic(
+ wallet_str.clone(),
+ "password".to_string(),
+ mnemonic_seed,
+ NetworkType::Mainnet,
+ 0, // Restore from the beginning of the blockchain.
+ 1, // Default KDF rounds.
+ "".to_string(), // No seed offset.
+ );
+
+ assert!(restored_wallet.is_ok(), "Failed to restore wallet: {:?}", restored_wallet.err());
+
+ // Check that the wallet is deterministic.
+ let wallet = restored_wallet.unwrap();
+ assert!(wallet.is_deterministic().is_ok(), "Restored wallet seems to have failed");
+ assert!(wallet.is_deterministic().unwrap(), "Restored wallet should be deterministic");
+
+ // Optionally, verify the address if applicable.
+ let address_result = wallet.get_address(0, 0);
+ assert!(address_result.is_ok(), "Failed to retrieve address: {:?}", address_result.err());
+ let address = address_result.unwrap();
+ assert_eq!(
+ address,
+ "45wsWad9EwZgF3VpxQumrUCRaEtdyyh6NG8sVD3YRVVJbK1jkpJ3zq8WHLijVzodQ22LxwkdWx7fS2a6JzaRGzkNU8K2Dhi",
+ "Address does not match expected value"
+ );
+
+ // Clean up wallet files.
+ teardown(&temp_dir).expect("Failed to clean up after test");
+}
+// TODO: Test with offset.
+
#[test]
fn test_generate_from_keys_integration() {
println!("Running test_generate_from_keys_integration");