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: move anvil account constants to testing utils module #331

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
10 changes: 0 additions & 10 deletions crates/chainio/clients/avsregistry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ pub mod error;
#[allow(dead_code)]
/// Fake avs registry module
pub mod fake_reader;

#[cfg(test)]
pub(crate) mod test_utils {
use alloy::primitives::{address, Address};

pub(crate) const ANVIL_FIRST_PRIVATE_KEY: &str =
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
pub(crate) const ANVIL_SECOND_ADDRESS: Address =
address!("70997970C51812dc3A010C7d01b50e0d17dc79C8");
}
8 changes: 4 additions & 4 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ impl AvsRegistryChainWriter {
mod tests {

use super::AvsRegistryChainWriter;
use crate::test_utils::{ANVIL_FIRST_PRIVATE_KEY, ANVIL_SECOND_ADDRESS};
use alloy::primitives::{Address, Bytes, FixedBytes, U256};
use eigen_common::get_signer;
use eigen_crypto_bls::BlsKeyPair;
Expand All @@ -405,6 +404,7 @@ mod tests {
use eigen_testing_utils::anvil_constants::{
get_operator_state_retriever_address, get_registry_coordinator_address,
};
use eigen_testing_utils::anvil_constants::{FIRST_PRIVATE_KEY, SECOND_ADDRESS};
use eigen_testing_utils::transaction::wait_transaction;
use eigen_utils::rewardsv2::middleware::servicemanagerbase::ServiceManagerBase;
use eigen_utils::slashing::middleware::registrycoordinator::ISlashingRegistryCoordinatorTypes::OperatorSetParam;
Expand Down Expand Up @@ -466,7 +466,7 @@ mod tests {
#[tokio::test]
async fn test_set_rewards_initiator() {
let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await;
let private_key = ANVIL_FIRST_PRIVATE_KEY.to_string();
let private_key = FIRST_PRIVATE_KEY.to_string();
let avs_writer =
build_avs_registry_chain_writer(http_endpoint.clone(), private_key.clone()).await;

Expand All @@ -477,7 +477,7 @@ mod tests {
let event = contract_registry_coordinator.RewardsInitiatorUpdated_filter();
let poller = event.watch().await.unwrap();

let new_rewards_init_address = ANVIL_SECOND_ADDRESS;
let new_rewards_init_address = SECOND_ADDRESS;

let tx_hash = avs_writer
.set_rewards_initiator(new_rewards_init_address)
Expand Down Expand Up @@ -614,7 +614,7 @@ mod tests {
let bls_key =
"1371012690269088913462269866874713266643928125698382731338806296762673180359922"
.to_string();
let private_key = ANVIL_FIRST_PRIVATE_KEY.to_string();
let private_key = FIRST_PRIVATE_KEY.to_string();
let avs_writer =
build_avs_registry_chain_writer(http_endpoint.clone(), private_key.clone()).await;
let quorum_nums = Bytes::from([0]);
Expand Down
11 changes: 4 additions & 7 deletions crates/chainio/clients/elcontracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) mod test_utils {
use eigen_testing_utils::anvil_constants::{
get_allocation_manager_address, get_avs_directory_address, get_delegation_manager_address,
get_erc20_mock_strategy, get_registry_coordinator_address, get_rewards_coordinator_address,
get_strategy_manager_address,
get_strategy_manager_address, FIRST_ADDRESS, FIRST_PRIVATE_KEY,
};
use eigen_utils::{
slashing::core::{
Expand All @@ -42,9 +42,6 @@ pub(crate) mod test_utils {
pub const OPERATOR_PRIVATE_KEY: &str =
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";

pub const ANVIL_FIRST_ADDRESS: Address = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266");
pub const ANVIL_FIRST_PRIVATE_KEY: &str =
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
pub async fn build_el_chain_reader(http_endpoint: String) -> ELChainReader {
let delegation_manager_address =
get_delegation_manager_address(http_endpoint.clone()).await;
Expand Down Expand Up @@ -142,12 +139,12 @@ pub(crate) mod test_utils {
(root, claim)
}

/// The claim can be submitted from [`ANVIL_FIRST_PRIVATE_KEY`]
/// The claim can be submitted from [`FIRST_PRIVATE_KEY`]
pub async fn new_claim(
http_endpoint: &str,
cumulative_earnings: U256,
) -> (FixedBytes<32>, RewardsMerkleClaim) {
let signer = get_signer(ANVIL_FIRST_PRIVATE_KEY, http_endpoint);
let signer = get_signer(FIRST_PRIVATE_KEY, http_endpoint);
let rewards_coordinator_address =
get_rewards_coordinator_address(http_endpoint.to_string()).await;

Expand Down Expand Up @@ -175,7 +172,7 @@ pub(crate) mod test_utils {

// Generate token tree leaf
// For the tree structure, see https://github.com/Layr-Labs/eigenlayer-contracts/blob/a888a1cd1479438dda4b138245a69177b125a973/docs/core/RewardsCoordinator.md#rewards-merkle-tree-structure
let earner_address = ANVIL_FIRST_ADDRESS;
let earner_address = FIRST_ADDRESS;
let token_leaves = vec![TokenTreeMerkleLeaf {
token: token_address,
cumulativeEarnings: cumulative_earnings,
Expand Down
Loading
Loading