2022-10-28 11:30:31 -07:00
|
|
|
//! Example Rust-based SBF program tests loop iteration
|
2019-08-29 11:25:22 -07:00
|
|
|
|
2023-09-01 00:26:13 -07:00
|
|
|
#![allow(clippy::arithmetic_side_effects)]
|
2023-03-12 22:28:34 -07:00
|
|
|
|
2020-10-23 17:22:10 -07:00
|
|
|
extern crate solana_program;
|
2019-08-29 11:25:22 -07:00
|
|
|
|
2019-09-18 19:54:10 -07:00
|
|
|
#[derive(Debug)]
|
2019-08-29 11:25:22 -07:00
|
|
|
pub struct Data<'a> {
|
|
|
|
pub twentyone: u64,
|
|
|
|
pub twentytwo: u64,
|
|
|
|
pub twentythree: u64,
|
|
|
|
pub twentyfour: u64,
|
|
|
|
pub twentyfive: u32,
|
|
|
|
pub array: &'a [u8],
|
|
|
|
}
|
|
|
|
|
2019-09-18 19:54:10 -07:00
|
|
|
#[derive(PartialEq, Debug)]
|
2019-08-29 11:25:22 -07:00
|
|
|
pub struct TestDep {
|
|
|
|
pub thirty: u32,
|
|
|
|
}
|
|
|
|
impl<'a> TestDep {
|
|
|
|
pub fn new(data: &Data<'a>, _one: u64, _two: u64, _three: u64, _four: u64, five: u64) -> Self {
|
|
|
|
Self {
|
|
|
|
thirty: data.twentyfive + five as u32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-18 19:54:10 -07:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_dep() {
|
|
|
|
let array = [0xA, 0xB, 0xC, 0xD, 0xE, 0xF];
|
|
|
|
let data = Data {
|
|
|
|
twentyone: 21u64,
|
|
|
|
twentytwo: 22u64,
|
|
|
|
twentythree: 23u64,
|
|
|
|
twentyfour: 24u64,
|
|
|
|
twentyfive: 25u32,
|
|
|
|
array: &array,
|
|
|
|
};
|
|
|
|
assert_eq!(TestDep { thirty: 30 }, TestDep::new(&data, 1, 2, 3, 4, 5));
|
|
|
|
}
|
|
|
|
}
|