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

Sozo CLI --version displaying more info #1710

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
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
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");
}
Loading