plumb in msgpack

This commit is contained in:
Jaremy Creechley 2023-12-05 23:31:00 -07:00
parent 519e6c2a6c
commit abd77f1496
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300

View File

@ -115,7 +115,7 @@ pub unsafe extern "C" fn prove(
slice.to_vec() slice.to_vec()
}; };
let pubkey = let _pubkey =
U256::try_from_le_slice(std::slice::from_raw_parts((*pubkey).data, (*pubkey).len)).unwrap(); U256::try_from_le_slice(std::slice::from_raw_parts((*pubkey).data, (*pubkey).len)).unwrap();
let root = let root =
@ -195,6 +195,23 @@ mod tests {
use super::{init, prove, Buffer}; 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] #[test]
fn test_storer_ffi() { fn test_storer_ffi() {
// generate a tuple of (preimages, hash), where preimages is a vector of 256 U256s // generate a tuple of (preimages, hash), where preimages is a vector of 256 U256s