Jelajahi Sumber

Warnings off

Cesar Rodas 1 tahun lalu
induk
melakukan
e5505f0d63

+ 3 - 2
utxo/src/cache.rs

@@ -2,7 +2,7 @@ use crate::{
     amount::AmountCents,
     asset::AssetId,
     changelog::Changelog,
-    storage::{Batch, Error, Storage},
+    storage::{Error, Storage},
     transaction::from_db::Transaction,
     AccountId, Amount, Payment, PaymentId, TransactionId, Type,
 };
@@ -25,6 +25,7 @@ impl<'a, S> Cache<'a, S>
 where
     S: Storage<'a> + Sync + Send,
 {
+    #[allow(unused)]
     pub fn new(storage: S) -> Self {
         Self {
             payments: Arc::new(RwLock::new(HashMap::new())),
@@ -127,7 +128,7 @@ mod test {
         storage_test_suite, tests::deposit, AssetDefinition, AssetManager, Ledger, SQLite, Status,
     };
     use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
-    use std::{fs::remove_file, path::Path};
+    use std::fs::remove_file;
 
     async fn get_instance(assets: AssetManager, test: &str) -> Cache<'static, SQLite<'static>> {
         let path = format!("/tmp/cache-{}.db", test);

+ 1 - 1
utxo/src/sqlite/batch.rs

@@ -1,7 +1,7 @@
 use crate::{
     changelog::Changelog,
     storage::{self, Error},
-    transaction, AccountId, Payment, PaymentId, Status, Transaction, TransactionId,
+    AccountId, Payment, PaymentId, Status, Transaction, TransactionId,
 };
 use serde::{de::DeserializeOwned, Serialize};
 use sqlx::{Row, Sqlite, Transaction as SqlxTransaction};

+ 2 - 2
utxo/src/sqlite/mod.rs

@@ -11,7 +11,7 @@ use crate::{
 use chrono::NaiveDateTime;
 use futures::TryStreamExt;
 use serde::{de::DeserializeOwned, Serialize};
-use sqlx::{pool::PoolConnection, sqlite::SqliteRow, Executor, Row, Sqlite, SqliteConnection};
+use sqlx::{sqlite::SqliteRow, Executor, Row, SqliteConnection};
 use std::{collections::HashMap, marker::PhantomData, ops::Deref};
 
 mod batch;
@@ -623,7 +623,7 @@ mod test {
     use super::*;
     use crate::{storage_test_suite, AssetDefinition};
     use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
-    use std::{fs::remove_file, path::Path};
+    use std::fs::remove_file;
 
     async fn get_instance(assets: AssetManager, test: &str) -> SQLite<'static> {
         let path = format!("/tmp/{}.db", test);

+ 12 - 12
utxo/src/storage.rs

@@ -185,7 +185,7 @@ pub trait Storage<'a> {
 #[cfg(test)]
 pub mod test {
     use super::*;
-    use crate::{payment::SpentInfo, AssetDefinition, AssetManager};
+    use crate::{payment::SpentInfo, AssetManager};
     use rand::Rng;
     use strum::IntoEnumIterator;
 
@@ -236,13 +236,13 @@ pub mod test {
         )
         .expect("valid tx");
         let mut storing = storage.begin().await.expect("valid tx");
-        storing.store_transaction(&deposit).await;
-        storing.rollback().await;
+        storing.store_transaction(&deposit).await.expect("store tx");
+        storing.rollback().await.expect("rollback");
         assert!(storage.get_transaction(&deposit.id()).await.is_err());
 
         let mut storing = storage.begin().await.expect("valid tx");
-        storing.store_transaction(&deposit).await;
-        storing.commit().await;
+        storing.store_transaction(&deposit).await.expect("store tx");
+        storing.commit().await.expect("commit");
         assert!(storage.get_transaction(&deposit.id()).await.is_ok());
     }
 
@@ -262,14 +262,14 @@ pub mod test {
         )
         .expect("valid tx");
         let mut storing = storage.begin().await.expect("valid tx");
-        storing.store_transaction(&deposit).await;
+        storing.store_transaction(&deposit).await.expect("store tx");
         assert!(storage.get_transaction(&deposit.id()).await.is_err());
-        storing.rollback().await;
+        storing.rollback().await.expect("rollback");
         assert!(storage.get_transaction(&deposit.id()).await.is_err());
 
         let mut storing = storage.begin().await.expect("valid tx");
-        storing.store_transaction(&deposit).await;
-        storing.commit().await;
+        storing.store_transaction(&deposit).await.expect("store tx");
+        storing.commit().await.expect("commit");
         assert!(storage.get_transaction(&deposit.id()).await.is_ok());
     }
 
@@ -423,7 +423,7 @@ pub mod test {
         let target_inputs_per_account = 20;
 
         for account in &accounts {
-            for i in 0..target_inputs_per_account {
+            for _ in 0..target_inputs_per_account {
                 let amount = assets
                     .human_amount_by_name("USD", &format!("{}", rng.gen_range(-1000.0..1000.0)))
                     .expect("valid amount");
@@ -491,7 +491,7 @@ pub mod test {
         .expect("valid tx");
 
         let mut batch = storage.begin().await.expect("valid tx");
-        batch.store_transaction(&deposit).await;
+        batch.store_transaction(&deposit).await.expect("is ok");
         batch
             .relate_account_to_transaction(&deposit, &account1)
             .await
@@ -570,7 +570,7 @@ pub mod test {
             .await
             .expect("valid payment");
 
-        writer.commit().await.is_ok();
+        writer.commit().await.expect("is ok");
 
         assert!(storage
             .get_balance(&account)

+ 3 - 4
utxo/src/tests/mod.rs

@@ -1,11 +1,10 @@
 use crate::{
-    asset_manager::AssetDefinition,
-    sqlite::{Batch, SQLite},
-    storage::Storage,
-    AccountId, Amount, AssetManager, Error, Ledger, Status, TransactionId,
+    asset_manager::AssetDefinition, sqlite::SQLite, storage::Storage, AccountId, Amount,
+    AssetManager, Error, Ledger, Status, TransactionId,
 };
 use sqlx::sqlite::SqlitePoolOptions;
 
+#[allow(unused)]
 pub async fn get_file_asset_manager_and_ledger<'a>(
     name: &str,
 ) -> (AssetManager, Ledger<'static, SQLite<'static>>) {

+ 1 - 1
utxo/src/tests/tx.rs

@@ -59,7 +59,7 @@ async fn multi_account_transfers() {
         .id()
         .clone();
 
-    for account in &accounts {
+    for _ in &accounts {
         let txs = ledger
             .get_transactions(&accounts[0], vec![Type::Exchange])
             .await