mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Test teardown cleanup fix
Can't reproduce the current failing of servers tests, but stopping the servers cleanly can't hurt. I think.
This commit is contained in:
parent
dcfbda9c89
commit
b4febf2e40
2 changed files with 21 additions and 9 deletions
|
@ -24,6 +24,7 @@ extern crate grin_wallet as wallet;
|
|||
extern crate blake2_rfc as blake2;
|
||||
|
||||
use std::default::Default;
|
||||
use std::ops::Deref;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{fs, thread, time};
|
||||
|
||||
|
@ -175,7 +176,7 @@ impl LocalServerContainer {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn run_server(&mut self, duration_in_seconds: u64) -> servers::ServerStats {
|
||||
pub fn run_server(&mut self, duration_in_seconds: u64) -> servers::Server {
|
||||
let api_addr = format!("{}:{}", self.config.base_addr, self.config.api_server_port);
|
||||
|
||||
let mut seeding_type = servers::Seeding::None;
|
||||
|
@ -232,7 +233,7 @@ impl LocalServerContainer {
|
|||
self.stop_wallet();
|
||||
}
|
||||
|
||||
s.get_server_stats().unwrap()
|
||||
s
|
||||
}
|
||||
|
||||
/// Starts a wallet daemon to receive and returns the
|
||||
|
@ -507,7 +508,7 @@ impl LocalServerContainerPool {
|
|||
/// once they've all been run
|
||||
///
|
||||
|
||||
pub fn run_all_servers(self) -> Vec<servers::ServerStats> {
|
||||
pub fn run_all_servers(self) -> Arc<Mutex<Vec<servers::Server>>> {
|
||||
let run_length = self.config.run_length_in_seconds;
|
||||
let mut handles = vec![];
|
||||
|
||||
|
@ -543,9 +544,9 @@ impl LocalServerContainerPool {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return a much simplified version of the results
|
||||
let return_vec = return_containers.lock().unwrap();
|
||||
return_vec.clone()
|
||||
return_containers.clone()
|
||||
}
|
||||
|
||||
pub fn connect_all_peers(&mut self) {
|
||||
|
@ -567,6 +568,13 @@ impl LocalServerContainerPool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn stop_all_servers(servers: Arc<Mutex<Vec<servers::Server>>>) {
|
||||
let locked_servs = servers.lock().unwrap();
|
||||
for s in locked_servs.deref() {
|
||||
s.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// Create and return a ServerConfig
|
||||
pub fn config(n: u16, test_name_dir: &str, seed_n: u16) -> servers::ServerConfig {
|
||||
servers::ServerConfig {
|
||||
|
|
|
@ -28,7 +28,8 @@ use std::{thread, time};
|
|||
use core::core::hash::Hashed;
|
||||
use core::global::{self, ChainTypes};
|
||||
|
||||
use framework::{config, stratum_config, LocalServerContainerConfig, LocalServerContainerPool,
|
||||
use framework::{config, stratum_config, stop_all_servers,
|
||||
LocalServerContainerConfig, LocalServerContainerPool,
|
||||
LocalServerContainerPoolConfig};
|
||||
|
||||
/// Testing the frameworks by starting a fresh server, creating a genesis
|
||||
|
@ -59,7 +60,8 @@ fn basic_genesis_mine() {
|
|||
server_config.burn_mining_rewards = true;
|
||||
|
||||
pool.create_server(&mut server_config);
|
||||
pool.run_all_servers();
|
||||
let servers = pool.run_all_servers();
|
||||
stop_all_servers(servers);
|
||||
}
|
||||
|
||||
/// Creates 5 servers, first being a seed and check that through peer address
|
||||
|
@ -106,7 +108,8 @@ fn simulate_seeding() {
|
|||
|
||||
// pool.connect_all_peers();
|
||||
|
||||
let _ = pool.run_all_servers();
|
||||
let servers = pool.run_all_servers();
|
||||
stop_all_servers(servers);
|
||||
}
|
||||
|
||||
/// Create 1 server, start it mining, then connect 4 other peers mining and
|
||||
|
@ -160,7 +163,8 @@ fn simulate_parallel_mining() {
|
|||
|
||||
// pool.connect_all_peers();
|
||||
|
||||
let _ = pool.run_all_servers();
|
||||
let servers = pool.run_all_servers();
|
||||
stop_all_servers(servers);
|
||||
|
||||
// Check mining difficulty here?, though I'd think it's more valuable
|
||||
// to simply output it. Can at least see the evolution of the difficulty target
|
||||
|
|
Loading…
Reference in a new issue