forked from Layr-Labs/eigensdk-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avs registry service chain caller tests (Layr-Labs#90)
This PR adds unit tests for `AvsRegistryServiceChainCaller` methods --------- Co-authored-by: tomasarrachea <tomas.arrachea@lambdaclass.com> Co-authored-by: Pablo Deymonnaz <deymonnaz@gmail.com> Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
- Loading branch information
1 parent
dfb1022
commit 76971ad
Showing
20 changed files
with
576 additions
and
180 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use crate::{error::AvsRegistryError, reader::AvsRegistryReader}; | ||
use alloy_primitives::{Address, Bytes, FixedBytes}; | ||
use async_trait::async_trait; | ||
use eigen_crypto_bls::BlsKeyPair; | ||
use eigen_types::test::TestOperator; | ||
use eigen_utils::binding::OperatorStateRetriever; | ||
|
||
const OPERATOR_STAKE: u128 = 123; | ||
|
||
/// This struct is used to test AvsRegistryServiceChainCaller methods. | ||
#[derive(Debug)] | ||
pub struct FakeAvsRegistryReader { | ||
operator_address: Address, | ||
operator_pubkeys: BlsKeyPair, | ||
operator_id: FixedBytes<32>, | ||
} | ||
|
||
impl FakeAvsRegistryReader { | ||
/// Creates a FakeAvsRegistryReader | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `operator` - A TestOperator. | ||
/// * `operator_address` - The operator address. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A FakeAvsRegistryReader | ||
pub fn new(operator: TestOperator, operator_address: Address) -> Self { | ||
Self { | ||
operator_address, | ||
operator_id: operator.operator_id, | ||
operator_pubkeys: operator.bls_keypair, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl AvsRegistryReader for FakeAvsRegistryReader { | ||
async fn get_operators_stake_in_quorums_at_block( | ||
&self, | ||
_block_number: u32, | ||
_quorum_numbers: Bytes, | ||
) -> Result<Vec<Vec<OperatorStateRetriever::Operator>>, AvsRegistryError> { | ||
Ok(vec![vec![OperatorStateRetriever::Operator { | ||
operator: self.operator_address, | ||
operatorId: self.operator_id, | ||
stake: OPERATOR_STAKE, | ||
}]]) | ||
} | ||
|
||
async fn get_check_signatures_indices( | ||
&self, | ||
_reference_block_number: u32, | ||
_quorum_numbers: Vec<u8>, | ||
_non_signer_operator_ids: Vec<FixedBytes<32>>, | ||
) -> Result<OperatorStateRetriever::CheckSignaturesIndices, AvsRegistryError> { | ||
unimplemented!() | ||
} | ||
|
||
async fn get_operator_from_id( | ||
&self, | ||
_operator_id: [u8; 32], | ||
) -> Result<Address, AvsRegistryError> { | ||
Ok(self.operator_address) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.