gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (68616ce -> d0200f2)


From: gnunet
Subject: [libeufin] branch master updated (68616ce -> d0200f2)
Date: Tue, 15 Dec 2020 17:51:40 +0100

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

ms pushed a change to branch master
in repository libeufin.

    from 68616ce  Taler wire gateways test.
     new 38a83cf  test deduplication
     new e7175ba  extend bank-account API to show initiated payments status
     new d0200f2  Initiated payments tracking.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .idea/vcs.xml                                      |   1 +
 integration-tests/tests.py                         | 132 ++++++++++++++++-----
 nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt |   4 +-
 .../tech/libeufin/nexus/bankaccount/BankAccount.kt |   1 +
 .../main/kotlin/tech/libeufin/nexus/server/JSON.kt |   7 +-
 .../tech/libeufin/nexus/server/NexusServer.kt      |   7 +-
 6 files changed, 119 insertions(+), 33 deletions(-)

diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index c8faf33..707ab3c 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -5,5 +5,6 @@
     <mapping directory="$PROJECT_DIR$/build-common" vcs="Git" />
     <mapping directory="$PROJECT_DIR$/build-system/taler-build-scripts" 
vcs="Git" />
     <mapping directory="$PROJECT_DIR$/parsing-tests" vcs="Git" />
+    <mapping directory="$PROJECT_DIR$/parsing-tests/samples" vcs="Git" />
   </component>
 </project>
\ No newline at end of file
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index 3eba263..4d6de74 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -120,12 +120,10 @@ def setup_function():
     prepareSandbox()
     prepareNexus()
 
-
 def teardown_function():
     dropSandboxTables(DB)
     dropNexusTables(DB)
 
-
 def test_env():
     print("Nexus and Sandbox are up and running!")
     try:
@@ -187,39 +185,119 @@ def test_ebics_custom_ebics_order():
 # This test makes a payment and expects to see it
 # in the account history.
 def test_payment():
-    resp = assertResponse(
-        post(
-            
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/payment-initiations",
-            json=dict(
-                iban="FR7630006000011234567890189",
-                bic="AGRIFRPP",
-                name="Jacques La Fayette",
-                subject="integration test",
-                amount="EUR:1",
-            ),
-            auth=PERSONA.nexus.auth
-        )
-    )
+    resp = assertResponse(post(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/payment-initiations",
+        json=dict(
+            iban="FR7630006000011234567890189",
+            bic="AGRIFRPP",
+            name="Jacques La Fayette",
+            subject="integration test",
+            amount="EUR:1",
+        ),
+        auth=PERSONA.nexus.auth
+    ))
     PAYMENT_UUID = resp.json().get("uuid")
-    assertResponse(
-        post(
-            
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/payment-initiations/{PAYMENT_UUID}/submit",
-            json=dict(),
-            auth=PERSONA.nexus.auth
-        )
-    )
+    assertResponse(post("/".join([
+        PERSONA.nexus.base_url,
+        "bank-accounts",
+        PERSONA.nexus.bank_label,
+        "payment-initiations",
+        PAYMENT_UUID,
+        "submit"]),
+        json=dict(),
+        auth=PERSONA.nexus.auth
+    ))
     assertResponse(
         post(
             
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/fetch-transactions",
             auth=PERSONA.nexus.auth
         )
     )
