1use std::time::Duration;
23use crate::{error::SparkSdkError, spark_test_utils::MempoolFaucet, SparkSdk};
4use tokio::time::sleep;
56use super::{polling::poll_for_claim_deposit, DEPOSIT_CONFIRMATION_WAIT};
78/// Helper function to deposit funds for a user and claim them
9/// Returns a Result indicating success or failure
10pub async fn deposit_for_user(
11 sdk: &mut SparkSdk,
12 faucet: &MempoolFaucet,
13 amount: u64,
14) -> Result<(), SparkSdkError> {
15// Get deposit address from the SDK
16let deposit_address_response = sdk.generate_deposit_address().await.unwrap();
17let deposit_address = deposit_address_response.deposit_address;
1819// Broadcast funds to the deposit address using the faucet
20let txid = faucet.make_faucet_request(&deposit_address, amount).await?;
2122// Wait for confirmation and claim the deposit
23sleep(Duration::from_secs(DEPOSIT_CONFIRMATION_WAIT)).await;
2425 poll_for_claim_deposit(sdk, txid).await?;
2627Ok(())
28}