gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: test for #7482


From: gnunet
Subject: [libeufin] branch master updated: test for #7482
Date: Sun, 15 Jan 2023 20:32:24 +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 ce3de29e test for #7482
ce3de29e is described below

commit ce3de29eb1a657cfa10d55e228d8ddf82478ec24
Author: MS <ms@taler.net>
AuthorDate: Sun Jan 15 20:32:14 2023 +0100

    test for #7482
---
 nexus/src/test/kotlin/MakeEnv.kt              |  1 +
 nexus/src/test/kotlin/SandboxAccessApiTest.kt | 44 ++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt
index 5616f616..40da1d81 100644
--- a/nexus/src/test/kotlin/MakeEnv.kt
+++ b/nexus/src/test/kotlin/MakeEnv.kt
@@ -132,6 +132,7 @@ fun prepSandboxDb() {
             name = "default"
             this.withSignupBonus = false
             captchaUrl = "http://example.com/"; // unused
+            suggestedExchangePayto = "payto://iban/${BAR_USER_IBAN}"
         }
         BankAccountEntity.new {
             iban = BANK_IBAN
diff --git a/nexus/src/test/kotlin/SandboxAccessApiTest.kt 
b/nexus/src/test/kotlin/SandboxAccessApiTest.kt
index d3900906..5a7f0273 100644
--- a/nexus/src/test/kotlin/SandboxAccessApiTest.kt
+++ b/nexus/src/test/kotlin/SandboxAccessApiTest.kt
@@ -5,6 +5,7 @@ import io.ktor.client.statement.*
 import io.ktor.http.*
 import io.ktor.server.testing.*
 import kotlinx.coroutines.runBlocking
+import org.jetbrains.exposed.sql.transactions.transaction
 import org.junit.Test
 import tech.libeufin.sandbox.*
 
@@ -60,6 +61,48 @@ class SandboxAccessApiTest {
             }
         }
     }
+    // Tests for #7482
+    @Test
+    fun highAmountWithdraw() {
+        withTestDatabase {
+            prepSandboxDb()
+            val b = getDefaultDemobank()
+            testApplication {
+                application(sandboxApp)
+                transaction { b.usersDebtLimit = 900000000 }
+                // Create the operation.
+                val r = 
client.post("/demobanks/default/access-api/accounts/foo/withdrawals") {
+                    expectSuccess = true
+                    setBody("{\"amount\": \"TESTKUDOS:500000000\"}")
+                    contentType(ContentType.Application.Json)
+                    basicAuth("foo", "foo")
+                }
+                println(r.bodyAsText())
+                val j = mapper.readTree(r.readBytes())
+                val op = j.get("withdrawal_id").asText()
+                // Select exchange and specify a reserve pub.
+                
client.post("/demobanks/default/integration-api/withdrawal-operation/$op") {
+                    expectSuccess = true
+                    contentType(ContentType.Application.Json)
+                    setBody("""{
+                        "selected_exchange":"payto://iban/${BAR_USER_IBAN}",
+                        "reserve_pub": "not-used"
+                    }""".trimIndent())
+                }
+                // Confirm the operation.
+                
client.post("/demobanks/default/access-api/accounts/foo/withdrawals/$op/confirm")
 {
+                    expectSuccess = true
+                    basicAuth("foo", "foo")
+                }
+                // Check the withdrawal amount in the unique transaction.
+                val t = 
client.get("/demobanks/default/access-api/accounts/foo/transactions") {
+                    basicAuth("foo", "foo")
+                }
+                val amount = 
mapper.readTree(t.readBytes()).get("transactions").get(0).get("amount").asText()
+                assert(amount == "500000000")
+            }
+        }
+    }
     @Test
     fun withdrawWithHighBalance() {
         withTestDatabase {
@@ -81,7 +124,6 @@ class SandboxAccessApiTest {
             testApplication {
                 this.application(sandboxApp)
                 runBlocking {
-                    // Normal, successful withdrawal.
                     
client.post("/demobanks/default/access-api/accounts/foo/withdrawals") {
                         expectSuccess = true
                         setBody("{\"amount\": \"TESTKUDOS:1\"}")

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