mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-07-10 08:05:33 +00:00
feat(types,blahd): allow using mock clock for testing
This commit is contained in:
parent
1a4980ebba
commit
31dc3e33c6
8 changed files with 61 additions and 13 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use ed25519_dalek::{
|
||||
Signature, SignatureError, Signer, SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH,
|
||||
|
@ -104,6 +103,12 @@ impl<T: Serialize> SignExt for T {
|
|||
}
|
||||
|
||||
pub fn get_timestamp() -> u64 {
|
||||
#[cfg(not(feature = "unsafe_use_mock_instant_for_testing"))]
|
||||
use std::time::SystemTime;
|
||||
|
||||
#[cfg(feature = "unsafe_use_mock_instant_for_testing")]
|
||||
use mock_instant::thread_local::SystemTime;
|
||||
|
||||
SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.expect("after UNIX epoch")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue