gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 02/03: cash-out estimation test


From: gnunet
Subject: [libeufin] 02/03: cash-out estimation test
Date: Mon, 20 Mar 2023 15:44:28 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 265a823964fe6aaa7348cebdea674743fe449872
Author: ms <ms@taler.net>
AuthorDate: Mon Mar 20 15:43:58 2023 +0100

    cash-out estimation test
---
 nexus/src/test/kotlin/SandboxCircuitApiTest.kt | 27 +++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt 
b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
index 83a63104..4664cceb 100644
--- a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
+++ b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
@@ -11,6 +11,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
 import org.junit.Ignore
 import org.junit.Test
 import tech.libeufin.sandbox.*
+import tech.libeufin.util.parseAmount
 import java.io.File
 import java.math.BigDecimal
 import java.util.*
@@ -30,6 +31,30 @@ class SandboxCircuitApiTest {
         }
     }
 
+    // Tests the application of cash-out ratio and fee.
+    @Test
+    fun estimationTest() {
+        withTestDatabase {
+            prepSandboxDb()
+            testApplication {
+                application(sandboxApp)
+                val R = client.get(
+                    
"/demobanks/default/circuit-api/cashouts/estimates?amount_debit=TESTKUDOS:2"
+                ) {
+                    expectSuccess = true
+                    basicAuth("foo", "foo")
+                }
+                println(R.bodyAsText())
+                val mapper = ObjectMapper()
+                val respJson = mapper.readTree(R.bodyAsText())
+                val creditAmount = respJson.get("amount_credit").asText()
+                // sell ratio and fee are the following constants: 0.95 and 0.
+                // expected credit amount = 2 * 0.95 - 0 = 1.90
+                assert("CHF:1.90" == creditAmount)
+            }
+        }
+    }
+
     /**
      * Checking that the ordinary user foo doesn't get to access bar's
      * data, but admin does.
@@ -45,7 +70,7 @@ class SandboxCircuitApiTest {
                     expectSuccess = false
                 }
                 assert(R.status.value == HttpStatusCode.Forbidden.value)
-                R = client.get("/demobanks/default/circuit-api/accounts/bar") {
+                client.get("/demobanks/default/circuit-api/accounts/bar") {
                     basicAuth("admin", "foo")
                     expectSuccess = true
                 }

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