diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index fc3c7c5f5b..4a065764a9 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -20,8 +20,21 @@ use crate::commands::model::ModelArgs; use crate::commands::register::RegisterArgs; use crate::commands::test::TestArgs; +fn generate_version() -> String { + const DOJO_VERSION: &str = env!("CARGO_PKG_VERSION"); + let scarb_version = scarb::version::get().version; + let scarb_sierra_version = scarb::version::get().sierra.version; + let scarb_cairo_version = scarb::version::get().cairo.version; + + let version_string = format!( + "{}\nscarb: {}\ncairo: {}\nsierra: {}", + DOJO_VERSION, scarb_version, scarb_cairo_version, scarb_sierra_version, + ); + version_string +} + #[derive(Parser)] -#[command(author, version, about, long_about = None)] +#[command(author, version=generate_version(), about, long_about = None)] #[command(propagate_version = true)] pub struct SozoArgs { #[arg(long)] diff --git a/crates/katana/rpc/rpc/tests/saya.rs b/crates/katana/rpc/rpc/tests/saya.rs index dd1135c4b2..75de2d3edb 100644 --- a/crates/katana/rpc/rpc/tests/saya.rs +++ b/crates/katana/rpc/rpc/tests/saya.rs @@ -68,33 +68,51 @@ async fn process_sealed_block_only() { client.get_transactions_executions(cursor).await.unwrap(); assert!(response.transactions_executions.is_empty()); - assert!(response.cursor.block_number == 1); - assert!(response.cursor.transaction_index == 0); - assert!(response.cursor.chunk_size == CHUNK_SIZE_DEFAULT); + assert_eq!(response.cursor.block_number, 1); + assert_eq!(response.cursor.transaction_index, 0); + assert_eq!(response.cursor.chunk_size, CHUNK_SIZE_DEFAULT); - let _declare_res = account.declare(contract.clone(), compiled_class_hash).send().await.unwrap(); + let declare_res = account.declare(contract.clone(), compiled_class_hash).send().await.unwrap(); + + let max_retry = 10; + let mut attempt = 0; + loop { + match client.transaction_status(declare_res.transaction_hash).await { + Ok(s) => { + if s != TransactionStatus::Received { + break; + } + } + Err(_) => { + assert!(attempt < max_retry); + sleep(Duration::from_millis(300)).await; + attempt += 1; + } + } + } // Should still return 0 transactions execution for the block 0. let response: TransactionsExecutionsPage = client.get_transactions_executions(cursor).await.unwrap(); assert!(response.transactions_executions.is_empty()); - assert!(response.cursor.block_number == 1); - assert!(response.cursor.transaction_index == 0); - assert!(response.cursor.chunk_size == CHUNK_SIZE_DEFAULT); + assert_eq!(response.cursor.block_number, 1); + assert_eq!(response.cursor.transaction_index, 0); + assert_eq!(response.cursor.chunk_size, CHUNK_SIZE_DEFAULT); // Create block 1. let _: () = client.generate_block().await.unwrap(); // Should now return 1 transaction from the mined block. cursor.block_number = 1; + let response: TransactionsExecutionsPage = client.get_transactions_executions(cursor).await.unwrap(); - assert!(response.transactions_executions.len() == 1); - assert!(response.cursor.block_number == 2); - assert!(response.cursor.transaction_index == 0); - assert!(response.cursor.chunk_size == CHUNK_SIZE_DEFAULT); + assert_eq!(response.transactions_executions.len(), 1); + assert_eq!(response.cursor.block_number, 2); + assert_eq!(response.cursor.transaction_index, 0); + assert_eq!(response.cursor.chunk_size, CHUNK_SIZE_DEFAULT); } #[tokio::test(flavor = "multi_thread")] @@ -160,17 +178,17 @@ async fn executions_chunks_logic_ok() { let response: TransactionsExecutionsPage = client.get_transactions_executions(cursor).await.unwrap(); - assert!(response.transactions_executions.len() == 15); - assert!(response.cursor.block_number == 1); - assert!(response.cursor.transaction_index == 15); + assert_eq!(response.transactions_executions.len(), 15); + assert_eq!(response.cursor.block_number, 1); + assert_eq!(response.cursor.transaction_index, 15); // Should get the remaining 15 transactions and cursor to the next block. let response: TransactionsExecutionsPage = client.get_transactions_executions(response.cursor).await.unwrap(); - assert!(response.transactions_executions.len() == 15); - assert!(response.cursor.block_number == 2); - assert!(response.cursor.transaction_index == 0); + assert_eq!(response.transactions_executions.len(), 15); + assert_eq!(response.cursor.block_number, 2); + assert_eq!(response.cursor.transaction_index, 0); // Create block 2. let _: () = client.generate_block().await.unwrap(); @@ -179,8 +197,8 @@ async fn executions_chunks_logic_ok() { client.get_transactions_executions(response.cursor).await.unwrap(); assert!(response.transactions_executions.is_empty()); - assert!(response.cursor.block_number == 3); - assert!(response.cursor.transaction_index == 0); + assert_eq!(response.cursor.block_number, 3); + assert_eq!(response.cursor.transaction_index, 0); sequencer.stop().expect("failed to stop sequencer"); }