|  | @@ -0,0 +1,70 @@
 | 
	
		
			
				|  |  | +use super::{deposit, get_instance, get_persistance_instance};
 | 
	
		
			
				|  |  | +use crate::{AccountId, Status, Type};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#[tokio::test]
 | 
	
		
			
				|  |  | +async fn multi_account_transfers() {
 | 
	
		
			
				|  |  | +    let accounts = (0..100)
 | 
	
		
			
				|  |  | +        .into_iter()
 | 
	
		
			
				|  |  | +        .map(|i| format!("account{}", i).parse::<AccountId>())
 | 
	
		
			
				|  |  | +        .collect::<Result<Vec<AccountId>, _>>()
 | 
	
		
			
				|  |  | +        .expect("valid");
 | 
	
		
			
				|  |  | +    let target = "target".parse::<AccountId>().expect("target account");
 | 
	
		
			
				|  |  | +    let (assets, ledger) = get_instance().await;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    for account in &accounts {
 | 
	
		
			
				|  |  | +        deposit(
 | 
	
		
			
				|  |  | +            &ledger,
 | 
	
		
			
				|  |  | +            &account,
 | 
	
		
			
				|  |  | +            assets.amount_by_and_cents(2, 100000).expect("amount"),
 | 
	
		
			
				|  |  | +        )
 | 
	
		
			
				|  |  | +        .await;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    let mut from = vec![];
 | 
	
		
			
				|  |  | +    for (p, account) in (&accounts).iter().enumerate() {
 | 
	
		
			
				|  |  | +        assert_eq!(
 | 
	
		
			
				|  |  | +            vec![assets.amount_by_and_cents(2, 100_000).expect("amount")],
 | 
	
		
			
				|  |  | +            ledger.get_balance(&account).await.expect("balance")
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +        from.push((
 | 
	
		
			
				|  |  | +            account.clone(),
 | 
	
		
			
				|  |  | +            assets
 | 
	
		
			
				|  |  | +                .amount_by_and_cents(2, 1000 * ((p + 1) as i128))
 | 
	
		
			
				|  |  | +                .expect("amount"),
 | 
	
		
			
				|  |  | +        ));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    ledger
 | 
	
		
			
				|  |  | +        .new_transaction(
 | 
	
		
			
				|  |  | +            "test tx".to_owned(),
 | 
	
		
			
				|  |  | +            Status::Settled,
 | 
	
		
			
				|  |  | +            from,
 | 
	
		
			
				|  |  | +            vec![(
 | 
	
		
			
				|  |  | +                target.clone(),
 | 
	
		
			
				|  |  | +                assets.amount_by_and_cents(2, 5_050_000).expect("amount"),
 | 
	
		
			
				|  |  | +            )],
 | 
	
		
			
				|  |  | +        )
 | 
	
		
			
				|  |  | +        .await
 | 
	
		
			
				|  |  | +        .expect("valid tx");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    assert_eq!(
 | 
	
		
			
				|  |  | +        vec![assets.amount_by_and_cents(2, 5_050_000).expect("amount")],
 | 
	
		
			
				|  |  | +        ledger.get_balance(&target).await.expect("balance")
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    let exchange_id = ledger
 | 
	
		
			
				|  |  | +        .get_transactions(&accounts[0], vec![Type::Exchange])
 | 
	
		
			
				|  |  | +        .await
 | 
	
		
			
				|  |  | +        .expect("valid")[0]
 | 
	
		
			
				|  |  | +        .id()
 | 
	
		
			
				|  |  | +        .clone();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    for account in &accounts {
 | 
	
		
			
				|  |  | +        let txs = ledger
 | 
	
		
			
				|  |  | +            .get_transactions(&accounts[0], vec![Type::Exchange])
 | 
	
		
			
				|  |  | +            .await
 | 
	
		
			
				|  |  | +            .expect("valid");
 | 
	
		
			
				|  |  | +        assert_eq!(1, txs.len());
 | 
	
		
			
				|  |  | +        assert_eq!(exchange_id, *txs[0].id());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 |