pub struct MockAccountSyncer { /* private fields */ }Expand description
Mock account syncer for snapshot-account strategies.
Implementations§
Source§impl MockAccountSyncer
impl MockAccountSyncer
Sourcepub async fn set_should_fail(&self, should_fail: bool)
pub async fn set_should_fail(&self, should_fail: bool)
Configure whether sync calls should fail.
Sourcepub async fn set_simulated_pnl(&self, pnl: f64)
pub async fn set_simulated_pnl(&self, pnl: f64)
Set the PnL returned by successful sync calls.
Sourcepub async fn set_network_delay(&self, ms: u64)
pub async fn set_network_delay(&self, ms: u64)
Set simulated network delay in milliseconds.
Sourcepub async fn sync_calls(&self) -> Vec<AccountSyncCall>
pub async fn sync_calls(&self) -> Vec<AccountSyncCall>
Return all recorded account sync calls.
Sourcepub async fn last_sync(&self) -> Option<AccountSyncCall>
pub async fn last_sync(&self) -> Option<AccountSyncCall>
Return the latest recorded account sync call.
Sourcepub async fn shutdown_syncs(&self) -> Vec<AccountSyncCall>
pub async fn shutdown_syncs(&self) -> Vec<AccountSyncCall>
Return recorded shutdown sync calls.
Sourcepub async fn assert_shutdown_sync_sent(&self)
pub async fn assert_shutdown_sync_sent(&self)
Assert exactly one shutdown sync was recorded.
Sourcepub async fn assert_periodic_syncs(&self, min_count: usize)
pub async fn assert_periodic_syncs(&self, min_count: usize)
Assert at least min_count non-shutdown syncs were recorded.
Sourcepub async fn sync(
&mut self,
account_state: &AccountState,
stop_bot: bool,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn sync( &mut self, account_state: &AccountState, stop_bot: bool, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Record an account sync call and return the configured mock result.
Sourcepub async fn shutdown_sync(
&mut self,
account_state: &AccountState,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn shutdown_sync( &mut self, account_state: &AccountState, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Record a shutdown account sync call.
Trait Implementations§
Source§impl AccountSync for MockAccountSyncer
impl AccountSync for MockAccountSyncer
Source§fn should_sync(&self) -> bool
fn should_sync(&self) -> bool
Check if it’s time to sync based on interval
Source§fn sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_bot: bool,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_bot: bool,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sync account state to upstream
Source§fn shutdown_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn shutdown_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Perform final sync on shutdown
Source§fn set_metrics_snapshot(
&mut self,
_snapshot: Option<PerformanceMetricsSnapshot>,
)
fn set_metrics_snapshot( &mut self, _snapshot: Option<PerformanceMetricsSnapshot>, )
Set the latest performance metrics snapshot to include in sync metadata.
Auto Trait Implementations§
impl !RefUnwindSafe for MockAccountSyncer
impl !UnwindSafe for MockAccountSyncer
impl Freeze for MockAccountSyncer
impl Send for MockAccountSyncer
impl Sync for MockAccountSyncer
impl Unpin for MockAccountSyncer
impl UnsafeUnpin for MockAccountSyncer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more