1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//https://crates.io/crates/library_utils
pub mod calculate;
pub mod slicer;
pub mod stepper;
pub mod stringify;
pub mod stringtou128;
#[allow(unused_imports)]
#[allow(dead_code)]
#[cfg(test)]
mod tests {
use super::*;
static DIFFICULTY_STR: &str = "0x00ffffffffffffffffffffffffffff00";
static DIFFICULTY_128: u128 = 0x00ffffffffffffffffffffffffffff00;
#[test]
fn func_string_to_u128() {
let difficulty = crate::stringtou128::string_to_u128(&DIFFICULTY_STR.to_string());
assert_eq!(difficulty, 0x00ffffffffffffffffffffffffffff00);
}
// #[test]
// fn func_bytes_to_u128(){
// let y=&u128_bytes(&difficulty_128);
// let x=difficulty_bytes_as_u128(&y.to_vec());
// assert_eq!(&x,&difficulty_128);
// }
// #[test]
// fn func_bytes_to_u128(){
// let mut bytes:Vec<u8> = vec![];
// bytes.extend(&u128_bytes(&difficulty_128));
// let x=difficulty_bytes_as_u128(&bytes).to_le_bytes().to_vec();
// assert_eq!(&x,&bytes);
// }
//#[test]
//fn func_integration_string_vs_u128(){
// let mut bytes = vec![];
// let difficulty=string_to_u128(&difficulty_str.to_string());
// let de_diff_bytes=u128_bytes(&difficulty);
// bytes.extend(de_diff_bytes);
// let de_diff = u128::from_le_bytes(de_diff_bytes);
// let de_diff_str = format!("0x{de_diff:032x}");
// let aa=difficulty_bytes_as_u128(&bytes);
// assert_eq!(&difficulty_str, &de_diff_str);
// assert_eq!(&difficulty, &de_diff);
// assert_eq!(&de_diff, &aa);
//}
}