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

Refactor test utils #102

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ mod tests {
use eigen_crypto_bls::BlsKeyPair;
use eigen_logging::get_test_logger;
use eigen_testing_utils::anvil_constants::{
get_operator_state_retriever_address, get_registry_coordinator_address,
get_transaction_status, ANVIL_HTTP_URL,
get_operator_state_retriever_address, get_registry_coordinator_address, ANVIL_HTTP_URL,
};
use eigen_testing_utils::transaction::get_transaction_status;

async fn build_avs_registry_chain_writer(private_key: String) -> AvsRegistryChainWriter {
let registry_coordinator_address = get_registry_coordinator_address().await;
Expand Down
5 changes: 1 addition & 4 deletions crates/services/bls_aggregation/src/bls_agg_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ pub mod integration_test {
get_erc20_mock_strategy, get_operator_state_retriever_address,
get_registry_coordinator_address, get_service_manager_address,
};
use eigen_types::{
avs::TaskIndex,
operator::{operator_id_from_g1_pub_key, QuorumThresholdPercentages},
};
use eigen_types::{avs::TaskIndex, operator::QuorumThresholdPercentages};
use eigen_utils::{
binding::{
IBLSSignatureChecker::{self, G1Point, NonSignerStakesAndSignature},
Expand Down
26 changes: 2 additions & 24 deletions testing/testing-utils/src/anvil_constants.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//! Anvil utilities
use alloy_network::Ethereum;
use alloy_primitives::{address, Address, FixedBytes};
use alloy_primitives::{address, Address};
use alloy_provider::{
fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller},
Provider, RootProvider,
RootProvider,
};
use alloy_transport_http::{Client, Http};
use eigen_utils::{
binding::ContractsRegistry::{self, contractsReturn},
get_provider,
};
use once_cell::sync::Lazy;
use tokio::time::{sleep, Duration};

/// Local anvil ContractsRegistry which contains a mapping of all locally deployed EL contracts.
pub const CONTRACTS_REGISTRY: Address = address!("5FbDB2315678afecb367f032d93F642f64180aa3");
Expand Down Expand Up @@ -154,24 +153,3 @@ pub async fn get_proxy_admin() -> Address {

address
}

/// Retrieves the status of a transaction from its hash.
///
/// # Arguments
///
/// `tx_hash` - The hash of the transaction.
///
/// # Returns
///
/// A bool indicating wether the transaction was successful or not.
pub async fn get_transaction_status(tx_hash: FixedBytes<32>) -> bool {
// this sleep is needed so that we wait for the tx to be processed
sleep(Duration::from_millis(500)).await;
ANVIL_RPC_URL
.clone()
.get_transaction_receipt(tx_hash)
.await
.unwrap()
.unwrap()
.status()
}
3 changes: 3 additions & 0 deletions testing/testing-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ pub mod m2_holesky_constants;

/// Anvil constants
pub mod anvil_constants;

/// Transaction utilities for testing.
pub mod transaction;
25 changes: 25 additions & 0 deletions testing/testing-utils/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use super::anvil_constants::ANVIL_RPC_URL;
use alloy_primitives::FixedBytes;
use alloy_provider::Provider;
use tokio::time::{sleep, Duration};

/// Retrieves the status of a transaction from its hash.
///
/// # Arguments
///
/// `tx_hash` - The hash of the transaction.
///
/// # Returns
///
/// A bool indicating wether the transaction was successful or not.
pub async fn get_transaction_status(tx_hash: FixedBytes<32>) -> bool {
// this sleep is needed so that we wait for the tx to be processed
sleep(Duration::from_millis(500)).await;
ANVIL_RPC_URL
.clone()
.get_transaction_receipt(tx_hash)
.await
.unwrap()
.unwrap()
.status()
}
Loading