eigen_services_operatorsinfo/
fake_operator_info.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use alloy_primitives::Address;
use async_trait::async_trait;
use eigen_crypto_bls::BlsKeyPair;
use eigen_types::operator::{OperatorInfo, OperatorPubKeys};

use crate::{operator_info::OperatorInfoService, operatorsinfo_inmemory::OperatorInfoServiceError};

/// A fake implementation of the `OperatorInfoService` trait that can be used for testing or debug purposes.
pub struct FakeOperatorInfoService {
    pub pubkeys: OperatorInfo,
    pub socket: String,
}

impl FakeOperatorInfoService {
    pub fn new(pubkeys: BlsKeyPair) -> Self {
        Self {
            pubkeys: OperatorInfo {
                pub_keys: Some(OperatorPubKeys::from(pubkeys)),
            },
            socket: String::default(),
        }
    }
}

#[async_trait]
impl OperatorInfoService for FakeOperatorInfoService {
    async fn get_operator_info(
        &self,
        _address: Address,
    ) -> Result<Option<OperatorPubKeys>, OperatorInfoServiceError> {
        Ok(self.pubkeys.pub_keys.clone())
    }

    async fn get_operator_socket(
        &self,
        _address: Address,
    ) -> Result<Option<String>, OperatorInfoServiceError> {
        Ok(Some(self.socket.clone()))
    }
}