-    resp = assertResponse(
-        get(
-            
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/transactions",
-            auth=PERSONA.nexus.auth
-        )
+    resp = assertResponse(get(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/transactions",
+        auth=PERSONA.nexus.auth
+    ))
+    assert len(resp.json().get("transactions")) == 1
+
+    # assert now that the payment shows up as confirmed.
+    resp = assertResponse(get("/".join([
+        PERSONA.nexus.base_url,
+        "bank-accounts",
+        PERSONA.nexus.bank_label,
+        "payment-initiations",
+        PAYMENT_UUID]),
+        auth=PERSONA.nexus.auth
+    ))
+    assert resp.json()["status"] == "BOOK"
+
+    # Posting a second payment initiation, but not submitting it.
+    resp = assertResponse(post(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/payment-initiations",
+        json=dict(
+            iban="FR7630006000011234567890189",
+            bic="AGRIFRPP",
+            name="Jacques La Fayette",
+            subject="integration test",
+            amount="EUR:1",
+        ),
+        auth=PERSONA.nexus.auth
+    ))
+    PAYMENT_UUID_NON_SUBMITTED = resp.json().get("uuid")
+    resp = assertResponse(get("/".join([
+        PERSONA.nexus.base_url,
+        "bank-accounts",
+        PERSONA.nexus.bank_label,
+        "payment-initiations",
+        PAYMENT_UUID_NON_SUBMITTED]),
+        auth=PERSONA.nexus.auth
+    ))
+    assert resp.json()["status"] == None
+
+
+@pytest.fixture
+def fetch_transactions():
+    assertResponse(post(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/fetch-transactions",
+        auth=PERSONA.nexus.auth
+    ))
+
+# Book a incoming payment for "persona" at the Sandbox.
+@pytest.fixture
+def make_crdt_payment():
+    payment_instruction = dict(
+        creditorIban=PERSONA.banking.iban,
+        creditorBic=PERSONA.banking.bic,
+        creditorName=PERSONA.banking.name,
+        debitorIban="FR00000000000000000000",
+        debitorBic="BUKBGB22",
+        debitorName="Max Mustermann",
+        amount=5,
+        currency="EUR",
+        subject="Reimbursement",
+        direction="CRDT"
     )
+
+    assertResponse(post(
+        f"{PERSONA.banking.bank_base_url}/admin/payments/",
+        json=payment_instruction
+    ))
+
+
+def test_deduplication(make_crdt_payment):
+    # fetching twice the transactions and check that
+    # the payment made via the fixture shows up only once.
+    assertResponse(post(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/fetch-transactions",
+        auth=PERSONA.nexus.auth
+    ))
+    assertResponse(post(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/fetch-transactions",
+        auth=PERSONA.nexus.auth
+    ))
+    resp = assertResponse(get(
+        
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/transactions",
+        auth=PERSONA.nexus.auth
+    ))
     assert len(resp.json().get("transactions")) == 1
 
 
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index 52a6edd..ef2c4b9 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -424,7 +424,7 @@ fun ingestTalerTransactions() {
         val facadeState = getTalerFacadeState(facade.id.value)
         var lastId = facadeState.highestSeenMsgID
         NexusBankTransactionEntity.find {
-            /** Those with exchange bank account involved */
+            /** Those with "our" bank account involved */
             NexusBankTransactionsTable.bankAccount eq 
subscriberAccount.id.value and
                     /** Those that are booked */
                     (NexusBankTransactionsTable.status eq EntryStatus.BOOK) and
@@ -438,7 +438,7 @@ fun ingestTalerTransactions() {
             )
             val details = 
tx.batches?.get(0)?.batchTransactions?.get(0)?.details
             if (details == null) {
-                logger.warn("Met a void money movement: VERY strange")
+                logger.warn("A void money movement made it through the 
ingestion: VERY strange")
                 return@forEach
             }
             when (tx.creditDebitIndicator) {
diff --git 
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 6e7588d..52a9d2c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -163,6 +163,7 @@ fun processCamtMessage(bankAccountId: String, camtDoc: 
Document, code: String):
             }
             val duplicate = findDuplicate(bankAccountId, acctSvcrRef)
             if (duplicate != null) {
+                logger.info("Found a duplicate: $acctSvcrRef")
                 // FIXME(dold): See if an old transaction needs to be 
superseded by this one
                 // https://bugs.gnunet.org/view.php?id=6381
                 break
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index ec353ab..ad11b4c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -233,7 +233,12 @@ data class PaymentStatus(
     val amount: String,
     val subject: String,
     val submissionDate: String?,
-    val preparationDate: String
+    val preparationDate: String,
+    // null when the payment was never acknowledged by
+    // the bank.  For example, it was submitted but never
+    // seen in any report; or only created and not even
+    // submitted.
+    val status: EntryStatus?
 )
 
 data class Transactions(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 14fc102..e0708a7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -575,6 +575,7 @@ fun serverMain(dbName: String, host: String) {
                         val sd = it.submissionDate
                         ret.initiatedPayments.add(
                             PaymentStatus(
+                                status = it.confirmationTransaction?.status,
                                 paymentInitiationId = it.id.value.toString(),
                                 submitted = it.submitted,
                                 creditorIban = it.creditorIban,
@@ -601,6 +602,7 @@ fun serverMain(dbName: String, host: String) {
                     val paymentInitiation = 
getPaymentInitiation(ensureLong(call.parameters["uuid"]))
                     return@transaction object {
                         val paymentInitiation = paymentInitiation
+                        val paymentStatus = 
paymentInitiation.confirmationTransaction?.status
                     }
                 }
                 val sd = res.paymentInitiation.submissionDate
@@ -613,9 +615,8 @@ fun serverMain(dbName: String, host: String) {
                         creditorIban = res.paymentInitiation.creditorIban,
                         amount = 
"${res.paymentInitiation.currency}:${res.paymentInitiation.sum}",
                         subject = res.paymentInitiation.subject,
-                        submissionDate = if (sd != null) {
-                            importDateFromMillis(sd).toDashedDate()
-                        } else null,
+                        submissionDate = if (sd != null) { 
importDateFromMillis(sd).toDashedDate() } else null,
+                        status = res.paymentStatus,
                         preparationDate = 
importDateFromMillis(res.paymentInitiation.preparationDate).toDashedDate()
                     )
                 )

-- 
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]