31 lines
843 B
Rust
Raw Normal View History

2022-10-12 10:06:34 -04:00
use anyhow::Result;
use ethereum_types::U256;
use crate::cpu::kernel::aggregator::combined_kernel;
use crate::cpu::kernel::interpreter::run_with_kernel;
#[test]
fn test_field() -> Result<()> {
let kernel = combined_kernel();
2022-10-17 11:02:24 -04:00
let initial_offset = kernel.global_labels["test_mul_Fp12"];
let initial_stack: Vec<U256> = vec![
1, 1, 0, 0, 1, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 3, 0, 0, 1, 0, 0,
]
.iter()
.map(|&x| U256::from(x as u32))
.rev()
.collect();
2022-10-12 10:06:34 -04:00
let final_stack: Vec<U256> = run_with_kernel(&kernel, initial_offset, initial_stack)?
.stack()
.to_vec();
2022-10-17 11:02:24 -04:00
let expected: Vec<U256> = vec![5, 5, 9, 0, 5, 3, 17, 12, 100, 1, 3, 0]
.iter()
.map(|&x| U256::from(x as u32))
.rev()
.collect();
2022-10-12 10:06:34 -04:00
assert_eq!(final_stack, expected);
2022-10-17 11:02:24 -04:00
2022-10-12 10:06:34 -04:00
Ok(())
}