Add sanity test to verify floating point std math lib works for BPF (#21013)
On-chain programs frequently require floating point operations. In addition standard library functions are expected to be available. This change adds a simple sanity check that such functions are available and work correctly when compiled to BPF.
This commit is contained in:
@ -62,6 +62,15 @@ pub fn process_instruction(
|
||||
panic!();
|
||||
}
|
||||
|
||||
{
|
||||
// Test - float math functions
|
||||
let zero = accounts[0].try_borrow_mut_data()?.len() as f64;
|
||||
let num = zero + 8.0f64;
|
||||
let num = num.powf(0.333f64);
|
||||
// check that the result is in a correct interval close to 1.998614185980905
|
||||
assert!(1.9986f64 < num && num < 2.0f64);
|
||||
}
|
||||
|
||||
sol_log_compute_units();
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user