Fixed hash-tail tests.

This commit is contained in:
Revertron
2021-03-07 02:12:00 +01:00
parent 9f7a6a126b
commit 0d40f6599b
+7 -7
View File
@@ -27,7 +27,7 @@ pub struct Keystore {
#[serde(skip)] #[serde(skip)]
path: String, path: String,
#[serde(skip)] #[serde(skip)]
seed: Vec<u8> seed: Vec<u8>,
} }
impl Keystore { impl Keystore {
@@ -36,12 +36,12 @@ impl Keystore {
let mut rng = thread_rng(); let mut rng = thread_rng();
rng.fill(&mut buf); rng.fill(&mut buf);
let (private, public) = keypair(&buf); let (private, public) = keypair(&buf);
Keystore {private_key: Bytes::from_bytes(&private), public_key: Bytes::from_bytes(&public), path: String::new(), seed: Vec::from(&buf[..])} Keystore { private_key: Bytes::from_bytes(&private), public_key: Bytes::from_bytes(&public), path: String::new(), seed: Vec::from(&buf[..]) }
} }
pub fn from_bytes(seed: &[u8]) -> Self { pub fn from_bytes(seed: &[u8]) -> Self {
let (private, public) = keypair(&seed); let (private, public) = keypair(&seed);
Keystore {private_key: Bytes::from_bytes(&private), public_key: Bytes::from_bytes(&public), path: String::new(), seed: Vec::from(seed)} Keystore { private_key: Bytes::from_bytes(&private), public_key: Bytes::from_bytes(&public), path: String::new(), seed: Vec::from(seed) }
} }
pub fn from_file(filename: &str, _password: &str) -> Option<Self> { pub fn from_file(filename: &str, _password: &str) -> Option<Self> {
@@ -51,10 +51,10 @@ impl Keystore {
let mut keystore = Self::from_bytes(key.as_slice()); let mut keystore = Self::from_bytes(key.as_slice());
keystore.path = path.to_str().unwrap().to_owned(); keystore.path = path.to_str().unwrap().to_owned();
Some(keystore) Some(keystore)
}, }
Err(_) => { Err(_) => {
None None
}, }
} }
} }
@@ -247,7 +247,7 @@ mod tests {
#[test] #[test]
pub fn test_tail_bytes() { pub fn test_tail_bytes() {
let bytes = Bytes::new(vec![0,255,255,255]); let bytes = Bytes::new(vec![0, 255, 255, 255, 0, 255, 255, 255]);
assert_eq!(bytes.get_tail_u64(), 16777215); assert_eq!(bytes.get_tail_u64(), 72057589759737855u64);
} }
} }