test: test advanced mode functionality

This commit is contained in:
mostafaei2002 2024-06-11 17:47:35 +03:30
parent 3d6e6e8bfe
commit cda7c975b6

View file

@ -3,7 +3,7 @@ mod test {
use crate::helper::{ use crate::helper::{
p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi}, 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, Helper, Process, ProcessName, ProcessState,
}; };
@ -527,6 +527,7 @@ Uptime = 0h 2m 4s
async fn corr(client: &Client) -> XvbPubStats { async fn corr(client: &Client) -> XvbPubStats {
XvbPubStats::request_api(client).await.unwrap() XvbPubStats::request_api(client).await.unwrap()
} }
#[test] #[test]
fn algorithm_time_given() { fn algorithm_time_given() {
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new())); let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
@ -777,4 +778,51 @@ Uptime = 0h 2m 4s
/ 1000.0; / 1000.0;
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip)); 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);
}
} }