gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/03: test deduplication


From: gnunet
Subject: [libeufin] 01/03: test deduplication
Date: Tue, 15 Dec 2020 17:51:41 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 38a83cfeed54165a9df69ac5e97d2b32260847cf
Author: MS <ms@taler.net>
AuthorDate: Tue Dec 15 13:48:01 2020 +0100

    test deduplication
---
 .idea/vcs.xml                                      |  1 +
 integration-tests/tests.py                         | 47 ++++++++++++++++++++++
 nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt |  4 +-
 .../tech/libeufin/nexus/bankaccount/BankAccount.kt |  1 +
 4 files changed, 51 insertions(+), 2 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..ca220c0 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -223,6 +223,53 @@ def test_payment():
     assert len(resp.json().get("transactions")) == 1
 
 
+@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
+
+
 @pytest.fixture
 def make_taler_facade():
     assertResponse(
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

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