async fn deposit(&mut self) -> Result<(), failure::Error> {
        // Amount of money we need to deposit.
        // Initialize it with the raw amount: only sum of transfers per account.
        // Fees are taken into account below.
        let mut amount_to_deposit =
            self.transfer_size.clone() * BigUint::from(self.n_accounts as u64);

        // Count the fees: we need to provide fee for each of initial transfer transactions,
        // for each funds rotating transaction, and for each withdraw transaction.

        // Sum of fees for one tx per every account.
        let fee_for_all_accounts =
            self.estimated_fee_for_op.clone() * BigUint::from(self.n_accounts as u64);
        // Total amount of cycles is amount of funds rotation cycles + one for initial transfers +
        // one for collecting funds back to the main account.
        amount_to_deposit += fee_for_all_accounts * (self.cycles_amount + 2);
        // Also the fee is required to perform a final withdraw
        amount_to_deposit += self.estimated_fee_for_op.clone();

        let account_balance = self.main_account.eth_acc.eth_balance().await?;
        log::info!(
            "Main account ETH balance: {} ETH",
            format_ether(&account_balance)
        );

        log::info!(
            "Starting depositing phase. Depositing {} ETH to the main account",
            format_ether(&amount_to_deposit)
        );

        // Ensure that account does have enough money.
        if amount_to_deposit > account_balance {
            panic!("Main ETH account does not have enough balance to run the test with the provided config");
        }

        // Deposit funds and wait for operation to be executed.
        deposit_single(&self.main_account, amount_to_deposit, &self.rpc_client).await?;

        log::info!("Deposit sent and verified");

        // Now when deposits are done it is time to update account id.
        self.main_account
            .update_account_id(&self.rpc_client)
            .await?;

        log::info!("Main account ID set");

        // ...and change the main account pubkey.
        // We have to change pubkey after the deposit so we'll be able to use corresponding
        // `zkSync` account.
        let (change_pubkey_tx, eth_sign) = (self.main_account.sign_change_pubkey(), None);
        let mut sent_txs = SentTransactions::new();
        let tx_hash = self.rpc_client.send_tx(change_pubkey_tx, eth_sign).await?;
        sent_txs.add_tx_hash(tx_hash);
        wait_for_verify(sent_txs, self.verify_timeout, &self.rpc_client).await?;

        log::info!("Main account pubkey changed");

        log::info!("Deposit phase completed");

        Ok(())
    }
/// Runs the initial deposit of the money onto the main account.
Runs the initial deposit of the money onto the main account.
Runs the initial deposit of the money onto the main account .
async fn deposit(&mut self) -> Result<(), failure::Error> {
        // Amount of money we need to deposit.
        // Initialize it with the raw amount: only sum of transfers per account.
        // Fees are taken into account below.
        let mut amount_to_deposit =
            self.transfer_size.clone() * BigUint::from(self.n_accounts as u64);
        // Count the fees: we need to provide fee for each of initial transfer transactions,
        // for each funds rotating transaction, and for each withdraw transaction.
        // Sum of fees for one tx per every account.
        let fee_for_all_accounts =
            self.estimated_fee_for_op.clone() * BigUint::from(self.n_accounts as u64);
        // Total amount of cycles is amount of funds rotation cycles + one for initial transfers +
        // one for collecting funds back to the main account.
        amount_to_deposit += fee_for_all_accounts * (self.cycles_amount + 2);
        // Also the fee is required to perform a final withdraw
        amount_to_deposit += self.estimated_fee_for_op.clone();
        let account_balance = self.main_account.eth_acc.eth_balance().await?;
        log::info!(
            "Main account ETH balance: {} ETH",
            format_ether(&account_balance)
        );
        log::info!(
            "Starting depositing phase. Depositing {} ETH to the main account",
            format_ether(&amount_to_deposit)
        );
        // Ensure that account does have enough money.
        if amount_to_deposit > account_balance {
            panic!("Main ETH account does not have enough balance to run the test with the provided config");
        }
        // Deposit funds and wait for operation to be executed.
        deposit_single(&self.main_account, amount_to_deposit, &self.rpc_client).await?;
        log::info!("Deposit sent and verified");
        // Now when deposits are done it is time to update account id.
        self.main_account
            .update_account_id(&self.rpc_client)
            .await?;
        log::info!("Main account ID set");
        // ...and change the main account pubkey.
        // We have to change pubkey after the deposit so we'll be able to use corresponding
        // `zkSync` account.
        let (change_pubkey_tx, eth_sign) = (self.main_account.sign_change_pubkey(), None);
        let mut sent_txs = SentTransactions::new();
        let tx_hash = self.rpc_client.send_tx(change_pubkey_tx, eth_sign).await?;
        sent_txs.add_tx_hash(tx_hash);
        wait_for_verify(sent_txs, self.verify_timeout, &self.rpc_client).await?;
        log::info!("Main account pubkey changed");
        log::info!("Deposit phase completed");
        Ok(())
    }
async fn deposit ( & mut self ) -> Result < ( ) , failure :: Error > { // Amount of money we need to deposit. // Initialize it with the raw amount: only sum of transfers per account. // Fees are taken into account below. let mut amount_to_deposit = self . transfer_size . clone ( ) * BigUint :: from ( self . n_accounts as u64 ) ; // Count the fees: we need to provide fee for each of initial transfer transactions, // for each funds rotating transaction, and for each withdraw transaction. // Sum of fees for one tx per every account. let fee_for_all_accounts = self . estimated_fee_for_op . clone ( ) * BigUint :: from ( self . n_accounts as u64 ) ; // Total amount of cycles is amount of funds rotation cycles + one for initial transfers + // one for collecting funds back to the main account. amount_to_deposit += fee_for_all_accounts * ( self . cycles_amount + 2 ) ; // Also the fee is required to perform a final withdraw amount_to_deposit += self . estimated_fee_for_op . clone ( ) ; let account_balance = self . main_account . eth_acc . eth_balance ( ) . await ? ; log :: info ! ( " " format_ether ( account_balance ) ) ; log :: info ! ( " " format_ether ( amount_to_deposit ) ) ; // Ensure that account does have enough money. if amount_to_deposit > account_balance { panic ! ( " " ) ; } // Deposit funds and wait for operation to be executed. deposit_single ( & self . main_account , amount_to_deposit , & self . rpc_client ) . await ? ; log :: info ! ( " " ) ; // Now when deposits are done it is time to update account id. self . main_account . update_account_id ( & self . rpc_client ) . await ? ; log :: info ! ( " " ) ; // ...and change the main account pubkey. // We have to change pubkey after the deposit so we'll be able to use corresponding // `zkSync` account. let ( change_pubkey_tx , eth_sign ) = ( self . main_account . sign_change_pubkey ( ) , None ) ; let mut sent_txs = SentTransactions :: new ( ) ; let tx_hash = self . rpc_client . send_tx ( change_pubkey_tx , eth_sign ) . await ? ; sent_txs . add_tx_hash ( tx_hash ) ; wait_for_verify ( sent_txs , self . verify_timeout , & self . rpc_client ) . await ? ; log :: info ! ( " " ) ; log :: info ! ( " " ) ; Ok ( ( ) ) }
Runs the initial deposit of the money onto the main account.
Runs the initial deposit of the money onto the main account .
&mut self