2020-09-29 23:29:20 -07:00
|
|
|
//! @brief SHA256 Syscall test
|
|
|
|
|
2020-10-24 17:25:22 +00:00
|
|
|
extern crate solana_program;
|
|
|
|
use solana_program::{
|
2020-09-29 23:29:20 -07:00
|
|
|
hash::{hashv, Hasher},
|
2020-12-01 06:05:31 +00:00
|
|
|
msg,
|
2020-09-29 23:29:20 -07:00
|
|
|
};
|
|
|
|
|
2020-10-07 18:38:38 -07:00
|
|
|
fn test_hasher() {
|
2020-09-29 23:29:20 -07:00
|
|
|
let vals = &["Gaggablaghblagh!".as_ref(), "flurbos".as_ref()];
|
|
|
|
let mut hasher = Hasher::default();
|
|
|
|
hasher.hashv(vals);
|
|
|
|
assert_eq!(hashv(vals), hasher.result());
|
2020-10-07 18:38:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
2020-12-01 06:05:31 +00:00
|
|
|
msg!("sha256");
|
2020-10-07 18:38:38 -07:00
|
|
|
|
|
|
|
test_hasher();
|
2020-09-29 23:29:20 -07:00
|
|
|
|
|
|
|
0
|
|
|
|
}
|
2020-10-07 18:38:38 -07:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_sha256() {
|
|
|
|
test_hasher();
|
|
|
|
}
|
|
|
|
}
|