[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: .equals() method for TalerAmount
From: |
gnunet |
Subject: |
[libeufin] branch master updated: .equals() method for TalerAmount |
Date: |
Fri, 15 Sep 2023 11:22:20 +0200 |
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 6e2ee7ff .equals() method for TalerAmount
6e2ee7ff is described below
commit 6e2ee7ff28ac6894e6d9acbea0ce77521b3c1b01
Author: MS <ms@taler.net>
AuthorDate: Fri Sep 15 11:22:07 2023 +0200
.equals() method for TalerAmount
---
bank/src/main/kotlin/tech/libeufin/bank/Database.kt | 7 +++++++
bank/src/test/kotlin/Common.kt | 1 +
bank/src/test/kotlin/DatabaseTest.kt | 12 ++++++------
bank/src/test/kotlin/LibeuFinApiTest.kt | 20 +-------------------
4 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
index b58269da..0bfd88ad 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
@@ -62,6 +62,13 @@ class TalerAmount(
?: throw internalServerError("internal_currency not found in the
config")
internalCurrency
} else maybeCurrency
+
+ override fun equals(other: Any?): Boolean {
+ return other is TalerAmount &&
+ other.value == this.value &&
+ other.frac == this.frac &&
+ other.currency == this.currency
+ }
}
// BIC got removed, because it'll be expressed in the internal_payto_uri.
diff --git a/bank/src/test/kotlin/Common.kt b/bank/src/test/kotlin/Common.kt
index e2b08e69..8aa7e456 100644
--- a/bank/src/test/kotlin/Common.kt
+++ b/bank/src/test/kotlin/Common.kt
@@ -35,5 +35,6 @@ fun initDb(): Database {
throwIfFails = true
)
val db = Database("jdbc:postgresql:///libeufincheck")
+ db.configSet("internal_currency", "KUDOS")
return db
}
\ No newline at end of file
diff --git a/bank/src/test/kotlin/DatabaseTest.kt
b/bank/src/test/kotlin/DatabaseTest.kt
index 05633562..6961a9b5 100644
--- a/bank/src/test/kotlin/DatabaseTest.kt
+++ b/bank/src/test/kotlin/DatabaseTest.kt
@@ -50,14 +50,14 @@ class DatabaseTest {
lastNexusFetchRowId = 1L,
owningCustomerId = 1L,
hasDebt = false,
- maxDebt = TalerAmount(10, 1)
+ maxDebt = TalerAmount(10, 1, "KUDOS")
)
private val bankAccountBar = BankAccount(
internalPaytoUri = "BAR-IBAN-ABC",
lastNexusFetchRowId = 1L,
owningCustomerId = 2L,
hasDebt = false,
- maxDebt = TalerAmount(10, 1)
+ maxDebt = TalerAmount(10, 1, "KUDOS")
)
@Test
@@ -155,8 +155,8 @@ class DatabaseTest {
// Foo should have returned to zero and no debt, same for Bar.
// Foo: debit -> credit
assert(fooAccount?.hasDebt == false && barAccount?.hasDebt == false)
- assert(fooAccount?.balance?.equals(TalerAmount(0, 0)) == true)
- assert(barAccount?.balance?.equals(TalerAmount(0, 0)) == true)
+ assert(fooAccount?.balance?.equals(TalerAmount(0, 0, "KUDOS")) == true)
+ assert(barAccount?.balance?.equals(TalerAmount(0, 0, "KUDOS")) == true)
// Bringing Bar to debit.
val barPaysMore = db.bankTransactionCreate(barPaysFoo)
assert(barPaysAgain == Database.BankTransactionResult.SUCCESS)
@@ -164,8 +164,8 @@ class DatabaseTest {
fooAccount = db.bankAccountGetFromOwnerId(fooId)
// Bar: credit -> debit
assert(fooAccount?.hasDebt == false && barAccount?.hasDebt == true)
- assert(fooAccount?.balance?.equals(TalerAmount(10, 0)) == true)
- assert(barAccount?.balance?.equals(TalerAmount(10, 0)) == true)
+ assert(fooAccount?.balance?.equals(TalerAmount(10, 0, "KUDOS")) ==
true)
+ assert(barAccount?.balance?.equals(TalerAmount(10, 0, "KUDOS")) ==
true)
}
@Test
fun customerCreationTest() {
diff --git a/bank/src/test/kotlin/LibeuFinApiTest.kt
b/bank/src/test/kotlin/LibeuFinApiTest.kt
index ec09c813..48ca69a6 100644
--- a/bank/src/test/kotlin/LibeuFinApiTest.kt
+++ b/bank/src/test/kotlin/LibeuFinApiTest.kt
@@ -9,24 +9,6 @@ import tech.libeufin.util.CryptoUtil
import tech.libeufin.util.execCommand
class LibeuFinApiTest {
- fun initDb(): Database {
- System.setProperty(
- "BANK_DB_CONNECTION_STRING",
- "jdbc:postgresql:///libeufincheck"
- )
- execCommand(
- listOf(
- "libeufin-bank-dbinit",
- "-d",
- "libeufincheck",
- "-r"
- ),
- throwIfFails = true
- )
- val db = Database("jdbc:postgresql:///libeufincheck")
- return db
- }
-
/**
* Testing the account creation, its idempotency and
* the restriction to admin to create accounts.
@@ -36,7 +18,7 @@ class LibeuFinApiTest {
testApplication {
val db = initDb()
val ibanPayto = genIbanPaytoUri()
- // Bank needs that to operate:
+ // Bank needs those to operate:
db.configSet("max_debt_ordinary_customers", "KUDOS:11")
application(webApp)
var resp = client.post("/accounts") {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: .equals() method for TalerAmount,
gnunet <=