Add dependent crate test (#4647)

automerge
This commit is contained in:
Jack May
2019-06-11 11:45:13 -07:00
committed by Grimes
parent 3217a1d70c
commit 439e7cc26a
6 changed files with 56 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
//! @brief Example Rust-based BPF program tests dependent crates
#![no_std]
extern crate solana_sdk_bpf_utils;
use byteorder::{ByteOrder, LittleEndian};
use solana_sdk_bpf_utils::log::*;
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> bool {
let mut buf = [0; 4];
LittleEndian::write_u32(&mut buf, 1_000_000);
assert_eq!(1_000_000, LittleEndian::read_u32(&buf));
let mut buf = [0; 2];
LittleEndian::write_i16(&mut buf, -5_000);
assert_eq!(-5_000, LittleEndian::read_i16(&buf));
sol_log("Success");
true
}