libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 38a83cfeed54165a9df69ac5e97d2b32260847cf
parent 68616ce589dce8e1983f3b8e51591e714c60609f
Author: MS <ms@taler.net>
Date:   Tue, 15 Dec 2020 13:48:01 +0100

test deduplication

Diffstat:
M.idea/vcs.xml | 1+
Mintegration-tests/tests.py | 47+++++++++++++++++++++++++++++++++++++++++++++++
Mnexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt | 1+
4 files changed, 51 insertions(+), 2 deletions(-)

diff --git 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 @@ -224,6 +224,53 @@ def test_payment(): @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( post( diff --git 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 @@ -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