diff options
| author | sneurlax <sneurlax@gmail.com> | 2024-10-20 20:33:38 -0500 |
|---|---|---|
| committer | sneurlax <sneurlax@gmail.com> | 2024-10-20 20:33:38 -0500 |
| commit | 1c1e0f2a4fcc33324a7d06c3e60d3bf796884e9c (patch) | |
| tree | 14dba8dbf8deab3c309cd310c1cec7d937514c7f /impls/monero.rs/tests | |
| parent | 755749eda4f86500026ce6b790a5eeefe143b34d (diff) | |
add restore_polyseed
and remove an integration test from the unit tests
Diffstat (limited to 'impls/monero.rs/tests')
| -rw-r--r-- | impls/monero.rs/tests/integration_tests.rs | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/impls/monero.rs/tests/integration_tests.rs b/impls/monero.rs/tests/integration_tests.rs index 22bcfda..6dea846 100644 --- a/impls/monero.rs/tests/integration_tests.rs +++ b/impls/monero.rs/tests/integration_tests.rs @@ -109,15 +109,12 @@ 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( @@ -153,6 +150,46 @@ fn test_restore_mnemonic_integration() { // TODO: Test with offset. #[test] +fn test_restore_polyseed_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(); + let mnemonic_seed = "capital chief route liar question fix clutch water outside pave hamster occur always learn license knife".to_string(); + + let restored_wallet = manager.restore_polyseed( + 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. + true, // Create a new wallet. + ); + + 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, + "465cUW8wTMSCV8oVVh7CuWWHs7yeB1oxhNPrsEM5FKSqadTXmobLqsNEtRnyGsbN1rbDuBtWdtxtXhTJda1Lm9vcH2ZdrD1", + "Address does not match expected value" + ); + + // Clean up wallet files. + teardown(&temp_dir).expect("Failed to clean up after test"); +} + +#[test] fn test_generate_from_keys_integration() { println!("Running test_generate_from_keys_integration"); let (manager, temp_dir) = setup().expect("Failed to set up test environment"); |
