use crate::{ storage::{sqlite::SQLite, Storage}, AccountId, Amount, Error, Ledger, RevId, Status, }; use sqlx::sqlite::SqlitePoolOptions; use std::sync::Arc; #[allow(unused)] pub async fn get_file_asset_manager_and_ledger<'a>(name: &str) -> Arc> { let pool = SqlitePoolOptions::new() .max_connections(1) .idle_timeout(None) .max_lifetime(None) .connect(format!("sqlite:///tmp/{}.db", name).as_str()) .await .expect("pool"); let db = SQLite::new(pool); db.setup().await.expect("setup"); Ledger::new(db.into()) } pub async fn get_asset_manager_and_ledger() -> Arc> { let pool = SqlitePoolOptions::new() .max_connections(1) .idle_timeout(None) .max_lifetime(None) .connect(":memory:") .await .expect("pool"); let db = SQLite::new(pool); db.setup().await.expect("setup"); Ledger::new(db.into()) } pub async fn withdrawal( ledger: &Ledger, account_id: &AccountId, status: Status, amount: Amount, ) -> Result { Ok(ledger .withdrawal(account_id, amount, status, "Test".to_owned()) .await? .revision_id .clone()) } pub async fn deposit(ledger: &Ledger, account_id: &AccountId, amount: Amount) -> RevId where S: Storage + Send + Sync, { ledger .deposit( account_id, amount, "settled".into(), vec![], "Test".to_owned(), ) .await .expect("valid tx") .revision_id .clone() } mod deposit; mod negative_deposit; mod tx; mod withdrawal;