X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ftest_utils.rs;h=27c2d9de874ed45abca03dabe171ca238d7288ff;hb=b42ebd892b161e846cd37e0bb3639cca9b6c08b8;hp=9cd2f9ec13e8bd49de15be2fc0f283fe34660eee;hpb=797a648b6caa105e4c6edd9dba337eebb15bc97c;p=rust-lightning diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 9cd2f9ec..27c2d9de 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -411,7 +411,10 @@ impl events::MessageSendEventsProvider for TestRoutingMessageHandler { pub struct TestLogger { level: Level, + #[cfg(feature = "std")] id: String, + #[cfg(not(feature = "std"))] + _id: String, pub lines: Mutex>, } @@ -422,7 +425,10 @@ impl TestLogger { pub fn with_id(id: String) -> TestLogger { TestLogger { level: Level::Trace, + #[cfg(feature = "std")] id, + #[cfg(not(feature = "std"))] + _id: id, lines: Mutex::new(HashMap::new()) } } @@ -471,8 +477,7 @@ impl Logger for TestLogger { pub struct TestKeysInterface { pub backing: keysinterface::PhantomKeysManager, - pub override_session_priv: Mutex>, - pub override_channel_id_priv: Mutex>, + pub override_random_bytes: Mutex>, pub disable_revocation_policy_check: bool, enforcement_states: Mutex>>>, expectations: Mutex>>, @@ -506,16 +511,9 @@ impl keysinterface::KeysInterface for TestKeysInterface { } fn get_secure_random_bytes(&self) -> [u8; 32] { - let override_channel_id = self.override_channel_id_priv.lock().unwrap(); - let override_session_key = self.override_session_priv.lock().unwrap(); - if override_channel_id.is_some() && override_session_key.is_some() { - panic!("We don't know which override key to use!"); - } - if let Some(key) = &*override_channel_id { - return *key; - } - if let Some(key) = &*override_session_key { - return *key; + let override_random_bytes = self.override_random_bytes.lock().unwrap(); + if let Some(bytes) = &*override_random_bytes { + return *bytes; } self.backing.get_secure_random_bytes() } @@ -543,8 +541,7 @@ impl TestKeysInterface { let now = Duration::from_secs(genesis_block(network).header.time as u64); Self { backing: keysinterface::PhantomKeysManager::new(seed, now.as_secs(), now.subsec_nanos(), seed), - override_session_priv: Mutex::new(None), - override_channel_id_priv: Mutex::new(None), + override_random_bytes: Mutex::new(None), disable_revocation_policy_check: false, enforcement_states: Mutex::new(HashMap::new()), expectations: Mutex::new(None),