Skip to content

Commit

Permalink
fix: make test
Browse files Browse the repository at this point in the history
  • Loading branch information
keroro520 committed Dec 30, 2024
1 parent bbeb2fe commit 7655373
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 100 deletions.
5 changes: 5 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ mod tests {
proof_type,
blob_proof_type: BlobProofType::ProofOfEquivalence,
prover_args: test_proof_params(false),
image_id: None,
};
prove_block(l1_chain_spec, taiko_chain_spec, proof_request).await;
}
Expand Down Expand Up @@ -358,6 +359,7 @@ mod tests {
proof_type,
blob_proof_type: BlobProofType::ProofOfEquivalence,
prover_args: test_proof_params(false),
image_id: None,
};
prove_block(l1_chain_spec, taiko_chain_spec, proof_request).await;
}
Expand Down Expand Up @@ -397,6 +399,7 @@ mod tests {
proof_type,
blob_proof_type: BlobProofType::ProofOfEquivalence,
prover_args: test_proof_params(false),
image_id: None,
};
prove_block(l1_chain_spec, taiko_chain_spec, proof_request).await;
}
Expand Down Expand Up @@ -430,6 +433,7 @@ mod tests {
proof_type,
blob_proof_type: BlobProofType::ProofOfEquivalence,
prover_args: test_proof_params(false),
image_id: None,
};
prove_block(l1_chain_spec, taiko_chain_spec, proof_request).await;
}
Expand Down Expand Up @@ -460,6 +464,7 @@ mod tests {
proof_type,
blob_proof_type: BlobProofType::ProofOfEquivalence,
prover_args: test_proof_params(true),
image_id: None,
};
let proof = prove_block(l1_chain_spec, taiko_chain_spec, proof_request).await;

Expand Down
1 change: 1 addition & 0 deletions host/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ mod test {
blob_proof_type: BlobProofType::KzgVersionedHash,
prover_args: Default::default(),
l1_inclusion_block_number: 0,
image_id: None,
};
let raiko = Raiko::new(
l1_chain_spec.clone(),
Expand Down
1 change: 1 addition & 0 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ pub async fn handle_proof(
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::ChainId;
use tokio::sync::mpsc;

fn create_test_proof_request() -> ProofRequest {
Expand Down
25 changes: 22 additions & 3 deletions host/tests/common/request.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use raiko_core::interfaces::{AggregationOnlyRequest, ProofRequestOpt, ProverSpecificOpts};
use raiko_core::interfaces::{
get_aggregation_image, AggregationOnlyRequest, ProofRequestOpt, ProverSpecificOpts,
};
use raiko_host::server::api;
use raiko_lib::consts::Network;
use raiko_lib::proof_type::ProofType;
use raiko_lib::prover::Proof;
use raiko_lib::{consts::Network, prover::encode_image_id};
use raiko_tasks::{TaskDescriptor, TaskReport, TaskStatus};
use serde_json::json;

Expand All @@ -20,6 +22,13 @@ pub fn make_proof_request(
block_number,
std::time::Instant::now().elapsed().as_secs()
);
let image_id = match proof_type {
ProofType::Sp1 | ProofType::Risc0 => {
let (_, image_id) = get_aggregation_image(*proof_type).unwrap();
Some(encode_image_id(image_id))
}
ProofType::Native | ProofType::Sgx => None,
};
ProofRequestOpt {
block_number: Some(block_number),
network: Some(network.to_string()),
Expand All @@ -46,6 +55,7 @@ pub fn make_proof_request(
sgx: None,
sp1: None,
},
image_id,
}
}

Expand All @@ -66,6 +76,13 @@ pub async fn make_aggregate_proof_request(
.join(","),
std::time::Instant::now().elapsed().as_secs()
);
let image_id = match proof_type {
ProofType::Sp1 | ProofType::Risc0 => {
let (_, image_id) = get_aggregation_image(*proof_type).unwrap();
Some(encode_image_id(image_id))
}
ProofType::Native | ProofType::Sgx => None,
};
AggregationOnlyRequest {
aggregation_ids: block_numbers,
proofs,
Expand All @@ -83,6 +100,7 @@ pub async fn make_aggregate_proof_request(
sgx: None,
sp1: None,
},
image_id,
}
}

Expand Down Expand Up @@ -246,7 +264,8 @@ pub async fn get_status_of_aggregation_proof_request(
client: &Client,
request: &AggregationOnlyRequest,
) -> TaskStatus {
let expected_task_descriptor: TaskDescriptor = TaskDescriptor::Aggregation(request.into());
let expected_task_descriptor: TaskDescriptor =
TaskDescriptor::Aggregation(request.try_into().unwrap());
let report = v2_assert_report(client).await;
for (task_descriptor, task_status) in &report {
if task_descriptor == &expected_task_descriptor {
Expand Down
16 changes: 14 additions & 2 deletions host/tests/test/manual_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::common::{complete_proof_request, v2_assert_report, Client};
use raiko_core::interfaces::{ProofRequestOpt, ProverSpecificOpts};
use raiko_core::interfaces::{get_aggregation_image, ProofRequestOpt, ProverSpecificOpts};
use raiko_host::server::api;
use raiko_lib::{proof_type::ProofType, prover::encode_image_id};
use raiko_tasks::TaskStatus;
use serde_json::json;
use std::str::FromStr;

/// This test is used to manually test the proof process. Operator can use this to test case to
/// simplly test online service.
Expand Down Expand Up @@ -32,16 +34,26 @@ pub async fn test_manual_prove() {
let api_version = std::env::var("RAIKO_TEST_MANUAL_PROVE_API_VERSION").unwrap_or_default();
let network = std::env::var("RAIKO_TEST_MANUAL_PROVE_NETWORK").unwrap_or_default();
let proof_type = std::env::var("RAIKO_TEST_MANUAL_PROVE_PROOF_TYPE").unwrap_or_default();
let proof_type = ProofType::from_str(&proof_type).unwrap();
let block_number = std::env::var("RAIKO_TEST_MANUAL_PROVE_BLOCK_NUMBER")
.map(|s| s.parse::<u64>().unwrap())
.unwrap();
let raiko_rpc_url = std::env::var("RAIKO_TEST_MANUAL_PROVE_RAIKO_RPC_URL").unwrap_or_default();

let image_id = match proof_type {
ProofType::Sp1 | ProofType::Risc0 => {
let (_, image_id) = get_aggregation_image(proof_type).unwrap();
Some(encode_image_id(image_id))
}
ProofType::Native | ProofType::Sgx => None,
};

let client = Client::new(raiko_rpc_url.clone());
let request = ProofRequestOpt {
block_number: Some(block_number),
network: Some(network.clone()),
proof_type: Some(proof_type.clone()),
proof_type: Some(proof_type.to_string()),
image_id,

// Untesting parameters
l1_inclusion_block_number: None,
Expand Down
15 changes: 8 additions & 7 deletions taskdb/src/mem_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,14 @@ mod tests {
#[test]
fn test_db_enqueue() {
let mut db = InMemoryTaskDb::new();
let params = ProofTaskDescriptor {
chain_id: 1,
block_id: 1,
blockhash: B256::default(),
proof_system: ProofType::Native,
prover: "0x1234".to_owned(),
};
let params = ProofTaskDescriptor::new(
1,
1,
B256::default(),
ProofType::Native,
"0x1234".to_owned(),
None,
);
db.enqueue_task(&params).expect("enqueue task");
let status = db.get_task_proving_status(&params);
assert!(status.is_ok());
Expand Down
Loading

0 comments on commit 7655373

Please sign in to comment.