|
@@ -1,4 +1,6 @@
|
|
|
//! Storage layer trait
|
|
|
+use std::fmt::{self, Display};
|
|
|
+
|
|
|
use crate::{
|
|
|
amount::AmountCents, payment::PaymentTo, transaction::Type, AccountId, Amount, Asset, BaseTx,
|
|
|
Filter, PaymentFrom, PaymentId, ReplayProtection, RevId, Revision, Tag, Transaction, TxId,
|
|
@@ -38,12 +40,16 @@ pub enum AccountTransactionType {
|
|
|
Receives,
|
|
|
}
|
|
|
|
|
|
-impl ToString for AccountTransactionType {
|
|
|
- fn to_string(&self) -> String {
|
|
|
- match self {
|
|
|
- AccountTransactionType::Spends => "spends".to_string(),
|
|
|
- AccountTransactionType::Receives => "receives".to_string(),
|
|
|
- }
|
|
|
+impl Display for AccountTransactionType {
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
+ write!(
|
|
|
+ f,
|
|
|
+ "{}",
|
|
|
+ match self {
|
|
|
+ AccountTransactionType::Spends => "spends".to_string(),
|
|
|
+ AccountTransactionType::Receives => "receives".to_string(),
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1050,7 +1056,9 @@ pub mod test {
|
|
|
.into_iter()
|
|
|
.enumerate()
|
|
|
{
|
|
|
- let transaction_id: TxId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: TxId = vec![u8::try_from(i).expect("valid index"); 32]
|
|
|
+ .try_into()
|
|
|
+ .expect("valid tx id");
|
|
|
|
|
|
writer
|
|
|
.create_payments(
|
|
@@ -1098,7 +1106,9 @@ pub mod test {
|
|
|
.into_iter()
|
|
|
.enumerate()
|
|
|
{
|
|
|
- let transaction_id: TxId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: TxId = vec![u8::try_from(i).expect("valid index"); 32]
|
|
|
+ .try_into()
|
|
|
+ .expect("valid tx id");
|
|
|
|
|
|
writer
|
|
|
.create_payments(
|
|
@@ -1134,6 +1144,7 @@ pub mod test {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #[allow(clippy::arithmetic_side_effects)]
|
|
|
pub async fn payments_always_include_negative_amounts<T>(storage: T)
|
|
|
where
|
|
|
T: Storage + Send + Sync,
|
|
@@ -1150,7 +1161,9 @@ pub mod test {
|
|
|
let mut negative_payments_per_account = HashMap::new();
|
|
|
|
|
|
for (index, account) in accounts.iter().enumerate() {
|
|
|
- let transaction_id: TxId = vec![index as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: TxId = vec![u8::try_from(index).expect("valid index"); 32]
|
|
|
+ .try_into()
|
|
|
+ .expect("valid tx id");
|
|
|
let mut negative_payments: usize = 0;
|
|
|
let recipients = (0..target_inputs_per_account)
|
|
|
.map(|_| {
|