libeufin

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

commit d67273a2041f1e20600b6f37137cea0ae542e91b
parent 916892f6ee1972adbfb96150fdc229e4df29d32f
Author: Antoine A <>
Date:   Tue,  4 Mar 2025 11:48:47 +0100

nexus: renaming

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/api/WireGatewayApi.kt | 5++---
Mnexus/src/main/kotlin/tech/libeufin/nexus/cli/EbicsFetch.kt | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt | 2+-
Mnexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt | 26+++++++++++++-------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt | 48++++++++++++++++++++++++------------------------
Mnexus/src/test/kotlin/DatabaseTest.kt | 4++--
Mnexus/src/test/kotlin/Iso20022Test.kt | 67+++++++++++++++++++++++++++++++++----------------------------------
Mnexus/src/test/kotlin/RegistrationTest.kt | 58+++++++++++++++++++++++++++++-----------------------------
Mnexus/src/test/kotlin/helpers.kt | 20++++++++++----------
Mtestbench/src/test/kotlin/IntegrationTest.kt | 8++++----
11 files changed, 122 insertions(+), 124 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/api/WireGatewayApi.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/api/WireGatewayApi.kt @@ -120,13 +120,12 @@ fun Routing.wireGatewayApi(db: Database, cfg: NexusConfig) = conditional(cfg.wir cfg.checkCurrency(amount) val debitAccount = debitAccount.expectRequestIban() val timestamp = Instant.now() - val bankId = randEbicsId() val res = db.payment.registerTalerableIncoming(IncomingPayment( amount = amount, - debtorPayto = debitAccount, + debtor = debitAccount, subject = subject, executionTime = timestamp, - bankId = IncomingId(null, bankId, null) + id = IncomingId(null, randEbicsId(), null) ), metadata) when (res) { IncomingRegistrationResult.ReservePubReuse -> throw conflict( diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/cli/EbicsFetch.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/cli/EbicsFetch.kt @@ -105,7 +105,7 @@ suspend fun registerIncomingPayment( } } suspend fun bounce(msg: String) { - if (payment.bankId == null) { + if (payment.id == null) { logger.debug("{} ignored: missing bank ID", payment) return } @@ -140,7 +140,7 @@ suspend fun registerIncomingPayment( } } // Check we have enough info to handle this transaction - if (payment.subject == null || payment.debtorPayto == null) { + if (payment.subject == null || payment.debtor == null) { val res = db.payment.registerIncoming(payment) logRes(res, kind = "incomplete") return diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt @@ -98,11 +98,11 @@ class FakeIncoming: CliktCommand() { registerIncomingPayment(db, cfg.ingest, IncomingPayment( amount = amount, - debtorPayto = payto, + debtor = payto, subject = subject, creditFee = creditFee, executionTime = Instant.now(), - bankId = IncomingId(null, randEbicsId(), null) + id = IncomingId(null, randEbicsId(), null) ) ) } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt @@ -296,7 +296,7 @@ class InitiatedDAO(private val db: Database) { amount = it.getAmount("amount", db.bankCurrency), subject = it.getString("subject"), executionTime = executionTime, - creditorPayto = it.getIbanPayto("credit_payto") + creditor = it.getIbanPayto("credit_payto") ) } } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt @@ -52,7 +52,7 @@ class PaymentDAO(private val db: Database) { setInt(2, payment.amount.frac) setString(3, payment.subject) setLong(4, executionTime) - setString(5, payment.creditorPayto?.toString()) + setString(5, payment.creditor?.toString()) setString(6, payment.id.endToEndId) setString(7, payment.id.msgId) setString(8, payment.id.acctSvcrRef) @@ -99,10 +99,10 @@ class PaymentDAO(private val db: Database) { setInt(4, payment.creditFee?.frac ?: 0) setString(5, payment.subject) setLong(6, payment.executionTime.micros()) - setString(7, payment.debtorPayto?.toString()) - setObject(8, payment.bankId.uetr) - setString(9, payment.bankId.txId) - setString(10, payment.bankId.acctSvcrRef) + setString(7, payment.debtor?.toString()) + setObject(8, payment.id.uetr) + setString(9, payment.id.txId) + setString(10, payment.id.acctSvcrRef) setLong(11, bounceAmount.value) setInt(12, bounceAmount.frac) setLong(13, timestamp.micros()) @@ -140,10 +140,10 @@ class PaymentDAO(private val db: Database) { setInt(4, payment.creditFee?.frac ?: 0) setString(5, payment.subject) setLong(6, executionTime) - setString(7, payment.debtorPayto?.toString()) - setObject(8, payment.bankId.uetr) - setString(9, payment.bankId.txId) - setString(10, payment.bankId.acctSvcrRef) + setString(7, payment.debtor?.toString()) + setObject(8, payment.id.uetr) + setString(9, payment.id.txId) + setString(10, payment.id.acctSvcrRef) setString(11, metadata.type.name) setBytes(12, metadata.key.raw) one { @@ -174,10 +174,10 @@ class PaymentDAO(private val db: Database) { setInt(4, payment.creditFee?.frac ?: 0) setString(5, payment.subject) setLong(6, executionTime) - setString(7, payment.debtorPayto?.toString()) - setObject(8, payment.bankId.uetr) - setString(9, payment.bankId.txId) - setString(10, payment.bankId.acctSvcrRef) + setString(7, payment.debtor?.toString()) + setObject(8, payment.id.uetr) + setString(9, payment.id.txId) + setString(10, payment.id.acctSvcrRef) one { IncomingRegistrationResult.Success( it.getLong("out_tx_id"), diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt @@ -137,12 +137,12 @@ data class BatchId( /** ISO20022 incoming payment */ data class IncomingPayment( - val bankId: IncomingId, + val id: IncomingId, val amount: TalerAmount, val creditFee: TalerAmount? = null, val subject: String?, override val executionTime: Instant, - val debtorPayto: IbanPayto? + val debtor: IbanPayto? ): TxNotification { override fun toString(): String = buildString { append("IN ") @@ -154,10 +154,10 @@ data class IncomingPayment( append(creditFee) } append(" ") - append(bankId) - if (debtorPayto != null) { + append(id) + if (debtor != null) { append(" debtor=") - append(debtorPayto) + append(debtor) } if (subject != null) { append(" subject='") @@ -173,7 +173,7 @@ data class OutgoingPayment( val amount: TalerAmount, val subject: String?, override val executionTime: Instant, - val creditorPayto: IbanPayto? + val creditor: IbanPayto? ): TxNotification { override fun toString(): String = buildString { append("OUT ") @@ -182,9 +182,9 @@ data class OutgoingPayment( append(amount) append(" ") append(id) - if (creditorPayto != null) { + if (creditor != null) { append(" creditor=") - append(creditorPayto) + append(creditor) } if (subject != null) { append(" subject='") @@ -574,16 +574,16 @@ fun parseTx(notifXml: InputStream, dialect: Dialect): List<AccountTransactions> Kind.DBIT -> { val id = incomingId(ref) val subject = wireTransferSubject() - val debtorPayto = payto("Dbtr") + val debtor = payto("Dbtr") val creditFee = amount.creditFee() requireNotNull(creditFee) { "Do not support failed debit without credit fee" } require(creditFee > amount.amount()) txInfos.add(TxInfo.Credit( bookDate = bookDate, - bankId = id, + id = id, amount = amount.amount(), subject = subject, - debtorPayto = debtorPayto, + debtor = debtor, code = code, creditFee = creditFee )) @@ -594,27 +594,27 @@ fun parseTx(notifXml: InputStream, dialect: Dialect): List<AccountTransactions> when (kind) { Kind.CRDT -> { val id = incomingId(ref) - val debtorPayto = payto("Dbtr") + val debtor = payto("Dbtr") txInfos.add(TxInfo.Credit( bookDate = bookDate, - bankId = id, + id = id, amount = amount.amount(), subject = subject, - debtorPayto = debtorPayto, + debtor = debtor, code = code, creditFee = amount.creditFee() )) } Kind.DBIT -> { val outgoingId = outgoingId(ref) - val creditorPayto = payto("Cdtr") + val creditor = payto("Cdtr") require(amount.creditFee() == null) { "Do not support debit with credit fees" } txInfos.add(TxInfo.Debit( bookDate = bookDate, id = outgoingId, amount = amount.amount(), subject = subject, - creditorPayto = creditorPayto, + creditor = creditor, code = code )) } @@ -666,11 +666,11 @@ sealed interface TxInfo { data class Credit( val bookDate: Instant, val code: BankTransactionCode, - val bankId: IncomingId, + val id: IncomingId, val amount: TalerAmount, val creditFee: TalerAmount?, val subject: String?, - val debtorPayto: IbanPayto? + val debtor: IbanPayto? ): TxInfo data class Debit( val bookDate: Instant, @@ -678,7 +678,7 @@ sealed interface TxInfo { val id: OutId, val amount: TalerAmount, val subject: String?, - val creditorPayto: IbanPayto? + val creditor: IbanPayto? ): TxInfo fun parse(): TxNotification { @@ -694,13 +694,13 @@ sealed interface TxInfo { ) } is TxInfo.Credit -> { - if (bankId.uetr == null && bankId.txId == null && bankId.acctSvcrRef == null) - throw IncompleteTx("missing unique ID for Credit $bankId") + if (id.uetr == null && id.txId == null && id.acctSvcrRef == null) + throw IncompleteTx("missing unique ID for Credit $id") IncomingPayment( amount = amount, creditFee = creditFee, - bankId = bankId, - debtorPayto = debtorPayto, + id = id, + debtor = debtor, executionTime = bookDate, subject = subject, ) @@ -719,7 +719,7 @@ sealed interface TxInfo { ), amount = amount, executionTime = bookDate, - creditorPayto = creditorPayto, + creditor = creditor, subject = subject ) } diff --git a/nexus/src/test/kotlin/DatabaseTest.kt b/nexus/src/test/kotlin/DatabaseTest.kt @@ -228,7 +228,7 @@ class IncomingPaymentsTest { db.checkInCount(4, 3, 0) val original = genInPay("test 2") - val incomplete = original.copy(subject = null, debtorPayto = null) + val incomplete = original.copy(subject = null, debtor = null) // Register incomplete transaction registerIncomingPayment(db, cfg, incomplete) db.checkInCount(5, 3, 0) @@ -267,7 +267,7 @@ class IncomingPaymentsTest { db.checkInCount(4, 2, 1) val original = genInPay("test 2 with ${EddsaPublicKey.randEdsaKey()} reserve pub") - val incomplete = original.copy(subject = null, debtorPayto = null) + val incomplete = original.copy(subject = null, debtor = null) // Register incomplete transaction registerIncomingPayment(db, cfg, incomplete) db.checkInCount(5, 2, 1) diff --git a/nexus/src/test/kotlin/Iso20022Test.kt b/nexus/src/test/kotlin/Iso20022Test.kt @@ -150,21 +150,21 @@ class Iso20022Test { amount = TalerAmount("CHF:3.00"), subject = null, executionTime = dateToInstant("2024-01-15"), - creditorPayto = null + creditor = null ), IncomingPayment( - bankId = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCR9T"), + id = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCR9T"), amount = TalerAmount("CHF:10"), subject = "G1XTY6HGWGMVRM7E6XQ4JHJK561ETFDFTJZ7JVGV543XZCB27YBG", executionTime = dateToInstant("2023-12-19"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), IncomingPayment( - bankId = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCVR1"), + id = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCVR1"), amount = TalerAmount("CHF:2.53"), subject = "G1XTY6HGWGMVRM7E6XQ4JHJK561ETFDFTJZ7JVGV543XZCB27YB", executionTime = dateToInstant("2023-12-19"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), OutgoingReversal( endToEndId = "50820f78-9024-44ff-978d-63a18c", @@ -223,7 +223,7 @@ class Iso20022Test { amount = TalerAmount("EUR:2"), subject = "TestABC123", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), OutgoingReversal( endToEndId = "8XK8Z7RAX224FGWK832FD40GYC", @@ -231,11 +231,11 @@ class Iso20022Test { executionTime = dateToInstant("2024-09-05") ), IncomingPayment( - bankId = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), + id = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), amount = TalerAmount("EUR:3"), subject = "Taler FJDQ7W6G7NWX4H9M1MKA12090FRC9K7DA6N0FANDZZFXTR6QHX5G Test.,-", executionTime = dateToInstant("2024-04-12"), - debtorPayto = ibanPayto("DE84500105177118117964", "John Smith") + debtor = ibanPayto("DE84500105177118117964", "John Smith") ), OutgoingReversal( endToEndId = "COMPAT_FAILURE", @@ -247,14 +247,14 @@ class Iso20022Test { amount = TalerAmount("EUR:1.1"), subject = "single 2024-09-02T14:29:52.875253314Z", executionTime = dateToInstant("2024-09-02"), - creditorPayto = ibanPayto("DE89500105173198527518", "Grothoff Hans") + creditor = ibanPayto("DE89500105173198527518", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId("YF5QBARGQ0MNY0VK59S477VDG4", "YF5QBARGQ0MNY0VK59S477VDG4", "2024041810552821000"), amount = TalerAmount("EUR:1.1"), subject = "Simple tx", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), OutgoingBatch( msgId = "BATCH_MANY_SUCCESS", @@ -265,7 +265,7 @@ class Iso20022Test { amount = TalerAmount("EUR:0.42"), subject = "This should fail because bad iban", executionTime = dateToInstant("2024-09-23"), - creditorPayto = ibanPayto("DE18500105173385245163", "John Smith") + creditor = ibanPayto("DE18500105173385245163", "John Smith") ), OutgoingReversal( endToEndId = "KLJJ28S1LVNDK1R2HCHLN884M7EKM5XGM5", @@ -290,7 +290,7 @@ class Iso20022Test { amount = TalerAmount("EUR:2"), subject = "TestABC123", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), OutgoingReversal( endToEndId = "KGTDBASWTJ6JM89WXD3Q5KFQC4", @@ -302,11 +302,11 @@ class Iso20022Test { executionTime = dateToInstant("2024-09-04") ), IncomingPayment( - bankId = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), + id = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), amount = TalerAmount("EUR:3"), subject = "Taler FJDQ7W6G7NWX4H9M1MKA12090FRC9K7DA6N0FANDZZFXTR6QHX5G Test.,-", executionTime = dateToInstant("2024-04-12"), - debtorPayto = ibanPayto("DE84500105177118117964", "John Smith") + debtor = ibanPayto("DE84500105177118117964", "John Smith") ), OutgoingReversal( endToEndId = "COMPAT_FAILURE", @@ -318,14 +318,14 @@ class Iso20022Test { amount = TalerAmount("EUR:1.1"), subject = "single 2024-09-02T14:29:52.875253314Z", executionTime = dateToInstant("2024-09-02"), - creditorPayto = ibanPayto("DE89500105173198527518", "Grothoff Hans") + creditor = ibanPayto("DE89500105173198527518", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId("YF5QBARGQ0MNY0VK59S477VDG4", "YF5QBARGQ0MNY0VK59S477VDG4", "2024041810552821000"), amount = TalerAmount("EUR:1.1"), subject = "Simple tx", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), )) ) @@ -341,12 +341,11 @@ class Iso20022Test { currency = "EUR", txs = listOf<TxNotification>( IncomingPayment( - bankId = IncomingId(null, "IS11PGENODEFF2DA8899900378806", null), - //bankId = null, //"IS11PGENODEFF2DA8899900378806", + id = IncomingId(null, "IS11PGENODEFF2DA8899900378806", null), amount = TalerAmount("EUR:2.5"), subject = "Test ICT", executionTime = dateToInstant("2024-05-05"), - debtorPayto = ibanPayto("DE84500105177118117964", "Mr Test") + debtor = ibanPayto("DE84500105177118117964", "Mr Test") ) ) )) @@ -362,78 +361,78 @@ class Iso20022Test { currency = "CHF", txs = listOf<TxNotification>( IncomingPayment( - bankId = IncomingId("adbe4a5a-6cea-4263-b259-8ab964561a32", "41103099704.0002", "ZV20241104/765446/1"), + id = IncomingId("adbe4a5a-6cea-4263-b259-8ab964561a32", "41103099704.0002", "ZV20241104/765446/1"), amount = TalerAmount("CHF:1"), creditFee = TalerAmount("CHF:0.2"), subject = "SFHP6H24C16A5J05Q3FJW2XN1PB3EK70ZPY 5SJ30ADGY68FWN68G", executionTime = dateToInstant("2024-11-04"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), IncomingPayment( - bankId = IncomingId("7371795e-62fa-42dd-93b7-da89cc120faa", "41103099704.0003", "ZV20241104/765447/1"), + id = IncomingId("7371795e-62fa-42dd-93b7-da89cc120faa", "41103099704.0003", "ZV20241104/765447/1"), amount = TalerAmount("CHF:1"), creditFee = TalerAmount("CHF:0.2"), subject = "Random subject", executionTime = dateToInstant("2024-11-04"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), OutgoingPayment( id = OutgoingId("BATCH_SINGLE_REPORTING", "5IBJZOWESQGPCSOXSNNBBY49ZURI5W7Q4H", "ZV20241121/773541/1"), amount = TalerAmount("CHF:0.1"), subject = "multi 0 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId("BATCH_SINGLE_REPORTING", "XZ15UR0XU52QWI7Q4XB88EDS44PLH7DYXH", "ZV20241121/773541/4"), amount = TalerAmount("CHF:0.13"), subject = "multi 3 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId("BATCH_SINGLE_REPORTING", "A09R35EW0359SZ51464E7TC37A0P2CBK04", "ZV20241121/773541/3"), amount = TalerAmount("CHF:0.12"), subject = "multi 2 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId("BATCH_SINGLE_REPORTING", "UYXZ78LE9KAIMBY6UNXFYT1K8KNY8VLZLT", "ZV20241121/773541/2"), amount = TalerAmount("CHF:0.11"), subject = "multi 1 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), IncomingPayment( - bankId = IncomingId("f203fbb4-6e13-4c78-9b2a-d852fea6374a", "41202060702.0001", "ZV20241202/778108/1"), + id = IncomingId("f203fbb4-6e13-4c78-9b2a-d852fea6374a", "41202060702.0001", "ZV20241202/778108/1"), amount = TalerAmount("CHF:0.15"), creditFee = TalerAmount("CHF:0.2"), subject = "mini", executionTime = dateToInstant("2024-12-02"), - debtorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), IncomingPayment( - bankId = IncomingId("81b0d8c6-a677-4577-b75e-a639dcc03681", "41120636093.0001", "ZV20241121/773118/1"), + id = IncomingId("81b0d8c6-a677-4577-b75e-a639dcc03681", "41120636093.0001", "ZV20241121/773118/1"), amount = TalerAmount("CHF:0.1"), creditFee = TalerAmount("CHF:0.2"), subject = "small transfer test", executionTime = dateToInstant("2024-11-21"), - debtorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, null, "GB20241220/205792/1"), amount = TalerAmount("CHF:3000"), subject = null, executionTime = dateToInstant("2024-12-20"), - creditorPayto = null + creditor = null ), IncomingPayment( - bankId = IncomingId(null, null, "ZV20250114/796191/1"), + id = IncomingId(null, null, "ZV20250114/796191/1"), amount = TalerAmount("CHF:3003"), subject = "Fix bad payment by MB.", executionTime = dateToInstant("2025-01-27"), - debtorPayto = null + debtor = null ), ) )) diff --git a/nexus/src/test/kotlin/RegistrationTest.kt b/nexus/src/test/kotlin/RegistrationTest.kt @@ -121,7 +121,7 @@ class RegistrationTest { ) { all { IncomingPayment( - bankId = IncomingId( + id = IncomingId( it.getObject("uetr") as UUID?, it.getString("tx_id"), it.getString("acct_svcr_ref"), @@ -130,7 +130,7 @@ class RegistrationTest { creditFee = it.getAmount("credit_fee", this@check.bankCurrency).notZeroOrNull(), subject = it.getString("subject"), executionTime = it.getLong("execution_time").asInstant(), - debtorPayto = it.getOptIbanPayto("debit_payto"), + debtor = it.getOptIbanPayto("debit_payto"), ) } } @@ -156,7 +156,7 @@ class RegistrationTest { amount = it.getAmount("amount", this@check.bankCurrency), subject = it.getString("subject"), executionTime = it.getLong("execution_time").asInstant(), - creditorPayto = it.getOptIbanPayto("credit_payto"), + creditor = it.getOptIbanPayto("credit_payto"), ) } } @@ -336,11 +336,11 @@ class RegistrationTest { ), incoming = listOf( IncomingPayment( - bankId = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), + id = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"), amount = TalerAmount("EUR:3"), subject = "Taler FJDQ7W6G7NWX4H9M1MKA12090FRC9K7DA6N0FANDZZFXTR6QHX5G Test.,-", executionTime = dateToInstant("2024-04-12"), - debtorPayto = ibanPayto("DE84500105177118117964", "John Smith") + debtor = ibanPayto("DE84500105177118117964", "John Smith") ), ), outgoing = listOf( @@ -349,63 +349,63 @@ class RegistrationTest { amount = TalerAmount("EUR:2"), subject = "TestABC123", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), OutgoingPayment( id = OutgoingId(null, "FD622SMXKT5QWSAHDY0H8NYG3G", "2024090216552232000"), amount = TalerAmount("EUR:1.1"), subject = "single 2024-09-02T14:29:52.875253314Z", executionTime = dateToInstant("2024-09-02"), - creditorPayto = ibanPayto("DE89500105173198527518", "Grothoff Hans") + creditor = ibanPayto("DE89500105173198527518", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, "YF5QBARGQ0MNY0VK59S477VDG4", "2024041810552821000"), amount = TalerAmount("EUR:1.1"), subject = "Simple tx", executionTime = dateToInstant("2024-04-18"), - creditorPayto = ibanPayto("DE20500105172419259181", "John Smith") + creditor = ibanPayto("DE20500105172419259181", "John Smith") ), OutgoingPayment( id = OutgoingId(null, "IVMIGCUIE7Q7VOF73R8GU3KGRYBZPAYC5V", null), amount = TalerAmount("EUR:44"), subject = "init payment", executionTime = dateToInstant("2024-09-20"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test") + creditor = ibanPayto("CH4189144589712575493", "Test") ), OutgoingPayment( id = OutgoingId(null, "CDFN7I4FVIZ848DGDQ35DZ2K49H9EWXGAW", null), amount = TalerAmount("EUR:44"), subject = "init payment", executionTime = dateToInstant("2024-09-20"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test") + creditor = ibanPayto("CH4189144589712575493", "Test") ), OutgoingPayment( id = OutgoingId(null, "35M1268GW5ZFHS5JCB41UKDQNPMD40T849", null), amount = TalerAmount("EUR:44"), subject = "init payment", executionTime = dateToInstant("2024-09-20"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test") + creditor = ibanPayto("CH4189144589712575493", "Test") ), OutgoingPayment( id = OutgoingId(null, "HPOMV7A4E3P1TK9UZJS1WTM94A9V3X2SR1", null), amount = TalerAmount("EUR:44"), subject = "init payment", executionTime = dateToInstant("2024-09-20"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test") + creditor = ibanPayto("CH4189144589712575493", "Test") ), OutgoingPayment( id = OutgoingId(null, "KLJJ28S1LVNDK1R2HCHLN884M7EKM5XGM5", "2024092100252498000"), amount = TalerAmount("EUR:0.42"), subject = "This should fail because bad iban", executionTime = dateToInstant("2024-09-23"), - creditorPayto = ibanPayto("DE18500105173385245163", "John Smith") + creditor = ibanPayto("DE18500105173385245163", "John Smith") ), OutgoingPayment( id = OutgoingId(null, "27SK3166EG36SJ7VP7VFYP0MW8", null), amount = TalerAmount("EUR:44"), subject = "init payment", executionTime = dateToInstant("2024-09-04"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test") + creditor = ibanPayto("CH4189144589712575493", "Test") ), ) ) @@ -438,43 +438,43 @@ class RegistrationTest { ), incoming = listOf( IncomingPayment( - bankId = IncomingId("adbe4a5a-6cea-4263-b259-8ab964561a32", "41103099704.0002", "ZV20241104/765446/1"), + id = IncomingId("adbe4a5a-6cea-4263-b259-8ab964561a32", "41103099704.0002", "ZV20241104/765446/1"), amount = TalerAmount("CHF:1"), creditFee = TalerAmount("CHF:0.2"), subject = "SFHP6H24C16A5J05Q3FJW2XN1PB3EK70ZPY 5SJ30ADGY68FWN68G", executionTime = dateToInstant("2024-11-04"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), IncomingPayment( - bankId = IncomingId("7371795e-62fa-42dd-93b7-da89cc120faa", "41103099704.0003", "ZV20241104/765447/1"), + id = IncomingId("7371795e-62fa-42dd-93b7-da89cc120faa", "41103099704.0003", "ZV20241104/765447/1"), amount = TalerAmount("CHF:1"), creditFee = TalerAmount("CHF:0.2"), subject = "Random subject", executionTime = dateToInstant("2024-11-04"), - debtorPayto = ibanPayto("CH7389144832588726658", "Mr Test") + debtor = ibanPayto("CH7389144832588726658", "Mr Test") ), IncomingPayment( - bankId = IncomingId("f203fbb4-6e13-4c78-9b2a-d852fea6374a", "41202060702.0001", "ZV20241202/778108/1"), + id = IncomingId("f203fbb4-6e13-4c78-9b2a-d852fea6374a", "41202060702.0001", "ZV20241202/778108/1"), amount = TalerAmount("CHF:0.15"), creditFee = TalerAmount("CHF:0.2"), subject = "mini", executionTime = dateToInstant("2024-12-02"), - debtorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), IncomingPayment( - bankId = IncomingId("81b0d8c6-a677-4577-b75e-a639dcc03681", "41120636093.0001", "ZV20241121/773118/1"), + id = IncomingId("81b0d8c6-a677-4577-b75e-a639dcc03681", "41120636093.0001", "ZV20241121/773118/1"), amount = TalerAmount("CHF:0.1"), creditFee = TalerAmount("CHF:0.2"), subject = "small transfer test", executionTime = dateToInstant("2024-11-21"), - debtorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), IncomingPayment( - bankId = IncomingId(null, null, "ZV20250114/796191/1"), + id = IncomingId(null, null, "ZV20250114/796191/1"), amount = TalerAmount("CHF:3003"), subject = "Fix bad payment by MB.", executionTime = dateToInstant("2025-01-27"), - debtorPayto = null + debtor = null ), ), outgoing = listOf( @@ -483,35 +483,35 @@ class RegistrationTest { amount = TalerAmount("CHF:0.1"), subject = "multi 0 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, "XZ15UR0XU52QWI7Q4XB88EDS44PLH7DYXH", "ZV20241121/773541/4"), amount = TalerAmount("CHF:0.13"), subject = "multi 3 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, "A09R35EW0359SZ51464E7TC37A0P2CBK04", "ZV20241121/773541/3"), amount = TalerAmount("CHF:0.12"), subject = "multi 2 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, "UYXZ78LE9KAIMBY6UNXFYT1K8KNY8VLZLT", "ZV20241121/773541/2"), amount = TalerAmount("CHF:0.11"), subject = "multi 1 2024-11-21T15:21:59.8859234 63Z", executionTime = dateToInstant("2024-11-27"), - creditorPayto = ibanPayto("CH7389144832588726658", "Grothoff Hans") + creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans") ), OutgoingPayment( id = OutgoingId(null, null, "GB20241220/205792/1"), amount = TalerAmount("CHF:3000"), subject = null, executionTime = dateToInstant("2024-12-20"), - creditorPayto = null + creditor = null ), ) ) diff --git a/nexus/src/test/kotlin/helpers.kt b/nexus/src/test/kotlin/helpers.kt @@ -86,11 +86,11 @@ fun genInitPay( endToEndId: String, subject: String = "init payment", amount: String = "KUDOS:44", - creditorPayto: IbanPayto = ibanPayto("CH4189144589712575493", "Test") + creditor: IbanPayto = ibanPayto("CH4189144589712575493", "Test") ) = InitiatedPayment( id = -1, amount = TalerAmount(amount), - creditor = creditorPayto, + creditor = creditor, subject = subject, initiationTime = Instant.now(), endToEndId = endToEndId @@ -103,10 +103,10 @@ fun genInPay( executionTime: Instant = Instant.now() ) = IncomingPayment( amount = TalerAmount(amount), - debtorPayto = ibanPayto("DE84500105177118117964"), + debtor = ibanPayto("DE84500105177118117964"), subject = subject, executionTime = executionTime, - bankId = IncomingId(null, randEbicsId(), null) + id = IncomingId(null, randEbicsId(), null) ) /** Generates an outgoing payment, given its subject and end-to-end ID */ @@ -118,7 +118,7 @@ fun genOutPay( ) = OutgoingPayment( id = OutgoingId(msgId, endToEndId ?: randEbicsId(), null), amount = TalerAmount(44, 0, "KUDOS"), - creditorPayto = ibanPayto("CH4189144589712575493", "Test"), + creditor = ibanPayto("CH4189144589712575493", "Test"), subject = subject, executionTime = executionTime, ) @@ -175,7 +175,7 @@ suspend fun talerableIn(db: Database, amount: String = "CHF:44") { /** Register an incomplete talerable reserve incoming transaction */ suspend fun talerableIncompleteIn(db: Database) { val reserve_pub = EddsaPublicKey.randEdsaKey() - val incomplete = genInPay("test with $reserve_pub reserve pub").copy(subject = null, debtorPayto = null) + val incomplete = genInPay("test with $reserve_pub reserve pub").copy(subject = null, debtor = null) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), incomplete) } @@ -183,7 +183,7 @@ suspend fun talerableIncompleteIn(db: Database) { suspend fun talerableCompletedIn(db: Database) { val reserve_pub = EddsaPublicKey.randEdsaKey() val original = genInPay("test with $reserve_pub reserve pub") - val incomplete = original.copy(subject = null, debtorPayto = null) + val incomplete = original.copy(subject = null, debtor = null) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), incomplete) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), original) } @@ -203,14 +203,14 @@ suspend fun registerIn(db: Database) { /** Register an incomplete incoming transaction */ suspend fun registerIncompleteIn(db: Database) { - val incomplete = genInPay("ignored").copy(subject = null, debtorPayto = null) + val incomplete = genInPay("ignored").copy(subject = null, debtor = null) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), incomplete) } /** Register a completed incoming transaction */ suspend fun registerCompletedIn(db: Database) { val original = genInPay("ignored") - val incomplete = original.copy(subject = null, debtorPayto = null) + val incomplete = original.copy(subject = null, debtor = null) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), incomplete) registerIncomingPayment(db, NexusIngestConfig.default(AccountType.exchange), original) } @@ -223,7 +223,7 @@ suspend fun registerOut(db: Database) { /** Register an incomplete outgoing transaction */ suspend fun registerIncompleteOut(db: Database) { val original = genOutPay("ignored") - val incomplete = original.copy(id = OutgoingId(null, null, original.id.endToEndId), creditorPayto = null) + val incomplete = original.copy(id = OutgoingId(null, null, original.id.endToEndId), creditor = null) registerOutgoingPayment(db, incomplete) } diff --git a/testbench/src/test/kotlin/IntegrationTest.kt b/testbench/src/test/kotlin/IntegrationTest.kt @@ -169,10 +169,10 @@ class IntegrationTest { val reservePub = EddsaPublicKey.randEdsaKey() val reservePayment = IncomingPayment( amount = TalerAmount("EUR:10"), - debtorPayto = userPayTo, + debtor = userPayTo, subject = "Error test $reservePub", executionTime = Instant.now(), - bankId = IncomingId(null, "reserve_error", null) + id = IncomingId(null, "reserve_error", null) ) assertException("ERROR: cashin failed: missing exchange account") { @@ -183,7 +183,7 @@ class IntegrationTest { registerIncomingPayment( db, cfg, reservePayment.copy( - bankId = IncomingId(null, "kyc", null), + id = IncomingId(null, "kyc", null), subject = "Error test KYC:${EddsaPublicKey.randEdsaKey()}" ) ) @@ -234,7 +234,7 @@ class IntegrationTest { // Check success val validPayment = reservePayment.copy( subject = "Success $reservePub", - bankId = IncomingId(null, "success", null), + id = IncomingId(null, "success", null), ) registerIncomingPayment(db, cfg, validPayment) db.checkCount(3, 1, 2)