2022-09-19 18:38:43 -07:00
|
|
|
use anyhow::Result;
|
2022-09-19 19:06:48 -07:00
|
|
|
use ethereum_types::U256;
|
2022-09-19 18:38:43 -07:00
|
|
|
|
|
|
|
|
use crate::cpu::kernel::aggregator::combined_kernel;
|
2022-09-22 09:27:11 -07:00
|
|
|
use crate::cpu::kernel::interpreter::run_with_kernel;
|
2022-09-19 18:38:43 -07:00
|
|
|
|
2022-09-22 10:34:32 -07:00
|
|
|
|
2022-09-19 18:38:43 -07:00
|
|
|
#[test]
|
|
|
|
|
fn test_ripemd() -> Result<()> {
|
2022-09-22 10:34:32 -07:00
|
|
|
// let expected = "0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc";
|
|
|
|
|
let expected: Vec<&str> = vec!["10271CF7", "1B2C699C", "EBDCBB56", "65289D5B", "BC8D70B3"];
|
|
|
|
|
println!("{:#?}", expected);
|
2022-09-21 19:37:09 -07:00
|
|
|
|
2022-09-22 10:34:32 -07:00
|
|
|
let input: Vec<u32> = vec![0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, 0, 0xdeadbeef];
|
|
|
|
|
// let input: Vec<u32> = vec![
|
|
|
|
|
// 0x1a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
|
|
|
|
|
// 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
|
|
|
|
// ];
|
2022-09-22 09:27:11 -07:00
|
|
|
|
2022-09-22 10:34:32 -07:00
|
|
|
let kernel = combined_kernel();
|
|
|
|
|
let stack_input: Vec<U256> = input.iter().map(|&x| U256::from(x as u32)).rev().collect();
|
|
|
|
|
let stack_output = run_with_kernel(&kernel, kernel.global_labels["compress"], stack_input)?;
|
2022-09-22 23:33:43 -07:00
|
|
|
let actual: Vec<String> = stack_output.stack().iter().map(|&x| format!("{:X}", x)).collect();
|
2022-09-22 10:34:32 -07:00
|
|
|
println!("{:#?}", actual);
|
2022-09-22 09:27:11 -07:00
|
|
|
assert_eq!(expected, actual);
|
2022-09-19 18:38:43 -07:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|