2024-06-24 01:30:47 +00:00
|
|
|
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
2024-01-29 22:32:16 +00:00
|
|
|
|
|
|
|
struct AltName {
|
|
|
|
val: u8,
|
|
|
|
d: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
epee_object!(
|
|
|
|
AltName,
|
|
|
|
val("val2"): u8,
|
|
|
|
d: u64,
|
|
|
|
);
|
|
|
|
|
|
|
|
struct AltName2 {
|
|
|
|
val2: u8,
|
|
|
|
d: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
epee_object!(
|
|
|
|
AltName2,
|
|
|
|
val2: u8,
|
|
|
|
d: u64,
|
|
|
|
);
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn epee_alt_name() {
|
|
|
|
let val2 = AltName2 { val2: 40, d: 30 };
|
|
|
|
let bytes = to_bytes(val2).unwrap();
|
|
|
|
|
2024-01-30 16:09:54 +00:00
|
|
|
let val: AltName = from_bytes(&mut bytes.clone()).unwrap();
|
2024-01-29 22:32:16 +00:00
|
|
|
|
|
|
|
let bytes2 = to_bytes(val).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(bytes, bytes2);
|
|
|
|
}
|