gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: testing #7525


From: gnunet
Subject: [libeufin] branch master updated: testing #7525
Date: Thu, 12 Jan 2023 17:42:13 +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 440da053 testing #7525
440da053 is described below

commit 440da053a012c4ab1e44a0661d444785c081b026
Author: MS <ms@taler.net>
AuthorDate: Thu Jan 12 17:41:52 2023 +0100

    testing #7525
---
 Makefile                                   |  8 ++--
 cli/bin/debit_test.sh                      | 77 ++++++++++++++++++++++++++++++
 nexus/src/test/kotlin/DownloadAndSubmit.kt | 14 +++++-
 nexus/src/test/kotlin/MakeEnv.kt           |  7 ++-
 4 files changed, 99 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 842e20c4..6597f3c2 100644
--- a/Makefile
+++ b/Makefile
@@ -36,8 +36,8 @@ assemble:
 check:
        @./gradlew check
        @cd ./cli/bin && ./circuit_test.sh
+       @cd ./cli/bin && ./debit_test.sh
 
-
-.PHONY: parse
-parse:
-       @cd parsing-tests; py.test -s checks.py
+# .PHONY: parse
+# parse:
+#      @cd parsing-tests; py.test -s checks.py
diff --git a/cli/bin/debit_test.sh b/cli/bin/debit_test.sh
new file mode 100755
index 00000000..9df06364
--- /dev/null
+++ b/cli/bin/debit_test.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# Tests successful cases of the CLI acting
+# as the client of the Circuit API.
+
+set -eu
+
+echo TESTING DEBIT THRESHOLD
+jq --version &> /dev/null || (echo "'jq' command not found"; exit 77)
+curl --version &> /dev/null || (echo "'curl' command not found"; exit 77)
+
+DB_PATH=/tmp/debit-test.sqlite3
+export LIBEUFIN_SANDBOX_DB_CONNECTION=jdbc:sqlite:$DB_PATH
+
+echo -n Delete previous data..
+rm -f $DB_PATH
+echo DONE
+echo -n Configure the default demobank, with users limit 0...
+libeufin-sandbox config --currency MANA default --users-debt-limit=0
+echo DONE
+echo -n Start the bank...
+export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=circuit
+libeufin-sandbox serve &> sandbox.log &
+SANDBOX_PID=$!
+trap "echo -n 'killing the bank (pid $SANDBOX_PID)...'; kill $SANDBOX_PID; 
wait; echo DONE" EXIT
+echo DONE
+echo -n Wait for the bank...
+curl --max-time 2 --retry-connrefused --retry-delay 1 --retry 10 
http://localhost:5000/ &> /dev/null
+echo DONE
+
+echo -n "Register new account..."
+export LIBEUFIN_SANDBOX_USERNAME=www
+export LIBEUFIN_SANDBOX_PASSWORD=foo
+
+./libeufin-cli \
+  sandbox --sandbox-url http://localhost:5000/ \
+  demobank \
+  register
+echo DONE
+echo -n "Get the admin's IBAN..."
+ADMIN_IBAN=$(echo "SELECT iban FROM BankAccounts WHERE label='admin'" | 
sqlite3 $DB_PATH)
+echo "DONE ($ADMIN_IBAN)"
+echo -n "Try to surpass the debit threshold (user pays admin)..."
+./libeufin-cli \
+  sandbox --sandbox-url http://localhost:5000/ \
+  demobank \
+  new-transaction \
+  --bank-account www \
+  --payto-with-subject "payto://iban/SANDBOXX/${ADMIN_IBAN}?message=go-debit" \
+  --amount MANA:99999 &> /dev/null || true
+echo DONE
+
+echo -n Check the amount is zero...
+RESP=$(libeufin-cli sandbox --sandbox-url http://localhost:5000/ demobank info 
--bank-account www)
+BALANCE=$(echo $RESP | jq -r '.balance.amount')
+if [ "$BALANCE" != "MANA:0" ]; then
+  echo Debit threshold of MANA:0 not respected.
+  exit 1
+fi
+echo DONE
+
+echo -n "Try to surpass the debit threshold via low-level libeufin-sandbox 
command..."
+libeufin-sandbox \
+  make-transaction \
+  --credit-account=admin \
+  --debit-account=www \
+  MANA:9999 "Go debit again."  &> /dev/null || true
+echo DONE
+
+echo -n Check the amount is again zero...
+RESP=$(libeufin-cli sandbox --sandbox-url http://localhost:5000/ demobank info 
--bank-account www)
+BALANCE=$(echo $RESP | jq -r '.balance.amount')
+if [ "$BALANCE" != "MANA:0" ]; then
+  echo Debit threshold of MANA:0 not respected via low-level libeufin-sandbox 
command.
+  exit 1
+fi
+echo DONE
diff --git a/nexus/src/test/kotlin/DownloadAndSubmit.kt 
b/nexus/src/test/kotlin/DownloadAndSubmit.kt
index d656711b..928df051 100644
--- a/nexus/src/test/kotlin/DownloadAndSubmit.kt
+++ b/nexus/src/test/kotlin/DownloadAndSubmit.kt
@@ -31,6 +31,7 @@ import tech.libeufin.util.*
 import tech.libeufin.util.ebics_h004.EbicsRequest
 import tech.libeufin.util.ebics_h004.EbicsResponse
 import tech.libeufin.util.ebics_h004.EbicsTypes
+import kotlin.reflect.full.isSubclassOf
 
 /**
  * Data to make the test server return for EBICS
@@ -324,7 +325,7 @@ class DownloadAndSubmit {
                         ),
                         "foo"
                     )
-                    assertException<EbicsProtocolError> { 
submitAllPaymentInitiations(client, "foo") }
+                    assertException<EbicsProtocolError>({ 
submitAllPaymentInitiations(client, "foo") })
                 }
             }
         }
@@ -349,7 +350,16 @@ class DownloadAndSubmit {
                         ),
                         "foo"
                     )
-                    assertException<EbicsProtocolError> { 
submitAllPaymentInitiations(client, "foo") }
+                    assertException<EbicsProtocolError>(
+                        { submitAllPaymentInitiations(client, "foo") },
+                        {
+                            val nexusEbicsException = it as EbicsProtocolError
+                            assert(
+                                
EbicsReturnCode.EBICS_AMOUNT_CHECK_FAILED.errorCode ==
+                                
nexusEbicsException.ebicsTechnicalCode?.errorCode
+                            )
+                        }
+                    )
                 }
             }
         }
diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt
index 238b912c..5616f616 100644
--- a/nexus/src/test/kotlin/MakeEnv.kt
+++ b/nexus/src/test/kotlin/MakeEnv.kt
@@ -33,11 +33,16 @@ val userKeys = EbicsKeys(
 )
 
 // New versions of JUnit provide this!
-inline fun <reified ExceptionType> assertException(block: () -> Unit) {
+inline fun <reified ExceptionType> assertException(
+    block: () -> Unit,
+    assertBlock: (Throwable) -> Unit = {}
+) {
     try {
         block()
     } catch (e: Throwable) {
         assert(e.javaClass == ExceptionType::class.java)
+        // Expected type, try more custom asserts on it
+        assertBlock(e)
         return
     }
     return assert(false)

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