Skip to content
Snippets Groups Projects
Commit 5003021c authored by Éloïs's avatar Éloïs
Browse files

[tests] common-tests-tools: ensure to init logger once

parent f75a6389
No related branches found
No related tags found
2 merge requests!232Elois/local validation,!221WIP: Resolve "Fail to revert block with transactions"
......@@ -28,20 +28,12 @@ use durs_ws2p_protocol::controller::{WS2PControllerEvent, WebsocketActionOrder};
use durs_ws2p_protocol::orchestrator::OrchestratorMsg;
use durs_ws2p_protocol::MySelfWs2pNode;
use std::sync::mpsc;
use std::sync::Once;
use std::thread;
use std::time::Duration;
static PORT: &'static u16 = &10899;
static SETUP: Once = Once::new();
static TIMEOUT_IN_MS: &'static u64 = &20_000;
fn setup() {
SETUP.call_once(|| {
durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]);
});
}
pub fn currency() -> CurrencyName {
CurrencyName(String::from("g1"))
}
......@@ -82,7 +74,7 @@ fn client_node() -> MySelfWs2pNode {
#[test]
#[cfg(unix)]
fn test_connection_negociation_denial() {
setup();
durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]);
// ===== initialization =====
// client and server are initialized and launched in separate threads
......@@ -159,7 +151,7 @@ fn test_connection_negociation_denial() {
#[test]
#[cfg(unix)]
fn test_connection_negociation_success() {
setup();
durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]);
// ===== initialization =====
// client and server are initialized and launched in separate threads
......
......@@ -17,9 +17,18 @@
use fern::colors::{Color, ColoredLevelConfig};
use log::LevelFilter;
use std::sync::Once;
static ONCE: Once = Once::new();
/// Initialize stdout logger
pub fn init_logger_stdout(off_targets: Vec<&'static str>) {
ONCE.call_once(|| {
init_logger_stdout_(off_targets);
});
}
fn init_logger_stdout_(off_targets: Vec<&'static str>) {
let colors = match std::env::var("DURS_TESTS_LOG_COLOR")
.unwrap_or_else(|_| String::from("no"))
.as_str()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment