Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rudy/test/reduce copro test time 2 #326

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions fhevm-engine/coprocessor/src/tests/operators_from_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ use fhevm_listener::contracts::TfheContract::TfheContractEvents;
use fhevm_listener::database::tfhe_event_propagate::{Database as ListenerDatabase, Handle, ToType};


use crate::tests::operators::{generate_binary_test_cases, generate_unary_test_cases, supported_types};
use crate::tests::operators::{generate_binary_test_cases, generate_unary_test_cases};
use crate::tests::utils::{default_api_key, setup_test_app, TestInstance};
use crate::tests::utils::{decrypt_ciphertexts, wait_until_all_ciphertexts_computed};

use crate::tests::operators::BinaryOperatorTestCase;
use crate::tests::operators::UnaryOperatorTestCase;

pub fn supported_types() -> &'static [i32] {
&[
0, // bool
8, // 256 bit
9, // ebytes 64
]
}

fn tfhe_event(data: TfheContractEvents) -> Log<TfheContractEvents> {
let address = "0x0000000000000000000000000000000000000000".parse().unwrap();
Log::<TfheContractEvents>{address, data}
Expand Down Expand Up @@ -105,7 +113,11 @@ async fn test_fhe_binary_operands_events() -> Result<(), Box<dyn std::error::Err
.connect(app.db_url())
.await?;
let mut listener_event_to_db = listener_event_to_db(&app).await;
let mut cases = vec![];
for op in generate_binary_test_cases() {
if !supported_types().contains(&op.input_types) {
continue;
}
let support_bytes = match S::try_from(op.operand).unwrap() {
S::FheEq | S::FheNe => true,
_ => false
Expand Down Expand Up @@ -141,8 +153,12 @@ async fn test_fhe_binary_operands_events() -> Result<(), Box<dyn std::error::Err
eprintln!("op_event: {:?}", &op_event);
listener_event_to_db.insert_tfhe_event(&tfhe_event(op_event)).await?;
listener_event_to_db.notify_scheduler().await;
wait_until_all_ciphertexts_computed(&app).await?;

cases.push((op, output_handle));
}

wait_until_all_ciphertexts_computed(&app).await?;
for (op, output_handle) in cases {
let decrypt_request = vec![output_handle.to_be_bytes_vec()];
let resp = decrypt_ciphertexts(&pool, 1, decrypt_request).await?;
let decr_response = &resp[0];
Expand Down Expand Up @@ -195,6 +211,9 @@ async fn test_fhe_unary_operands_events() -> Result<(), Box<dyn std::error::Erro
let mut listener_event_to_db = listener_event_to_db(&app).await;

for op in &ops {
if !supported_types().contains(&op.operand_types) {
continue;
}
let input_handle = next_handle();
let output_handle = next_handle();

Expand Down
Loading