mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-17 09:47:36 +00:00
tests: add p2pool sync test
This commit is contained in:
parent
7d9ed1b0b8
commit
34a840cfac
2 changed files with 28 additions and 2 deletions
|
@ -121,6 +121,7 @@ impl Default for Sys { fn default() -> Self { Self::new() } }
|
|||
//---------------------------------------------------------------------------------------------------- [Process] Struct
|
||||
// This holds all the state of a (child) process.
|
||||
// The main GUI thread will use this to display console text, online state, etc.
|
||||
#[derive(Debug)]
|
||||
pub struct Process {
|
||||
pub name: ProcessName, // P2Pool or XMRig?
|
||||
pub state: ProcessState, // The state of the process (alive, dead, etc)
|
||||
|
@ -1900,6 +1901,8 @@ impl Hashrate {
|
|||
//---------------------------------------------------------------------------------------------------- TESTS
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn reset_gui_output() {
|
||||
let max = crate::helper::GUI_OUTPUT_LEEWAY;
|
||||
|
@ -1955,7 +1958,8 @@ mod test {
|
|||
let output_pub = Arc::new(Mutex::new(String::new()));
|
||||
let elapsed = std::time::Duration::from_secs(60);
|
||||
let regex = P2poolRegex::new();
|
||||
PubP2poolApi::update_from_output(&public, &output_parse, &output_pub, elapsed, ®ex);
|
||||
let process = Arc::new(Mutex::new(Process::new(ProcessName::P2pool, "".to_string(), PathBuf::new())));
|
||||
PubP2poolApi::update_from_output(&public, &output_parse, &output_pub, elapsed, ®ex, &process);
|
||||
let public = public.lock().unwrap();
|
||||
println!("{:#?}", public);
|
||||
assert_eq!(public.payouts, 3);
|
||||
|
@ -1968,6 +1972,28 @@ mod test {
|
|||
assert_eq!(public.xmr_month, 648000.0000001296);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_p2pool_synchronized() {
|
||||
use crate::helper::{PubP2poolApi,P2poolRegex};
|
||||
use std::sync::{Arc,Mutex};
|
||||
let public = Arc::new(Mutex::new(PubP2poolApi::new()));
|
||||
let output_parse = Arc::new(Mutex::new(String::from(
|
||||
r#"payout of 5.000000000001 XMR in block 1111
|
||||
NOTICE 2021-12-27 21:42:17.2008 SideChain SYNCHRONIZED
|
||||
payout of 5.000000000001 XMR in block 1113"#
|
||||
)));
|
||||
let output_pub = Arc::new(Mutex::new(String::new()));
|
||||
let elapsed = std::time::Duration::from_secs(60);
|
||||
let regex = P2poolRegex::new();
|
||||
let process = Arc::new(Mutex::new(Process::new(ProcessName::P2pool, "".to_string(), PathBuf::new())));
|
||||
|
||||
// It only gets checked if we're `Syncing`.
|
||||
process.lock().unwrap().state = ProcessState::Syncing;
|
||||
PubP2poolApi::update_from_output(&public, &output_parse, &output_pub, elapsed, ®ex, &process);
|
||||
println!("{:#?}", process);
|
||||
assert!(process.lock().unwrap().state == ProcessState::Alive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_pub_p2pool_from_local_network_pool() {
|
||||
use std::sync::{Arc,Mutex};
|
||||
|
|
|
@ -127,6 +127,6 @@ mod test {
|
|||
assert_eq!(r.block.find(text).unwrap().as_str(), "block 1111111");
|
||||
assert_eq!(r.block_int.find(text).unwrap().as_str(), "1111111");
|
||||
assert_eq!(r.block_comma.find(text2).unwrap().as_str(), "1,111,111");
|
||||
assert_eq!(r.synchronized.find(text2).unwrap().as_str(), "SYNCHRONIZED");
|
||||
assert_eq!(r.synchronized.find(text3).unwrap().as_str(), "SYNCHRONIZED");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue