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

Improve Katana runner macro #2464

Merged
merged 14 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
88 changes: 46 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ members = [
"crates/katana/rpc/rpc-types",
"crates/katana/rpc/rpc-types-builder",
"crates/katana/runner",
"crates/katana/runner/runner-macro",
"crates/katana/runner/macro",
"crates/katana/storage/codecs",
"crates/katana/storage/codecs/derive",
"crates/katana/storage/db",
Expand Down Expand Up @@ -86,6 +86,7 @@ katana-core = { path = "crates/katana/core", default-features = false }
katana-db = { path = "crates/katana/storage/db" }
katana-executor = { path = "crates/katana/executor" }
katana-node = { path = "crates/katana/node", default-features = false }
katana-node-bindings = { path = "crates/katana/node-bindings" }
katana-pool = { path = "crates/katana/pool" }
katana-primitives = { path = "crates/katana/primitives" }
katana-provider = { path = "crates/katana/storage/provider" }
Expand Down
11 changes: 7 additions & 4 deletions bin/sozo/src/commands/options/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl AccountOptions {
#[cfg(test)]
mod tests {
use clap::Parser;
use katana_runner::RunnerCtx;
use starknet::accounts::ExecutionEncoder;
use starknet::core::types::Call;
use starknet_crypto::Felt;
Expand Down Expand Up @@ -211,8 +212,9 @@ mod tests {
assert!(cmd.account.account_address(None).is_err());
}

#[katana_runner::katana_test(2, true)]
async fn legacy_flag_works_as_expected() {
#[tokio::test]
#[katana_runner::test(accounts = 2, fee = false)]
async fn legacy_flag_works_as_expected(runner: &RunnerCtx) {
let cmd = Command::parse_from([
"sozo",
"--legacy",
Expand All @@ -235,8 +237,9 @@ mod tests {
assert!(*result.get(3).unwrap() == Felt::from_hex("0x0").unwrap());
}

#[katana_runner::katana_test(2, true)]
async fn without_legacy_flag_works_as_expected() {
#[tokio::test]
#[katana_runner::test(accounts = 2, fee = false)]
async fn without_legacy_flag_works_as_expected(runner: &RunnerCtx) {
let cmd = Command::parse_from(["sozo", "--account-address", "0x0", "--private-key", "0x1"]);
let dummy_call = vec![Call {
to: Felt::from_hex("0x0").unwrap(),
Expand Down
6 changes: 4 additions & 2 deletions bin/sozo/tests/test_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod utils;
use std::fs;

use assert_fs::fixture::PathChild;
use katana_runner::RunnerCtx;
use sozo_ops::account;
use starknet::accounts::Account;
use utils::snapbox::get_snapbox;
Expand All @@ -29,8 +30,9 @@ fn test_account_new() {
assert!(pt.child("account.json").exists());
}

#[katana_runner::katana_test(1, true)]
async fn test_account_fetch() {
#[tokio::test]
#[katana_runner::test(accounts = 2, fee = false)]
async fn test_account_fetch(runner: &RunnerCtx) {
let pt = assert_fs::TempDir::new().unwrap();

account::fetch(
Expand Down
5 changes: 3 additions & 2 deletions crates/katana/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
katana-node-bindings.workspace = true
katana-runner-macro = { path = "macro" }

anyhow.workspace = true
assert_fs.workspace = true
chrono.workspace = true
katana-node-bindings = { path = "../node-bindings" }
runner-macro = { path = "./runner-macro" }
serde.workspace = true
serde_json.workspace = true
starknet.workspace = true
Expand Down
16 changes: 16 additions & 0 deletions crates/katana/runner/macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
edition.workspace = true
name = "katana-runner-macro"
version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
proc-macro = true

[dependencies]
proc-macro2 = "1.0.86"
quote = "1.0"
syn = { version = "2.0", features = [ "fold", "full" ] }

[dev-dependencies]
starknet.workspace = true
Loading
Loading