diff options
author | MS <ms@taler.net> | 2023-07-29 09:10:41 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2023-07-29 09:10:41 +0200 |
commit | 4332cd279ce2a330be7e84baac6685522606629c (patch) | |
tree | 91f38efa0412475be4eec511d624d4c5bcfbaafd | |
parent | 48c1cc4ce7e338d14093b2e04ccd621282a451ee (diff) | |
download | libeufin-4332cd279ce2a330be7e84baac6685522606629c.tar.gz libeufin-4332cd279ce2a330be7e84baac6685522606629c.tar.bz2 libeufin-4332cd279ce2a330be7e84baac6685522606629c.zip |
balance accounting
avoiding passing DB objects as function arguments.
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 12 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt | 2 | ||||
-rw-r--r-- | sandbox/src/test/kotlin/BalanceTest.kt | 6 | ||||
-rw-r--r-- | sandbox/src/test/kotlin/DBTest.kt | 1 |
4 files changed, 11 insertions, 10 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt index 0dc7b742..cd886e55 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -545,14 +545,14 @@ private suspend fun confirmWithdrawal(call: ApplicationCall) { logger.debug("Withdrawal ${wo.wopid} confirmed? ${wo.confirmationDone}") if (!wo.confirmationDone) { wireTransfer( - debitAccount = wo.walletBankAccount, - creditAccount = exchangeBankAccount, + debitAccount = wo.walletBankAccount.label, + creditAccount = exchangeBankAccount.label, amount = wo.amount, subject = wo.reservePub ?: throw internalServerError( "Cannot transfer funds without reserve public key." ), // provide the currency. - demobank = ensureDemobank(call) + demobank = ensureDemobank(call).name ) wo.confirmationDone = true } @@ -1347,9 +1347,9 @@ val sandboxApp: Application.() -> Unit = { * of 'bankAccount' be correctly accessed. */ transaction { wireTransfer( - debitAccount = bankAccount, - creditAccount = getBankAccountFromIban(payto.iban), - demobank = bankAccount.demoBank, + debitAccount = bankAccount.label, + creditAccount = getBankAccountFromIban(payto.iban).label, + demobank = bankAccount.demoBank.name, subject = payto.message ?: throw badRequest( "'message' query parameter missing in Payto address" ), diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt index 9a449f84..f867fca2 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt @@ -160,7 +160,7 @@ fun wireTransfer( } // Book a CRDT and a DBIT transaction and return the unique reference thereof. -fun wireTransfer( +private fun wireTransfer( debitAccount: BankAccountEntity, creditAccount: BankAccountEntity, demobank: DemobankConfigEntity, diff --git a/sandbox/src/test/kotlin/BalanceTest.kt b/sandbox/src/test/kotlin/BalanceTest.kt index aabf2051..eb09cc64 100644 --- a/sandbox/src/test/kotlin/BalanceTest.kt +++ b/sandbox/src/test/kotlin/BalanceTest.kt @@ -91,13 +91,13 @@ class BalanceTest { this.demobank = demobank } wireTransfer( - other, one, demobank, "one gets 1", "EUR:1" + other.label, one.label, demobank.name, "one gets 1", "EUR:1" ) wireTransfer( - other, one, demobank, "one gets another 1", "EUR:1" + other.label, one.label, demobank.name, "one gets another 1", "EUR:1" ) wireTransfer( - one, other, demobank, "one gives 1", "EUR:1" + one.label, other.label, demobank.name, "one gives 1", "EUR:1" ) val maybeOneBalance: BigDecimal = getBalance(one) println(maybeOneBalance) diff --git a/sandbox/src/test/kotlin/DBTest.kt b/sandbox/src/test/kotlin/DBTest.kt index e85d0ea9..bc5a33c5 100644 --- a/sandbox/src/test/kotlin/DBTest.kt +++ b/sandbox/src/test/kotlin/DBTest.kt @@ -56,6 +56,7 @@ class DBTest { */ @Test fun connectionStringTest() { + getJdbcConnectionFromPg("postgres://auditor-basedb") var conv = getJdbcConnectionFromPg("postgresql:///libeufincheck") connectWithSchema(getJdbcConnectionFromPg("postgres:///libeufincheck")) connectWithSchema(conv) |