|
@@ -15,6 +15,7 @@
|
|
|
//! - Duplicate proof detection
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
+use std::time::Duration;
|
|
|
|
|
|
use bip39::Mnemonic;
|
|
|
use cashu::Amount;
|
|
@@ -27,7 +28,7 @@ use cdk::nuts::{
|
|
|
use cdk::wallet::types::TransactionDirection;
|
|
|
use cdk::wallet::{HttpClient, MintConnector, Wallet};
|
|
|
use cdk_fake_wallet::{create_fake_invoice, FakeInvoiceDescription};
|
|
|
-use cdk_integration_tests::{attempt_to_swap_pending, wait_for_mint_to_be_paid};
|
|
|
+use cdk_integration_tests::attempt_to_swap_pending;
|
|
|
use cdk_sqlite::wallet::memory;
|
|
|
|
|
|
const MINT_URL: &str = "http://127.0.0.1:8086";
|
|
@@ -46,7 +47,8 @@ async fn test_fake_tokens_pending() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -88,7 +90,8 @@ async fn test_fake_melt_payment_fail() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -153,7 +156,8 @@ async fn test_fake_melt_payment_fail_and_check() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -201,7 +205,8 @@ async fn test_fake_melt_payment_return_fail_status() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -264,7 +269,8 @@ async fn test_fake_melt_payment_error_unknown() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -327,7 +333,8 @@ async fn test_fake_melt_payment_err_paid() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -368,7 +375,8 @@ async fn test_fake_melt_change_in_quote() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -437,7 +445,8 @@ async fn test_fake_mint_with_witness() {
|
|
|
.expect("failed to create new wallet");
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -465,7 +474,8 @@ async fn test_fake_mint_without_witness() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -505,7 +515,8 @@ async fn test_fake_mint_with_wrong_witness() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -551,7 +562,8 @@ async fn test_fake_mint_inflated() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -609,7 +621,8 @@ async fn test_fake_mint_multiple_units() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -688,7 +701,8 @@ async fn test_fake_mint_multiple_unit_swap() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -709,7 +723,8 @@ async fn test_fake_mint_multiple_unit_swap() {
|
|
|
|
|
|
let mint_quote = wallet_usd.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet_usd, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -802,7 +817,8 @@ async fn test_fake_mint_multiple_unit_melt() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -825,7 +841,8 @@ async fn test_fake_mint_multiple_unit_melt() {
|
|
|
let mint_quote = wallet_usd.mint_quote(100.into(), None).await.unwrap();
|
|
|
println!("Minted quote usd");
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet_usd, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -920,7 +937,8 @@ async fn test_fake_mint_input_output_mismatch() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -978,7 +996,8 @@ async fn test_fake_mint_swap_inflated() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -1022,7 +1041,8 @@ async fn test_fake_mint_swap_spend_after_fail() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -1093,7 +1113,8 @@ async fn test_fake_mint_melt_spend_after_fail() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -1165,7 +1186,8 @@ async fn test_fake_mint_duplicate_proofs_swap() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
@@ -1245,7 +1267,8 @@ async fn test_fake_mint_duplicate_proofs_melt() {
|
|
|
|
|
|
let mint_quote = wallet.mint_quote(100.into(), None).await.unwrap();
|
|
|
|
|
|
- wait_for_mint_to_be_paid(&wallet, &mint_quote.id, 60)
|
|
|
+ wallet
|
|
|
+ .wait_for_payment(&mint_quote, Duration::from_secs(60))
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|