From abd77f14964f0a8dca8318fa6d650c6dc30cb03a Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Tue, 5 Dec 2023 23:31:00 -0700 Subject: [PATCH] plumb in msgpack --- src/ffi.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ffi.rs b/src/ffi.rs index 1a779d7..2e34cf1 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -115,7 +115,7 @@ pub unsafe extern "C" fn prove( slice.to_vec() }; - let pubkey = + let _pubkey = U256::try_from_le_slice(std::slice::from_raw_parts((*pubkey).data, (*pubkey).len)).unwrap(); let root = @@ -195,6 +195,23 @@ mod tests { use super::{init, prove, Buffer}; + use rmpv::ValueRef; + use rmpv::encode::write_value_ref; + use rmpv::decode::read_value_ref; + + #[test] + fn test_mpack() { + let mut buf = Vec::new(); + let val = ValueRef::from("le message"); + + write_value_ref(&mut buf, &val).unwrap(); + // assert_eq!(vec![0xaa, 0x6c, 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65], buf); + // let buf = [0xaa, 0x6c, 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65]; + let mut rd = &buf[..]; + + assert_eq!(ValueRef::from("le message"), read_value_ref(&mut rd).unwrap()); + } + #[test] fn test_storer_ffi() { // generate a tuple of (preimages, hash), where preimages is a vector of 256 U256s