libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 39ccbb160540daecb94f71e6741bbf5216cfbd29
parent 7f2a86c3726ebe2e97a4410c1c16a0858b53948d
Author: MS <ms@taler.net>
Date:   Fri,  5 Feb 2021 13:24:52 +0100

give transaction ref to generated payments

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt | 4+++-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 13++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt @@ -86,7 +86,9 @@ fun getEbicsSubscriberFromDetails(userID: String, partnerID: String, hostID: Str fun getRandomString(length: Int) : String { val allowedChars = ('A'..'Z') + ('0'..'9') - return (1..length) + val ret = (1..length) .map { allowedChars.random() } .joinToString("") + SandboxAssert(ret.length == length, "Unexpected random string") + return ret } \ No newline at end of file diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -443,11 +443,11 @@ fun serverMain(dbName: String, port: Int) { transaction { val accountLabel = ensureNonNull(call.parameters["label"]) val account = getBankAccountFromLabel(accountLabel) - val transactionReference = getRandomString(8) + val transactionReferenceCrdt = getRandomString(8) + val transactionReferenceDbit = getRandomString(8) + run { - val random = Random.nextLong(0, Long.MAX_VALUE) val amount = Random.nextLong(5, 25) - BankAccountTransactionsTable.insert { it[creditorIban] = account.iban it[creditorBic] = account.bic @@ -455,7 +455,7 @@ fun serverMain(dbName: String, port: Int) { it[debtorIban] = "DE64500105178797276788" it[debtorBic] = "DEUTDEBB101" it[debtorName] = "Max Mustermann" - it[subject] = "sample transaction $transactionReference" + it[subject] = "sample transaction $transactionReferenceCrdt" it[BankAccountTransactionsTable.amount] = amount.toString() it[currency] = account.currency it[date] = Instant.now().toEpochMilli() @@ -466,7 +466,6 @@ fun serverMain(dbName: String, port: Int) { } run { - val random = Random.nextLong() val amount = Random.nextLong(5, 25) BankAccountTransactionsTable.insert { @@ -476,11 +475,11 @@ fun serverMain(dbName: String, port: Int) { it[creditorIban] = "DE64500105178797276788" it[creditorBic] = "DEUTDEBB101" it[creditorName] = "Max Mustermann" - it[subject] = "sample transaction $random" + it[subject] = "sample transaction $transactionReferenceDbit" it[BankAccountTransactionsTable.amount] = amount.toString() it[currency] = account.currency it[date] = Instant.now().toEpochMilli() - it[pmtInfId] = random.toString() + it[accountServicerReference] = transactionReferenceDbit it[BankAccountTransactionsTable.account] = account.id it[direction] = "DBIT" }