Skip to content

Commit

Permalink
Sozo CLI --version displaying more info (#1710)
Browse files Browse the repository at this point in the history
* Creation of fn generate_version that gathers versions of requested tools.

* fix: ensure saya test always wait tx to be executed

* fix: fmt

---------

Co-authored-by: glihm <[email protected]>
  • Loading branch information
2 people authored and kariy committed Mar 28, 2024
1 parent 945b0d3 commit bd3a9cc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
15 changes: 14 additions & 1 deletion bin/sozo/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
56 changes: 37 additions & 19 deletions crates/katana/rpc/rpc/tests/saya.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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();
Expand All @@ -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");
}

0 comments on commit bd3a9cc

Please sign in to comment.