mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
feat: add rust unit test
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![feature(once_cell)]
|
||||
|
||||
mod batch;
|
||||
mod chunk;
|
||||
pub mod chunk;
|
||||
mod types;
|
||||
mod utils;
|
||||
|
||||
24
common/libzkp/impl/tests/chunk_test.rs
Normal file
24
common/libzkp/impl/tests/chunk_test.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use prover::utils::get_block_trace_from_file;
|
||||
use std::{ffi::CString, path::Path, thread::sleep, time::Duration};
|
||||
use zkp::chunk;
|
||||
|
||||
#[test]
|
||||
fn chunk_test() {
|
||||
let params = CString::new("/assets/test_params").expect("test_params conversion failed");
|
||||
let assets = CString::new("/assets/test_assets").expect("test_assets conversion failed");
|
||||
|
||||
let trace_path = "/assets/traces/1_transfer.json".to_string();
|
||||
let chunk_trace = get_block_trace_from_file(Path::new(&trace_path));
|
||||
let json_str = serde_json::to_string(&chunk_trace).expect("Serialization failed");
|
||||
let c_string = CString::new(json_str).expect("CString conversion failed");
|
||||
let c_str_ptr = c_string.as_ptr();
|
||||
|
||||
unsafe {
|
||||
chunk::init_chunk_prover(params.as_ptr(), assets.as_ptr());
|
||||
loop {
|
||||
chunk::gen_chunk_proof(c_str_ptr);
|
||||
let duration = Duration::from_millis(100);
|
||||
sleep(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user