gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: nexus db


From: gnunet
Subject: [libeufin] branch master updated: nexus db
Date: Thu, 02 Nov 2023 10:55:20 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 295ce2bc nexus db
295ce2bc is described below

commit 295ce2bc3fbb3adbae7a96a36c62151d671ce253
Author: MS <ms@taler.net>
AuthorDate: Thu Nov 2 10:54:46 2023 +0100

    nexus db
    
    method to set the failure message of initiated payments.
---
 .../main/kotlin/tech/libeufin/nexus/Database.kt    | 22 ++++++++++++++++++++
 nexus/src/test/kotlin/ConfigLoading.kt             |  2 +-
 nexus/src/test/kotlin/DatabaseTest.kt              | 24 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Database.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Database.kt
index dbe28b11..310d3e08 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Database.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Database.kt
@@ -339,6 +339,28 @@ class Database(dbConfig: String): java.io.Closeable {
         return@runConn stmt.maybeUpdate()
     }
 
+    /**
+     * Sets the failure message to an initiated payment.  This text may
+     * come soon: as an internal failure at Nexus itself, or as the bank
+     * HTTP response of POSTing the EBICS document, or later: when asking
+     * the bank a pain.002 report.
+     *
+     * @param rowId row ID of the record to set.
+     * @param failureMessage error message from the bank.
+     * @return true on success, false if no payment was affected.
+     */
+    suspend fun initiatedPaymentSetFailureMessage(rowId: Long, failureMessage: 
String): Boolean = runConn { conn ->
+        val stmt = conn.prepareStatement("""
+             UPDATE initiated_outgoing_transactions
+                      SET failure_message = ?
+                      WHERE initiated_outgoing_transaction_id=?
+             """
+        )
+        stmt.setString(1, failureMessage)
+        stmt.setLong(2, rowId)
+        return@runConn stmt.maybeUpdate()
+    }
+
     /**
      * Gets any initiated payment that was not submitted to the
      * bank yet.
diff --git a/nexus/src/test/kotlin/ConfigLoading.kt 
b/nexus/src/test/kotlin/ConfigLoading.kt
index cf9d8eab..13281799 100644
--- a/nexus/src/test/kotlin/ConfigLoading.kt
+++ b/nexus/src/test/kotlin/ConfigLoading.kt
@@ -24,7 +24,7 @@ class ConfigLoading {
         val handle = TalerConfig(NEXUS_CONFIG_SOURCE)
         handle.load()
         val cfg = EbicsSetupConfig(handle)
-        cfg.config.requirePath("nexus-ebics-fetch", "statement_log_directory")
+        cfg.config.requirePath("nexus-fetch", "statement_log_directory")
     }
 
 
diff --git a/nexus/src/test/kotlin/DatabaseTest.kt 
b/nexus/src/test/kotlin/DatabaseTest.kt
index 389618ee..8477d8f3 100644
--- a/nexus/src/test/kotlin/DatabaseTest.kt
+++ b/nexus/src/test/kotlin/DatabaseTest.kt
@@ -128,6 +128,30 @@ class IncomingPaymentsTest {
 }
 class PaymentInitiationsTest {
 
+    // Testing the insertion of the failure message.
+    @Test
+    fun setFailureMessage() {
+        val db = prepDb(TalerConfig(NEXUS_CONFIG_SOURCE))
+        runBlocking {
+            assertEquals(
+                db.initiatedPaymentCreate(genInitPay("not submitted, has row 
ID == 1")),
+                PaymentInitiationOutcome.SUCCESS
+            )
+            assertFalse(db.initiatedPaymentSetFailureMessage(3, "3 not 
existing"))
+            assertTrue(db.initiatedPaymentSetFailureMessage(1, "expired"))
+            // Checking the value from the database.
+            db.runConn { conn ->
+                val idOne = conn.execSQLQuery("""
+                    SELECT failure_message
+                      FROM initiated_outgoing_transactions
+                      WHERE initiated_outgoing_transaction_id = 1;
+                """.trimIndent())
+                assertTrue(idOne.next())
+                val maybeMessage = idOne.getString("failure_message")
+                assertEquals("expired", maybeMessage)
+            }
+        }
+    }
     // Tests the flagging of payments as submitted.
     @Test
     fun paymentInitiationSetAsSubmitted() {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]