Skip to content

Commit

Permalink
clippy and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrobles92 committed May 5, 2024
1 parent 1a5f775 commit fd99511
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
26 changes: 13 additions & 13 deletions crates/katana/rpc/rpc/tests/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -203,7 +201,7 @@ 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, "crates/katana/rpc/rpc/tests/test_data/cairo_l1_msg_contract.json");

#[tokio::test(flavor = "multi_thread")]
async fn test_messaging_l1_l2() {
Expand Down Expand Up @@ -273,11 +271,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);

Expand Down Expand Up @@ -354,7 +354,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),
)
Expand All @@ -376,7 +376,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();
Expand Down
29 changes: 12 additions & 17 deletions crates/katana/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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<
Expand Down

0 comments on commit fd99511

Please sign in to comment.