Trait tor_hsservice::ipt_mgr::Mockable

source ·
pub(crate) trait Mockable<R>: Debug + Send + Sync + Sized + 'static {
    type IptEstablisher: Send + Sync + 'static;
    type Rng<'m>: Rng + CryptoRng + 'm;

    // Required methods
    fn thread_rng(&mut self) -> Self::Rng<'_>;
    fn make_new_ipt(
        &mut self,
        imm: &Immutable<R>,
        params: IptParameters
    ) -> Result<(Self::IptEstablisher, Receiver<IptStatus>), FatalError>;
    fn start_accepting(&self, establisher: &(dyn Any + Send + Sync + 'static));
    fn expire_old_ipts_external_persistent_state_hook(&self);
}
Expand description

Mockable state for the IPT Manager

This allows us to use a fake IPT Establisher and IPT Publisher, so that we can unit test the Manager.

Required Associated Types§

source

type IptEstablisher: Send + Sync + 'static

IPT establisher type

source

type Rng<'m>: Rng + CryptoRng + 'm

A random number generator

Required Methods§

source

fn thread_rng(&mut self) -> Self::Rng<'_>

Return a random number generator

source

fn make_new_ipt( &mut self, imm: &Immutable<R>, params: IptParameters ) -> Result<(Self::IptEstablisher, Receiver<IptStatus>), FatalError>

Call IptEstablisher::new

source

fn start_accepting(&self, establisher: &(dyn Any + Send + Sync + 'static))

Call IptEstablisher::start_accepting

source

fn expire_old_ipts_external_persistent_state_hook(&self)

Allow tests to see when IptManager::expire_old_ipts_external_persistent_state is called.

This lets tests see that it gets called at the right times, and not the wrong ones.

Object Safety§

This trait is not object safe.

Implementors§