Browse Source

Fix tests

Cesar Rodas 1 month ago
parent
commit
fa6770cb1d

+ 3 - 1
crates/cdk-integration-tests/tests/bolt12.rs

@@ -350,7 +350,9 @@ async fn test_regtest_bolt12_mint_extra() -> Result<()> {
         .await?
         .unwrap();
 
-    let state = wallet.mint_bolt12_quote_state(&mint_quote.id).await?;
+    let mut tx = wallet.localstore.begin_db_transaction().await?;
+    let state = wallet.mint_bolt12_quote_state(&mint_quote.id, &mut tx).await?;
+    tx.commit().await?;
 
     assert_eq!(payment, state.amount_paid);
     assert_eq!(state.amount_paid, (pay_amount_msats / 1_000).into());

+ 8 - 8
crates/cdk-integration-tests/tests/fake_auth.rs

@@ -41,7 +41,7 @@ async fn test_invalid_credentials() {
         .expect("Wallet");
 
     let mint_info = wallet
-        .fetch_mint_info()
+        .fetch_mint_info(None)
         .await
         .expect("mint info")
         .expect("could not get mint info");
@@ -309,7 +309,7 @@ async fn test_mint_with_auth() {
         .expect("Wallet");
 
     let mint_info = wallet
-        .fetch_mint_info()
+        .fetch_mint_info(None)
         .await
         .expect("mint info")
         .expect("could not get mint info");
@@ -516,11 +516,11 @@ async fn test_reuse_auth_proof() {
         assert!(quote.amount == Some(10.into()));
     }
 
-    wallet
-        .localstore
-        .update_proofs(proofs, vec![])
-        .await
-        .unwrap();
+    {
+        let mut tx = wallet.localstore.begin_db_transaction().await.unwrap();
+        tx.update_proofs(proofs, vec![]).await.unwrap();
+        tx.commit().await.unwrap();
+    }
 
     {
         let quote_res = wallet.mint_quote(10.into(), None).await;
@@ -700,7 +700,7 @@ async fn test_auth_token_spending_order() {
         .expect("Wallet");
 
     let mint_info = wallet
-        .fetch_mint_info()
+        .fetch_mint_info(None)
         .await
         .expect("mint info")
         .expect("could not get mint info");

+ 1 - 1
crates/cdk-integration-tests/tests/fake_wallet.rs

@@ -729,7 +729,7 @@ async fn test_fake_mint_multiple_unit_swap() {
     )
     .expect("failed to create new wallet");
 
-    wallet.refresh_keysets().await.unwrap();
+    wallet.refresh_keysets(None).await.unwrap();
 
     let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
 

+ 1 - 1
crates/cdk-integration-tests/tests/happy_path_mint_wallet.rs

@@ -322,7 +322,7 @@ async fn test_restore() {
 
     assert!(!proofs.is_empty());
 
-    let expected_fee = wallet.get_proofs_fee(&proofs).await.unwrap();
+    let expected_fee = wallet.get_proofs_fee(None, &proofs).await.unwrap();
     wallet_2
         .swap(None, None, SplitTarget::default(), proofs, None, false)
         .await

+ 5 - 4
crates/cdk-integration-tests/tests/test_fees.rs

@@ -1,3 +1,4 @@
+use std::collections::HashMap;
 use std::str::FromStr;
 use std::sync::Arc;
 
@@ -52,7 +53,7 @@ async fn test_swap() {
 
     let proofs = send.proofs();
 
-    let fee = wallet.get_proofs_fee(&proofs).await.unwrap();
+    let fee = wallet.get_proofs_fee(None, &proofs).await.unwrap();
 
     assert_eq!(fee, 1.into());
 
@@ -107,17 +108,17 @@ async fn test_fake_melt_change_in_quote() {
 
     let proofs_total = proofs.total_amount().unwrap();
 
-    let fee = wallet.get_proofs_fee(&proofs).await.unwrap();
+    let fee = wallet.get_proofs_fee(None, &proofs).await.unwrap();
 
     let mut tx = wallet.localstore.begin_db_transaction().await.unwrap();
     let melt = wallet
-        .melt_proofs_with_metadata(&melt_quote.id, proofs, HashMap::new())
+        .melt_proofs_with_metadata(&melt_quote.id, proofs, HashMap::new(), &mut tx)
         .await
         .unwrap();
     tx.commit().await.unwrap();
 
     let change = melt.change.unwrap().total_amount().unwrap();
-    let idk = proofs.total_amount().unwrap() - Amount::from(invoice_amount) - change;
+    let idk = proofs_total - Amount::from(invoice_amount) - change;
 
     println!("{}", idk);
     println!("{}", fee);