|
@@ -352,6 +352,7 @@ pub mod test {
|
|
$crate::storage_unit_test!(spend_spendable_payments);
|
|
$crate::storage_unit_test!(spend_spendable_payments);
|
|
$crate::storage_unit_test!(relate_account_to_transaction);
|
|
$crate::storage_unit_test!(relate_account_to_transaction);
|
|
$crate::storage_unit_test!(find_transactions_by_tags);
|
|
$crate::storage_unit_test!(find_transactions_by_tags);
|
|
|
|
+ $crate::storage_unit_test!(find_transactions_by_status);
|
|
$crate::storage_unit_test!(not_spendable_new_payments_not_spendable);
|
|
$crate::storage_unit_test!(not_spendable_new_payments_not_spendable);
|
|
$crate::storage_unit_test!(subscribe_realtime);
|
|
$crate::storage_unit_test!(subscribe_realtime);
|
|
};
|
|
};
|
|
@@ -613,7 +614,7 @@ pub mod test {
|
|
status: Default::default(),
|
|
status: Default::default(),
|
|
});
|
|
});
|
|
|
|
|
|
- let mut subscription = ledger
|
|
|
|
|
|
+ let (_, mut subscription) = ledger
|
|
.subscribe(Filter {
|
|
.subscribe(Filter {
|
|
tags: vec!["even".parse().expect("valid tag")],
|
|
tags: vec!["even".parse().expect("valid tag")],
|
|
..Default::default()
|
|
..Default::default()
|
|
@@ -797,6 +798,75 @@ pub mod test {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ pub async fn find_transactions_by_status<T>(storage: T)
|
|
|
|
+ where
|
|
|
|
+ T: Storage + Send + Sync,
|
|
|
|
+ {
|
|
|
|
+ let ledger = Ledger::new(Config {
|
|
|
|
+ storage,
|
|
|
|
+ status: Default::default(),
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ for i in 0..10 {
|
|
|
|
+ let usd: Asset = "USD/2".parse().expect("valid asset");
|
|
|
|
+ let account = format!("account-{}", i).parse().expect("valid account");
|
|
|
|
+
|
|
|
|
+ ledger
|
|
|
|
+ .deposit(
|
|
|
|
+ &account,
|
|
|
|
+ usd.from_human("100.99").expect("valid amount"),
|
|
|
|
+ if i % 2 == 0 {
|
|
|
|
+ "even".into()
|
|
|
|
+ } else {
|
|
|
|
+ "odd".into()
|
|
|
|
+ },
|
|
|
|
+ vec![],
|
|
|
|
+ format!("test deposit {}", i),
|
|
|
|
+ )
|
|
|
|
+ .await
|
|
|
|
+ .expect("valid deposit");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ assert_eq!(
|
|
|
|
+ 5,
|
|
|
|
+ ledger
|
|
|
|
+ .get_transactions(Filter {
|
|
|
|
+ status: vec!["even".parse().expect("valid tag")],
|
|
|
|
+ ..Default::default()
|
|
|
|
+ })
|
|
|
|
+ .await
|
|
|
|
+ .expect("valid filter")
|
|
|
|
+ .len()
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ assert_eq!(
|
|
|
|
+ 5,
|
|
|
|
+ ledger
|
|
|
|
+ .get_transactions(Filter {
|
|
|
|
+ status: vec!["odd".parse().expect("valid tag")],
|
|
|
|
+ ..Default::default()
|
|
|
|
+ })
|
|
|
|
+ .await
|
|
|
|
+ .expect("valid filter")
|
|
|
|
+ .len()
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ assert_eq!(
|
|
|
|
+ 10,
|
|
|
|
+ ledger
|
|
|
|
+ .get_transactions(Filter {
|
|
|
|
+ status: vec![
|
|
|
|
+ "even".parse().expect("valid tag"),
|
|
|
|
+ "odd".parse().expect("valid tag")
|
|
|
|
+ ],
|
|
|
|
+ ..Default::default()
|
|
|
|
+ })
|
|
|
|
+ .await
|
|
|
|
+ .expect("valid filter")
|
|
|
|
+ .len()
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
pub async fn spend_spendable_payments<T>(storage: T)
|
|
pub async fn spend_spendable_payments<T>(storage: T)
|
|
where
|
|
where
|
|
T: Storage + Send + Sync,
|
|
T: Storage + Send + Sync,
|