commit 9f4c319750ae1d5b35cb378c1644898246ba17b2
parent acc2b508bdb8444e06ae7eb970c74f50bc5798ff
Author: William Casarin <jb55@jb55.com>
Date: Thu, 7 Jul 2022 09:21:29 -0700
rust: fix test
We might not always receive a commando message. handle this in the test
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/rust/lib.rs b/rust/lib.rs
@@ -54,15 +54,20 @@ mod tests {
let response = {
let mut len = 0u16;
let mut t: u8 = 0;
+ let mut typ: u16 = 0;
let addr = &mut t as *mut u8 as usize;
let mut uptr = addr as *mut u8;
- let res_recv = lnsocket_read(&mut socket, &mut uptr, &mut len);
+ let res_recv = lnsocket_recv(&mut socket, &mut typ, &mut uptr, &mut len);
assert_eq!(res_recv, 1);
let iptr = uptr as *mut i8;
- CStr::from_ptr(iptr.offset(10))
- .to_str()
- .unwrap()
- .to_string()
+ if typ == 0x594d {
+ CStr::from_ptr(iptr.offset(10))
+ .to_str()
+ .unwrap()
+ .to_string()
+ } else {
+ "other".to_string()
+ }
};
assert!(response.len() > 0);