From ebbafaacd51f02cf7690cb4648552e2d7f52a3f7 Mon Sep 17 00:00:00 2001 From: Elias Tazartes Date: Tue, 19 Dec 2023 16:11:02 +0100 Subject: [PATCH] fix: fix dead code warning --- tests/ethereum_integration.rs | 2 +- tests/starknet_client.rs | 1 + tests/test_utils/eoa.rs | 13 +++++++++++++ tests/test_utils/rpc/mod.rs | 4 ++++ tests/test_utils/sequencer/mod.rs | 3 +++ tests/transaction.rs | 6 +++++- tests/transaction_receipt.rs | 1 + 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/ethereum_integration.rs b/tests/ethereum_integration.rs index 090bfbb8a..71c867fa0 100644 --- a/tests/ethereum_integration.rs +++ b/tests/ethereum_integration.rs @@ -1,7 +1,7 @@ +mod test_utils; use std::convert::TryFrom; use std::sync::Arc; use std::time::Duration; -mod test_utils; use ethers::contract::ContractFactory; use ethers::core::k256::ecdsa::SigningKey; diff --git a/tests/starknet_client.rs b/tests/starknet_client.rs index 924852c01..115f196e3 100644 --- a/tests/starknet_client.rs +++ b/tests/starknet_client.rs @@ -1,3 +1,4 @@ +#[cfg(test)] mod test_utils; use kakarot_rpc::models::felt::Felt252Wrapper; use rstest::*; diff --git a/tests/test_utils/eoa.rs b/tests/test_utils/eoa.rs index 88d176e0c..c60282b92 100644 --- a/tests/test_utils/eoa.rs +++ b/tests/test_utils/eoa.rs @@ -121,6 +121,13 @@ impl KakarotEOA

{ Ok(KakarotEvmContract::new(bytecode, event.data[1], event.data[0])) } + /// Calls a KakarotEvmContract function and returns the Starknet transaction hash + /// The transaction is signed and sent by the EOA + /// The transaction is waited for until it is confirmed + /// + /// allow(dead_code) is used because this function is used in tests, + /// and each test is compiled separately, so the compiler thinks this function is unused + #[allow(dead_code)] pub async fn call_evm_contract( &self, contract: &KakarotEvmContract, @@ -145,6 +152,12 @@ impl KakarotEOA

{ Ok(starknet_tx_hash) } + /// Transfers value to the given address + /// The transaction is signed and sent by the EOA + /// + /// allow(dead_code) is used because this function is used in tests, + /// and each test is compiled separately, so the compiler thinks this function is unused + #[allow(dead_code)] pub async fn transfer(&self, to: Address, value: u128) -> Result { let nonce = self.nonce().await?; let nonce: u64 = nonce.try_into()?; diff --git a/tests/test_utils/rpc/mod.rs b/tests/test_utils/rpc/mod.rs index 43ef69115..ba6dc8d71 100644 --- a/tests/test_utils/rpc/mod.rs +++ b/tests/test_utils/rpc/mod.rs @@ -58,6 +58,10 @@ use super::sequencer::Katana; /// /// } /// ``` +/// +/// allow(dead_code) is used because this function is used in tests, +/// and each test is compiled separately, so the compiler thinks this function is unused +#[allow(dead_code)] pub async fn start_kakarot_rpc_server(katana: &Katana) -> Result<(SocketAddr, ServerHandle), eyre::Report> { let sequencer = katana.sequencer(); let client = katana.client(); diff --git a/tests/test_utils/sequencer/mod.rs b/tests/test_utils/sequencer/mod.rs index c84352f0d..968a02301 100644 --- a/tests/test_utils/sequencer/mod.rs +++ b/tests/test_utils/sequencer/mod.rs @@ -111,6 +111,9 @@ impl Katana { self.eoa.client() } + /// allow(dead_code) is used because this function is used in tests, + /// and each test is compiled separately, so the compiler thinks this function is unused + #[allow(dead_code)] pub const fn sequencer(&self) -> &TestSequencer { &self.sequencer } diff --git a/tests/transaction.rs b/tests/transaction.rs index d5eb3df55..cf4bd9ca8 100644 --- a/tests/transaction.rs +++ b/tests/transaction.rs @@ -1,3 +1,4 @@ +#[cfg(test)] mod test_utils; use kakarot_rpc::models::felt::Felt252Wrapper; @@ -10,6 +11,8 @@ use test_utils::evm_contract::KakarotEvmContract; use test_utils::fixtures::counter; use test_utils::sequencer::Katana; +use crate::test_utils::eoa::KakarotEOA; + #[rstest] #[awt] #[tokio::test(flavor = "multi_thread")] @@ -19,7 +22,8 @@ async fn test_is_kakarot_tx(#[future] counter: (Katana, KakarotEvmContract)) { let counter = counter.1; let client = katana.client(); let eoa = katana.eoa(); - let starknet_tx_hash = eoa.call_evm_contract(&counter, "inc", (), 0).await.expect("Failed to increment counter"); + let starknet_tx_hash = + KakarotEOA::call_evm_contract(eoa, &counter, "inc", (), 0).await.expect("Failed to increment counter"); // Query transaction let tx = client diff --git a/tests/transaction_receipt.rs b/tests/transaction_receipt.rs index ea44e6e80..0e826ab32 100644 --- a/tests/transaction_receipt.rs +++ b/tests/transaction_receipt.rs @@ -1,3 +1,4 @@ +#[cfg(test)] mod test_utils; use crate::test_utils::evm_contract::KakarotEvmContract;