Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
fix: fix dead code warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Eikix committed Dec 19, 2023
1 parent 9533358 commit ebbafaa
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/ethereum_integration.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/starknet_client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(test)]
mod test_utils;
use kakarot_rpc::models::felt::Felt252Wrapper;
use rstest::*;
Expand Down
13 changes: 13 additions & 0 deletions tests/test_utils/eoa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ impl<P: Provider + Send + Sync> KakarotEOA<P> {
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<T: Tokenize>(
&self,
contract: &KakarotEvmContract,
Expand All @@ -145,6 +152,12 @@ impl<P: Provider + Send + Sync> KakarotEOA<P> {
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<H256, eyre::Error> {
let nonce = self.nonce().await?;
let nonce: u64 = nonce.try_into()?;
Expand Down
4 changes: 4 additions & 0 deletions tests/test_utils/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions tests/test_utils/sequencer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 5 additions & 1 deletion tests/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(test)]
mod test_utils;

use kakarot_rpc::models::felt::Felt252Wrapper;
Expand All @@ -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")]
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/transaction_receipt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(test)]
mod test_utils;

use crate::test_utils::evm_contract::KakarotEvmContract;
Expand Down

0 comments on commit ebbafaa

Please sign in to comment.