|
|
@@ -117,80 +117,3 @@ pub unsafe fn deserialize<'a>(
|
|
|
|
|
|
Ok((kas, info, data))
|
|
|
}
|
|
|
-
|
|
|
-#[cfg(test)]
|
|
|
-mod tests {
|
|
|
- extern crate std;
|
|
|
-
|
|
|
- use self::std::ffi::CStr;
|
|
|
- use self::std::println;
|
|
|
- use self::std::string::String;
|
|
|
- use super::*;
|
|
|
- use core::mem;
|
|
|
-
|
|
|
- #[no_mangle]
|
|
|
- fn sol_log_(message: *const u8) {
|
|
|
- let scenario = get_log_scenario();
|
|
|
- let c_str = unsafe { CStr::from_ptr(message as *const i8) };
|
|
|
- let string = c_str.to_str().unwrap();
|
|
|
- println!("{:?}", string);
|
|
|
- }
|
|
|
-
|
|
|
- #[no_mangle]
|
|
|
- fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
|
|
|
- println!("{:?} {:?} {:?} {:?} {:?}", arg1, arg2, arg3, arg4, arg5);
|
|
|
- }
|
|
|
-
|
|
|
- #[test]
|
|
|
- fn test_entrypoint() {
|
|
|
- set_log_scenario(4);
|
|
|
- set_log_64_scenario(4);
|
|
|
- let mut input: [u8; 154] = [
|
|
|
- 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 151, 116, 3, 85, 181, 39, 151, 99, 155,
|
|
|
- 29, 208, 191, 255, 191, 11, 161, 4, 43, 104, 189, 202, 240, 231, 111, 146, 255, 199,
|
|
|
- 71, 67, 34, 254, 68, 48, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0,
|
|
|
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
|
|
|
- 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 190, 103, 191,
|
|
|
- 69, 193, 202, 38, 193, 95, 62, 131, 135, 105, 13, 142, 240, 155, 120, 177, 90, 212, 54,
|
|
|
- 10, 118, 40, 33, 192, 8, 54, 141, 187, 63,
|
|
|
- ];
|
|
|
-
|
|
|
- if let Ok((mut ka, info, data)) = deserialize(&mut input[0] as *mut u8) {
|
|
|
- let account0 = match mem::replace(&mut ka[0], None) {
|
|
|
- Some(mut account0) => account0,
|
|
|
- None => {
|
|
|
- panic!("Error: account not found");
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- for k in ka[1..].iter() {
|
|
|
- if let Some(_) = k {
|
|
|
- panic!("Too many keyed accounts found");
|
|
|
- }
|
|
|
- }
|
|
|
- assert_eq!(true, account0.is_signer);
|
|
|
- let key: &[u8; SIZE_PUBKEY] = &[
|
|
|
- 151, 116, 3, 85, 181, 39, 151, 99, 155, 29, 208, 191, 255, 191, 11, 161, 4, 43,
|
|
|
- 104, 189, 202, 240, 231, 111, 146, 255, 199, 71, 67, 34, 254, 68,
|
|
|
- ];
|
|
|
- assert_eq!(SIZE_PUBKEY, account0.key.key.len());
|
|
|
- assert_eq!(key, account0.key.key);
|
|
|
- assert_eq!(48, account0.lamports);
|
|
|
- assert_eq!(1, account0.data.len());
|
|
|
- let owner = &[0; SIZE_PUBKEY];
|
|
|
- assert_eq!(SIZE_PUBKEY, account0.owner.key.len());
|
|
|
- assert_eq!(owner, account0.owner.key);
|
|
|
- let d = [1, 0, 0, 0, 0, 0, 0, 0, 1];
|
|
|
- assert_eq!(9, data.len());
|
|
|
- assert_eq!(d, data);
|
|
|
- assert_eq!(1, info.tick_height);
|
|
|
- let program_id: &[u8; SIZE_PUBKEY] = &[
|
|
|
- 190, 103, 191, 69, 193, 202, 38, 193, 95, 62, 131, 135, 105, 13, 142, 240, 155,
|
|
|
- 120, 177, 90, 212, 54, 10, 118, 40, 33, 192, 8, 54, 141, 187, 63,
|
|
|
- ];
|
|
|
- assert_eq!(program_id, info.program_id.key);
|
|
|
- } else {
|
|
|
- panic!("Failed to deserialize");
|
|
|
- }
|
|
|
- }
|
|
|
-}
|