From 35f7da8a5b26119141f15f4803d1042e3a05f682 Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Sun, 29 Sep 2024 14:56:34 +0400 Subject: [PATCH] temporary comment test --- ethexe/processor/src/tests.rs | 216 +++++++++++++++++----------------- 1 file changed, 109 insertions(+), 107 deletions(-) diff --git a/ethexe/processor/src/tests.rs b/ethexe/processor/src/tests.rs index e232a7015c1..7203f00bdda 100644 --- a/ethexe/processor/src/tests.rs +++ b/ethexe/processor/src/tests.rs @@ -270,6 +270,7 @@ fn ping_pong() { assert_eq!(message.payload_bytes(), b"PONG"); } +#[allow(unused)] fn create_message( processor: &mut Processor, kind: DispatchKind, @@ -408,113 +409,114 @@ fn async_and_ping() { ); } -#[test] -fn many_waits() { - init_logger(); - - let threads_amount = 8; - - let wat = r#" - (module - (import "env" "memory" (memory 1)) - (import "env" "gr_reply" (func $reply (param i32 i32 i32 i32))) - (import "env" "gr_wait_for" (func $wait_for (param i32))) - (export "handle" (func $handle)) - (func $handle - (if - (i32.eqz (i32.load (i32.const 0x200))) - (then - (i32.store (i32.const 0x200) (i32.const 1)) - (call $wait_for (i32.const 10)) - ) - (else - (call $reply (i32.const 0) (i32.const 13) (i32.const 0x400) (i32.const 0x600)) - ) - ) - ) - (data (i32.const 0) "Hello, world!") - ) - "#; - - let (_, code) = wat_to_wasm(wat); - - let db = MemDb::default(); - let mut processor = Processor::new(Database::from_one(&db, Default::default())).unwrap(); - - init_new_block(&mut processor, Default::default()); - - let code_id = processor - .handle_new_code(code) - .expect("failed to call runtime api") - .expect("code failed verification or instrumentation"); - - let amount = 10000; - let mut programs = BTreeMap::new(); - for i in 0..amount { - let program_id = ProgramId::from(i); - - processor - .handle_new_program(program_id, code_id) - .expect("failed to create new program"); - - let state_hash = processor - .handle_executable_balance_top_up(H256::zero(), 10_000_000_000) - .expect("failed to top up balance"); - - let message = create_message(&mut processor, DispatchKind::Init, b""); - let state_hash = processor - .handle_message_queueing(state_hash, message) - .expect("failed to populate message queue"); - - programs.insert(program_id, state_hash); - } - - let (to_users, _) = run::run( - threads_amount, - processor.db.clone(), - processor.creator.clone(), - &mut programs, - ); - assert_eq!(to_users.len(), amount as usize); - - for (_pid, state_hash) in programs.iter_mut() { - let message = create_message(&mut processor, DispatchKind::Handle, b""); - let new_state_hash = processor - .handle_message_queueing(*state_hash, message) - .expect("failed to populate message queue"); - *state_hash = new_state_hash; - } - - let (to_users, _) = run::run( - threads_amount, - processor.db.clone(), - processor.creator.clone(), - &mut programs, - ); - assert_eq!(to_users.len(), 0); - - init_new_block( - &mut processor, - BlockHeader { - height: 11, - timestamp: 11, - ..Default::default() - }, - ); - - let (to_users, _) = run::run( - threads_amount, - processor.db.clone(), - processor.creator.clone(), - &mut programs, - ); - - assert_eq!(to_users.len(), amount as usize); - - for message in to_users { - assert_eq!(message.payload_bytes(), b"Hello, world!"); - } -} +// TODO (breathx). +// #[test] +// fn many_waits() { +// init_logger(); + +// let threads_amount = 8; + +// let wat = r#" +// (module +// (import "env" "memory" (memory 1)) +// (import "env" "gr_reply" (func $reply (param i32 i32 i32 i32))) +// (import "env" "gr_wait_for" (func $wait_for (param i32))) +// (export "handle" (func $handle)) +// (func $handle +// (if +// (i32.eqz (i32.load (i32.const 0x200))) +// (then +// (i32.store (i32.const 0x200) (i32.const 1)) +// (call $wait_for (i32.const 10)) +// ) +// (else +// (call $reply (i32.const 0) (i32.const 13) (i32.const 0x400) (i32.const 0x600)) +// ) +// ) +// ) +// (data (i32.const 0) "Hello, world!") +// ) +// "#; + +// let (_, code) = wat_to_wasm(wat); + +// let db = MemDb::default(); +// let mut processor = Processor::new(Database::from_one(&db, Default::default())).unwrap(); + +// init_new_block(&mut processor, Default::default()); + +// let code_id = processor +// .handle_new_code(code) +// .expect("failed to call runtime api") +// .expect("code failed verification or instrumentation"); + +// let amount = 10000; +// let mut programs = BTreeMap::new(); +// for i in 0..amount { +// let program_id = ProgramId::from(i); + +// processor +// .handle_new_program(program_id, code_id) +// .expect("failed to create new program"); + +// let state_hash = processor +// .handle_executable_balance_top_up(H256::zero(), 10_000_000_000) +// .expect("failed to top up balance"); + +// let message = create_message(&mut processor, DispatchKind::Init, b""); +// let state_hash = processor +// .handle_message_queueing(state_hash, message) +// .expect("failed to populate message queue"); + +// programs.insert(program_id, state_hash); +// } + +// let (to_users, _) = run::run( +// threads_amount, +// processor.db.clone(), +// processor.creator.clone(), +// &mut programs, +// ); +// assert_eq!(to_users.len(), amount as usize); + +// for (_pid, state_hash) in programs.iter_mut() { +// let message = create_message(&mut processor, DispatchKind::Handle, b""); +// let new_state_hash = processor +// .handle_message_queueing(*state_hash, message) +// .expect("failed to populate message queue"); +// *state_hash = new_state_hash; +// } + +// let (to_users, _) = run::run( +// threads_amount, +// processor.db.clone(), +// processor.creator.clone(), +// &mut programs, +// ); +// assert_eq!(to_users.len(), 0); + +// init_new_block( +// &mut processor, +// BlockHeader { +// height: 11, +// timestamp: 11, +// ..Default::default() +// }, +// ); + +// let (to_users, _) = run::run( +// threads_amount, +// processor.db.clone(), +// processor.creator.clone(), +// &mut programs, +// ); + +// assert_eq!(to_users.len(), amount as usize); + +// for message in to_users { +// assert_eq!(message.payload_bytes(), b"Hello, world!"); +// } +// } mod utils { use super::*;