From dce42cf4249f4d5b40433ceaa5e8c0a3383bf69e Mon Sep 17 00:00:00 2001 From: sneurlax Date: Fri, 18 Oct 2024 19:59:08 -0500 Subject: add init and wallet_name->test_wallet --- impls/monero.rs/tests/integration_tests.rs | 56 ++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'impls/monero.rs/tests/integration_tests.rs') diff --git a/impls/monero.rs/tests/integration_tests.rs b/impls/monero.rs/tests/integration_tests.rs index da7a6c6..0b8d21f 100644 --- a/impls/monero.rs/tests/integration_tests.rs +++ b/impls/monero.rs/tests/integration_tests.rs @@ -1,4 +1,4 @@ -use monero_c_rust::{WalletManager, NetworkType, WalletError, WalletResult, WalletStatus_Ok}; +use monero_c_rust::{WalletManager, NetworkType, WalletConfig, WalletError, WalletResult, WalletStatus_Ok}; use std::fs; use std::sync::Arc; use std::time::Instant; @@ -485,7 +485,7 @@ fn test_get_height_integration() { let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string"); // Create the wallet. - let wallet = manager + let _wallet = manager .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet) .expect("Failed to create wallet"); @@ -508,3 +508,55 @@ fn test_get_height_integration() { teardown(&temp_dir).expect("Failed to clean up after test"); } + +#[test] +fn test_refresh_integration_success() { + println!("Running test_refresh_integration_success"); + let (manager, temp_dir) = setup().expect("Failed to set up test environment"); + + // Construct the full path for the wallet within temp_dir. + let wallet_path = temp_dir.path().join("refresh_integration_wallet"); + let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string"); + + // Create the wallet. + let wallet = manager + .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet) + .expect("Failed to create wallet"); + println!("Wallet created successfully."); + + // Define initialization configuration. + let config = WalletConfig { + daemon_address: "http://localhost:18081".to_string(), // Ensure a daemon is running at this address + upper_transaction_size_limit: 10000, + daemon_username: "user".to_string(), + daemon_password: "pass".to_string(), + use_ssl: false, + light_wallet: false, + proxy_address: "".to_string(), + }; + + // Perform the initialization. + println!("Initializing the wallet..."); + let start = Instant::now(); + let init_result = wallet.init(config); + let duration = start.elapsed(); + println!("Initialization took {:?}", duration); + + assert!(init_result.is_ok(), "Failed to initialize wallet: {:?}", init_result.err()); + + // Perform a refresh operation after initialization. + println!("Refreshing the wallet..."); + let refresh_start = Instant::now(); + let refresh_result = wallet.refresh(); + let refresh_duration = refresh_start.elapsed(); + println!("Refresh operation took {:?}", refresh_duration); + + assert!(refresh_result.is_ok(), "Failed to refresh wallet: {:?}", refresh_result.err()); + + // Clean up wallet files. + fs::remove_file(wallet_str).expect("Failed to delete test wallet"); + fs::remove_file(format!("{}.keys", wallet_str)).expect("Failed to delete test wallet keys"); + + teardown(&temp_dir).expect("Failed to clean up after test"); +} + -- cgit v1.2.3