mirror of https://github.com/zcash/zip32.git
parent
43f48d540a
commit
a4c4c72174
29
src/lib.rs
29
src/lib.rs
|
@ -326,4 +326,33 @@ mod tests {
|
|||
|
||||
assert!(DiversifierIndex::try_from(0x0100_0000_0000_0000_0000_0000_u128).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diversifier_index_increment() {
|
||||
let mut di = DiversifierIndex::new();
|
||||
assert_eq!(di, 0_u32.into());
|
||||
|
||||
assert_matches!(di.increment(), Ok(_));
|
||||
assert_eq!(di, 1_u32.into());
|
||||
|
||||
assert_matches!(di.increment(), Ok(_));
|
||||
assert_eq!(di, 2_u32.into());
|
||||
|
||||
let mut di = DiversifierIndex::from(0xff_u32);
|
||||
assert_eq!(di, 0x00ff_u32.into());
|
||||
|
||||
assert_matches!(di.increment(), Ok(_));
|
||||
assert_eq!(di, 0x0100_u32.into());
|
||||
|
||||
assert_matches!(di.increment(), Ok(_));
|
||||
assert_eq!(di, 0x0101_u32.into());
|
||||
|
||||
let mut di = DiversifierIndex::try_from(0x00ff_ffff_ffff_ffff_ffff_fffe_u128).unwrap();
|
||||
assert_eq!(u128::from(di), 0x00ff_ffff_ffff_ffff_ffff_fffe_u128);
|
||||
|
||||
assert_matches!(di.increment(), Ok(_));
|
||||
assert_eq!(u128::from(di), 0x00ff_ffff_ffff_ffff_ffff_ffff_u128);
|
||||
|
||||
assert_matches!(di.increment(), Err(_));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue