From cda7c975b6c1d4188bacc155d3f95a7a303314f8 Mon Sep 17 00:00:00 2001 From: mostafaei2002 Date: Tue, 11 Jun 2024 17:47:35 +0330 Subject: [PATCH] test: test advanced mode functionality --- src/helper/tests.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/helper/tests.rs b/src/helper/tests.rs index 7b5a6bd..0ea3963 100644 --- a/src/helper/tests.rs +++ b/src/helper/tests.rs @@ -3,7 +3,7 @@ mod test { use crate::helper::{ p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi}, - xvb::{algorithm::calcul_donated_time, priv_stats::RuntimeMode, rounds::round_type}, + xvb::{algorithm::calcul_donated_time, priv_stats::RuntimeMode, priv_stats::RuntimeDonationLevel, rounds::round_type}, Helper, Process, ProcessName, ProcessState, }; @@ -527,6 +527,7 @@ Uptime = 0h 2m 4s async fn corr(client: &Client) -> XvbPubStats { XvbPubStats::request_api(client).await.unwrap() } + #[test] fn algorithm_time_given() { let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new())); @@ -777,4 +778,51 @@ Uptime = 0h 2m 4s / 1000.0; assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip)); } + + #[test] + fn test_xvb_advanced_options () { + let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new())); + let gui_api_p2pool = Arc::new(Mutex::new(PubP2poolApi::new())); + let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new())); + let state_p2pool = P2pool::default(); + lock!(gui_api_p2pool).p2pool_difficulty_u64 = 95000000; + lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0; + lock!(gui_api_xmrig).hashrate_raw_15m = 5000.0; + lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManuallyDonate; + lock!(gui_api_xvb).stats_priv.runtime_manual_amount = 500.0; + + let given_time = calcul_donated_time( + lock!(gui_api_xmrig).hashrate_raw_15m, + &gui_api_p2pool, + &gui_api_xvb, + &state_p2pool, + ); + + assert_eq!(given_time, 60); + + + lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManuallyKeep; + + let given_time = calcul_donated_time( + lock!(gui_api_xmrig).hashrate_raw_15m, + &gui_api_p2pool, + &gui_api_xvb, + &state_p2pool, + ); + assert_eq!(given_time, 540); + + + lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualDonationLevel; + lock!(gui_api_xvb).stats_priv.runtime_manual_donation_level = RuntimeDonationLevel::Donor; + + + let given_time = calcul_donated_time( + lock!(gui_api_xmrig).hashrate_raw_15m, + &gui_api_p2pool, + &gui_api_xvb, + &state_p2pool, + ); + assert_eq!(given_time, 120); + + } }