From 5ea3b1bf9782cd6c44b3ba74cade4024e606f6cd Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 23 Mar 2024 17:38:50 -0400 Subject: [PATCH] Use " " instead of "" for the empty key so sh doesn't interpret it as falsy --- substrate/client/tests/common/mod.rs | 2 +- substrate/client/tests/dht.rs | 2 +- substrate/client/tests/validator_sets.rs | 2 +- substrate/node/src/keystore.rs | 2 +- tests/coordinator/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/substrate/client/tests/common/mod.rs b/substrate/client/tests/common/mod.rs index a6d5300b..d7e8436b 100644 --- a/substrate/client/tests/common/mod.rs +++ b/substrate/client/tests/common/mod.rs @@ -32,7 +32,7 @@ macro_rules! serai_test { .replace_env( HashMap::from([ ("RUST_LOG".to_string(), "runtime=debug".to_string()), - ("KEY".to_string(), String::new()), + ("KEY".to_string(), " ".to_string()), ]) ) .set_publish_all_ports(true) diff --git a/substrate/client/tests/dht.rs b/substrate/client/tests/dht.rs index 4ab177ad..82450e46 100644 --- a/substrate/client/tests/dht.rs +++ b/substrate/client/tests/dht.rs @@ -15,7 +15,7 @@ async fn dht() { Image::with_repository("serai-dev-serai").pull_policy(PullPolicy::Never), ) .replace_env( - [("SERAI_NAME".to_string(), name.to_string()), ("KEY".to_string(), String::new())].into(), + [("SERAI_NAME".to_string(), name.to_string()), ("KEY".to_string(), " ".to_string())].into(), ) .set_publish_all_ports(true) .set_handle(handle(name)) diff --git a/substrate/client/tests/validator_sets.rs b/substrate/client/tests/validator_sets.rs index 884a42db..8ae150ec 100644 --- a/substrate/client/tests/validator_sets.rs +++ b/substrate/client/tests/validator_sets.rs @@ -102,7 +102,7 @@ async fn validator_set_rotation() { ]) .replace_env(HashMap::from([ ("RUST_LOG".to_string(), "runtime=debug".to_string()), - ("KEY".to_string(), String::new()), + ("KEY".to_string(), " ".to_string()), ])) .set_publish_all_ports(true) .set_handle(handle(name)) diff --git a/substrate/node/src/keystore.rs b/substrate/node/src/keystore.rs index f7b9110f..c313773a 100644 --- a/substrate/node/src/keystore.rs +++ b/substrate/node/src/keystore.rs @@ -8,7 +8,7 @@ pub struct Keystore(sr25519::Pair); impl Keystore { pub fn from_env() -> Option { let mut key_hex = serai_env::var("KEY")?; - if key_hex.is_empty() { + if key_hex.trim().is_empty() { None?; } let mut key = hex::decode(&key_hex).expect("KEY from environment wasn't hex"); diff --git a/tests/coordinator/src/lib.rs b/tests/coordinator/src/lib.rs index d09f4487..e6b0324d 100644 --- a/tests/coordinator/src/lib.rs +++ b/tests/coordinator/src/lib.rs @@ -67,7 +67,7 @@ pub fn serai_composition(name: &str) -> TestBodySpecification { Image::with_repository("serai-dev-serai").pull_policy(PullPolicy::Never), ) .replace_env( - [("SERAI_NAME".to_string(), name.to_lowercase()), ("KEY".to_string(), String::new())].into(), + [("SERAI_NAME".to_string(), name.to_lowercase()), ("KEY".to_string(), " ".to_string())].into(), ) .set_publish_all_ports(true) }