diff --git a/crates/katana/rpc/rpc/tests/starknet.rs b/crates/katana/rpc/rpc/tests/starknet.rs index 3b568f2897..82147047f5 100644 --- a/crates/katana/rpc/rpc/tests/starknet.rs +++ b/crates/katana/rpc/rpc/tests/starknet.rs @@ -5,12 +5,14 @@ use std::str::FromStr; use std::sync::Arc; use std::time::Duration; +use alloy::primitives::{Address, Uint, U256}; +use alloy::sol; use cainome::cairo_serde::EthAddress; use cainome::rs::abigen; - use dojo_test_utils::sequencer::{get_default_test_starknet_config, TestSequencer}; use dojo_world::utils::TransactionWaiter; use katana_core::sequencer::SequencerConfig; +use katana_runner::{AnvilRunner, KatanaRunner, KatanaRunnerConfig}; use serde_json::json; use starknet::accounts::{Account, Call, ConnectedAccount}; use starknet::contract::ContractFactory; @@ -24,10 +26,6 @@ use starknet::macros::felt; use starknet::providers::Provider; use tempfile::tempdir; -use alloy::primitives::{Address, Uint, U256}; -use alloy::sol; -use katana_runner::{AnvilRunner, KatanaRunner, KatanaRunnerConfig}; - mod common; const WAIT_TX_DELAY_MILLIS: u64 = 1000; @@ -203,7 +201,11 @@ sol!( "tests/test_data/solidity/Contract1Compiled.json" ); -abigen!(CairoMessagingContract, "/Users/fabrobles/Fab/dojo_fork/crates/katana/rpc/rpc/tests/test_data/cairo_l1_msg_contract.json"); +abigen!( + CairoMessagingContract, + "/Users/fabrobles/Fab/dojo_fork/crates/katana/rpc/rpc/tests/test_data/cairo_l1_msg_contract.\ + json" +); #[tokio::test(flavor = "multi_thread")] async fn test_messaging_l1_l2() { @@ -273,11 +275,13 @@ async fn test_messaging_l1_l2() { // successfully assert_eq!(receipt.finality_status(), &TransactionFinalityStatus::AcceptedOnL2); - assert!(starknet_account - .provider() - .get_class(BlockId::Tag(BlockTag::Latest), class_hash) - .await - .is_ok()); + assert!( + starknet_account + .provider() + .get_class(BlockId::Tag(BlockTag::Latest), class_hash) + .await + .is_ok() + ); let contract_factory = ContractFactory::new(class_hash, &starknet_account); @@ -354,7 +358,7 @@ async fn test_messaging_l1_l2() { let tx = cairo_messaging_contract .send_message_value( &EthAddress::from( - FieldElement::from_str(&contract_c1.address().to_string().as_str()).unwrap(), + FieldElement::from_str(contract_c1.address().to_string().as_str()).unwrap(), ), &FieldElement::from(2u8), ) @@ -376,7 +380,7 @@ async fn test_messaging_l1_l2() { .gas(12000000) .nonce(4); - //Wait for the message to reach L1 + // Wait for the message to reach L1 tokio::time::sleep(Duration::from_millis(8000)).await; let tx_receipt = builder.send().await.unwrap().get_receipt().await.unwrap(); diff --git a/crates/katana/runner/src/lib.rs b/crates/katana/runner/src/lib.rs index 1c0e16fa58..0903818393 100644 --- a/crates/katana/runner/src/lib.rs +++ b/crates/katana/runner/src/lib.rs @@ -9,8 +9,18 @@ use std::sync::mpsc::{self}; use std::thread; use std::time::Duration; +use alloy::network::{Ethereum, EthereumSigner}; +use alloy::primitives::Address; +use alloy::providers::fillers::{ + ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller, +}; +use alloy::providers::{Identity, ProviderBuilder, RootProvider}; +use alloy::signers::wallet::LocalWallet; +use alloy::transports::http::Http; use anyhow::{Context, Result}; use assert_fs::TempDir; +use hyper::http::request; +use hyper::{Client as HyperClient, Response, StatusCode}; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::allocation::{DevAllocationsGenerator, DevGenesisAccount}; use katana_primitives::FieldElement; @@ -23,17 +33,6 @@ use tokio::time; use url::Url; use utils::find_free_port; -use alloy::network::{Ethereum, EthereumSigner}; -use alloy::primitives::Address; -use alloy::providers::fillers::{ - ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller, -}; -use alloy::providers::{Identity, ProviderBuilder, RootProvider}; -use alloy::signers::wallet::LocalWallet; -use alloy::transports::http::Http; -use hyper::http::request; -use hyper::{Client as HyperClient, Response, StatusCode}; - #[derive(Debug)] pub struct KatanaRunner { child: Child, @@ -115,7 +114,7 @@ impl KatanaRunner { } if let Some(messaging_file) = config.messaging { - command.args(["--messaging", &format!("{}", messaging_file)]); + command.args(["--messaging", messaging_file.as_str()]); } let mut child = @@ -206,11 +205,7 @@ impl Drop for KatanaRunner { /// Determines the default program path for the katana runner based on the KATANA_RUNNER_BIN /// environment variable. If not set, try to to use katana from the PATH. fn determine_default_program_path() -> String { - if let Ok(bin) = std::env::var("KATANA_RUNNER_BIN") { - bin - } else { - "katana".to_string() - } + if let Ok(bin) = std::env::var("KATANA_RUNNER_BIN") { bin } else { "katana".to_string() } } type Provider = FillProvider<