fn ensure_expected_balance_after_block(
        &self,
        client: &mut Client,
        block_index: BlockIndex,
        expected_balance: u64,
    ) -> Result<(), TestClientError> {
        let start = Instant::now();
        let mut deadline = Some(start + self.policy.tx_receive_deadline);

        loop {
            let (new_balance, new_block_count) = client
                .check_balance()
                .map_err(TestClientError::CheckBalance)?;

            // Wait for client cursor to include the index where the transaction landed.
            if u64::from(new_block_count) > block_index {
                log::debug!(
                    self.logger,
                    "Txo cursor now {} > block_index {}, after {:?}",
                    new_block_count,
                    block_index,
                    start.elapsed()
                );
                log::debug!(
                    self.logger,
                    "Expected balance: {:?}, and got: {:?}",
                    expected_balance,
                    new_balance
                );
                if expected_balance != new_balance {
                    return Err(TestClientError::BadBalance(expected_balance, new_balance));
                }
                log::info!(self.logger, "Successful transfer");
                return Ok(());
            }
            deadline = if let Some(deadline) = deadline {
                if Instant::now() > deadline {
                    counters::TX_RECEIVED_DEADLINE_EXCEEDED_COUNT.inc();
                    if self.policy.fail_fast_on_deadline {
                        return Err(TestClientError::TxTimeout);
                    }
                    None
                } else {
                    Some(deadline)
                }
            } else {
                None
            };

            log::trace!(
                self.logger,
                "num_blocks = {} but tx expected in block index = {}, retry in {:?}...",
                new_block_count,
                block_index,
                self.policy.polling_wait
            );
            std::thread::sleep(self.policy.polling_wait);
        }
    }
/// Ensure that after all fog servers have caught up and the client has data
/// up to a certain number of blocks, the client computes the expected
/// balance.
///
/// Arguments:
/// * block_index: The block_index containing new transactions that must be
///   in the balance
/// * expected_balance: The expected balance to compute after this
///   block_index is included
Ensure that after all fog servers have caught up and the client has data
up to a certain number of blocks, the client computes the expected
balance.

The block_index containing new transactions that must be
in the balance
expected_balance: The expected balance to compute after this
block_index is included
Ensure that after all fog servers have caught up and the client has data up to a certain number of blocks the client computes the expected balance . The block_index containing new transactions that must be in the balance expected_balance : The expected balance to compute after this block_index is included
fn ensure_expected_balance_after_block(
        &self,
        client: &mut Client,
        block_index: BlockIndex,
        expected_balance: u64,
    ) -> Result<(), TestClientError> {
        let start = Instant::now();
        let mut deadline = Some(start + self.policy.tx_receive_deadline);
        loop {
            let (new_balance, new_block_count) = client
                .check_balance()
                .map_err(TestClientError::CheckBalance)?;
            // Wait for client cursor to include the index where the transaction landed.
            if u64::from(new_block_count) > block_index {
                log::debug!(
                    self.logger,
                    "Txo cursor now {} > block_index {}, after {:?}",
                    new_block_count,
                    block_index,
                    start.elapsed()
                );
                log::debug!(
                    self.logger,
                    "Expected balance: {:?}, and got: {:?}",
                    expected_balance,
                    new_balance
                );
                if expected_balance != new_balance {
                    return Err(TestClientError::BadBalance(expected_balance, new_balance));
                }
                log::info!(self.logger, "Successful transfer");
                return Ok(());
            }
            deadline = if let Some(deadline) = deadline {
                if Instant::now() > deadline {
                    counters::TX_RECEIVED_DEADLINE_EXCEEDED_COUNT.inc();
                    if self.policy.fail_fast_on_deadline {
                        return Err(TestClientError::TxTimeout);
                    }
                    None
                } else {
                    Some(deadline)
                }
            } else {
                None
            };
            log::trace!(
                self.logger,
                "num_blocks = {} but tx expected in block index = {}, retry in {:?}...",
                new_block_count,
                block_index,
                self.policy.polling_wait
            );
            std::thread::sleep(self.policy.polling_wait);
        }
    }
fn ensure_expected_balance_after_block ( & self , client : & mut Client , block_index : BlockIndex , expected_balance : u64 , ) -> Result < ( ) , TestClientError > { let start = Instant :: now ( ) ; let mut deadline = Some ( start + self . policy . tx_receive_deadline ) ; loop { let ( new_balance , new_block_count ) = client . check_balance ( ) . map_err ( TestClientError :: CheckBalance ) ? ; // Wait for client cursor to include the index where the transaction landed. if u64 :: from ( new_block_count ) > block_index { log :: debug ! ( self logger " " new_block_count block_index start elapsed ( ) ) ; log :: debug ! ( self logger " " expected_balance new_balance ) ; if expected_balance != new_balance { return Err ( TestClientError :: BadBalance ( expected_balance , new_balance ) ) ; } log :: info ! ( self logger " " ) ; return Ok ( ( ) ) ; } deadline = if let Some ( deadline ) = deadline { if Instant :: now ( ) > deadline { counters :: TX_RECEIVED_DEADLINE_EXCEEDED_COUNT . inc ( ) ; if self . policy . fail_fast_on_deadline { return Err ( TestClientError :: TxTimeout ) ; } None } else { Some ( deadline ) } } else { None } ; log :: trace ! ( self logger " " new_block_count block_index self policy polling_wait ) ; std :: thread :: sleep ( self . policy . polling_wait ) ; } }
Ensure that after all fog servers have caught up and the client has data
up to a certain number of blocks, the client computes the expected
balance.
Ensure that after all fog servers have caught up and the client has data up to a certain number of blocks the client computes the expected balance .
&self
client
&mut Client
block_index
BlockIndex
expected_balance
u64
&self
client
&mut Client
block_index
BlockIndex
expected_balance
u64