Forráskód Böngészése

Remove redb from the tests

Cesar Rodas 6 hónapja
szülő
commit
19218a1cc3

+ 1 - 1
crates/cdk-common/src/database/mint/mod.rs

@@ -67,7 +67,7 @@ pub trait QuotesTransaction<'a> {
     async fn get_mint_quote(&mut self, quote_id: &Uuid)
         -> Result<Option<MintMintQuote>, Self::Err>;
     /// Add [`MintMintQuote`]
-    async fn add_mint_quote(&mut self, quote: MintMintQuote) -> Result<(), Self::Err>;
+    async fn add_or_replace_mint_quote(&mut self, quote: MintMintQuote) -> Result<(), Self::Err>;
     /// Update state of [`MintMintQuote`]
     async fn update_mint_quote_state(
         &mut self,

+ 10 - 2
crates/cdk-mint-rpc/src/proto/server.rs

@@ -655,8 +655,16 @@ impl CdkMint for MintRPCServer {
 
                 mint_quote.state = state;
 
-                self.mint
-                    .update_mint_quote(mint_quote)
+                let mut tx = self
+                    .mint
+                    .localstore
+                    .begin_transaction()
+                    .await
+                    .map_err(|_| Status::internal("Could not update quote".to_string()))?;
+                tx.add_or_replace_mint_quote(mint_quote)
+                    .await
+                    .map_err(|_| Status::internal("Could not update quote".to_string()))?;
+                tx.commit()
                     .await
                     .map_err(|_| Status::internal("Could not update quote".to_string()))?;
             }

+ 1 - 1
crates/cdk-sqlite/src/mint/memory.rs

@@ -44,7 +44,7 @@ pub async fn new_with_state(
     let mut tx = MintDatabase::begin_transaction(&db).await?;
 
     for quote in mint_quotes {
-        tx.add_mint_quote(quote).await?;
+        tx.add_or_replace_mint_quote(quote).await?;
     }
 
     for quote in melt_quotes {

+ 1 - 1
crates/cdk-sqlite/src/mint/mod.rs

@@ -311,7 +311,7 @@ impl MintKeysDatabase for MintSqliteDatabase {
 impl<'a> MintQuotesTransaction<'a> for SqliteTransaction<'a> {
     type Err = database::Error;
 
-    async fn add_mint_quote(&mut self, quote: MintQuote) -> Result<(), Self::Err> {
+    async fn add_or_replace_mint_quote(&mut self, quote: MintQuote) -> Result<(), Self::Err> {
         query(
             r#"
                 INSERT OR REPLACE INTO mint_quote (

+ 1 - 10
crates/cdk/src/mint/issue/issue_nut04.rs

@@ -106,7 +106,7 @@ impl Mint {
         );
 
         let mut tx = self.localstore.begin_transaction().await?;
-        tx.add_mint_quote(quote.clone()).await?;
+        tx.add_or_replace_mint_quote(quote.clone()).await?;
         tx.commit().await?;
 
         let quote: MintQuoteBolt11Response<Uuid> = quote.into();
@@ -148,15 +148,6 @@ impl Mint {
         })
     }
 
-    /// Update mint quote
-    #[instrument(skip_all)]
-    pub async fn update_mint_quote(&self, quote: MintQuote) -> Result<(), Error> {
-        let mut tx = self.localstore.begin_transaction().await?;
-        tx.add_mint_quote(quote).await?;
-        tx.commit().await?;
-        Ok(())
-    }
-
     /// Get mint quotes
     #[instrument(skip_all)]
     pub async fn mint_quotes(&self) -> Result<Vec<MintQuote>, Error> {

+ 2 - 1
crates/cdk/src/mint/mod.rs

@@ -420,6 +420,7 @@ impl Mint {
                 return Err(Error::Internal);
             }
         };
+        tracing::error!("internal stuff");
 
         // Mint quote has already been settled, proofs should not be burned or held.
         if mint_quote.state == MintQuoteState::Issued || mint_quote.state == MintQuoteState::Paid {
@@ -446,7 +447,7 @@ impl Mint {
 
         let amount = melt_quote.amount;
 
-        self.update_mint_quote(mint_quote).await?;
+        tx.add_or_replace_mint_quote(mint_quote).await?;
 
         Ok(Some(amount))
     }