[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: make test case pass
From: |
gnunet |
Subject: |
[libeufin] branch master updated: make test case pass |
Date: |
Mon, 08 Jun 2020 11:32:02 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new daecfe6 make test case pass
daecfe6 is described below
commit daecfe6cf5ce379a20ec10f9f65262cb770e3447
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Mon Jun 8 15:01:52 2020 +0530
make test case pass
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 8 +--
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 2 +-
nexus/src/test/kotlin/DBTest.kt | 18 +++--
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 1 +
sandbox/src/test/kotlin/DBTest.kt | 78 ++++++++++++++--------
5 files changed, 65 insertions(+), 42 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 67e09e8..15a79bf 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -143,7 +143,7 @@ class RawBankTransactionEntity(id: EntityID<Long>) :
LongEntity(id) {
*/
object PreparedPaymentsTable : IdTable<String>() {
/** the UUID representing this payment in the system */
- override val id = varchar("id", ID_MAX_LENGTH).entityId().primaryKey()
+ override val id = varchar("id", ID_MAX_LENGTH).entityId()
val paymentId = long("paymentId")
val preparationDate = long("preparationDate")
val submissionDate = long("submissionDate").nullable()
@@ -188,7 +188,7 @@ class PreparedPaymentEntity(id: EntityID<String>) :
Entity<String>(id) {
* This table holds triples of <iban, bic, holder name>.
*/
object NexusBankAccountsTable : IdTable<String>() {
- override val id = varchar("id", ID_MAX_LENGTH).primaryKey().entityId()
+ override val id = varchar("id", ID_MAX_LENGTH).entityId()
val accountHolder = text("accountHolder")
val iban = text("iban")
val bankCode = text("bankCode")
@@ -241,7 +241,6 @@ class EbicsSubscriberEntity(id: EntityID<Int>) :
IntEntity(id) {
object NexusUsersTable : IdTable<String>() {
override val id = varchar("id", ID_MAX_LENGTH).entityId()
- override val primaryKey = PrimaryKey(id, name = "id")
val passwordHash = text("password")
val superuser = bool("superuser")
}
@@ -253,7 +252,7 @@ class NexusUserEntity(id: EntityID<String>) :
Entity<String>(id) {
}
object NexusBankConnectionsTable : IdTable<String>() {
- override val id =
NexusBankConnectionsTable.text("id").entityId().primaryKey()
+ override val id = NexusBankConnectionsTable.text("id").entityId()
val type = text("type")
val owner = reference("user", NexusUsersTable)
}
@@ -266,7 +265,6 @@ class NexusBankConnectionEntity(id: EntityID<String>) :
Entity<String>(id) {
object FacadesTable : IdTable<String>() {
override val id = FacadesTable.text("id").entityId()
- override val primaryKey = PrimaryKey(id, name = "id")
val type = text("type")
val creator = reference("creator", NexusUsersTable)
val highestSeenMsgID = long("highestSeenMessageID").default(0)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index a8837a7..3cbcdfc 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -430,7 +430,7 @@ fun serverMain(dbName: String) {
return@intercept
}
- schedulePeriodicWork()
+ //schedulePeriodicWork()
routing {
/**
* Shows information about the requesting user.
diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt
index 586707c..8b86382 100644
--- a/nexus/src/test/kotlin/DBTest.kt
+++ b/nexus/src/test/kotlin/DBTest.kt
@@ -44,22 +44,20 @@ class DBTest {
TalerFacadeStatesTable,
NexusUsersTable
)
- val talerConfig = TalerFacadeStateEntity.new {
- bankAccount = "b"
- bankConnection = "b"
- reserveTransferLevel = "any"
- intervalIncrement = "any"
- }
- talerConfig.flush()
val user = NexusUserEntity.new("u") {
passwordHash = "x"
superuser = true
}
- FacadeEntity.new("my-id") {
+ val facade = FacadeEntity.new("my-id") {
type = "any"
creator = user
- config = talerConfig
- highestSeenMsgID = 0
+ }
+ val talerConfig = TalerFacadeStateEntity.new {
+ bankAccount = "b"
+ bankConnection = "b"
+ reserveTransferLevel = "any"
+ intervalIncrement = "any"
+ this.facade = facade
}
}
}
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index ce0db3d..9f4c542 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -871,6 +871,7 @@ private fun
handleEbicsUploadTransactionInitialization(requestContext: RequestCo
this.numSegments = numSegments.toInt()
this.transactionKeyEnc = ExposedBlob(transactionKeyEnc)
}.flush()
+ logger.debug("after SQL flush")
val sigObj =
XMLUtil.convertStringToJaxb<UserSignatureData>(plainSigData.toString(Charsets.UTF_8))
logger.debug("got UserSignatureData:
${plainSigData.toString(Charsets.UTF_8)}")
for (sig in sigObj.value.orderSignatureList ?: listOf()) {
diff --git a/sandbox/src/test/kotlin/DBTest.kt
b/sandbox/src/test/kotlin/DBTest.kt
index 7de3db3..4f859cd 100644
--- a/sandbox/src/test/kotlin/DBTest.kt
+++ b/sandbox/src/test/kotlin/DBTest.kt
@@ -9,10 +9,35 @@ import tech.libeufin.sandbox.PaymentEntity
import tech.libeufin.sandbox.PaymentsTable
import tech.libeufin.util.millis
import tech.libeufin.util.parseDashedDate
+import java.io.File
import java.sql.Connection
import java.time.Instant
import java.time.LocalDateTime
+/**
+ * Run a block after connecting to the test database.
+ * Cleans up the DB file afterwards.
+ */
+fun withTestDatabase(f: () -> Unit) {
+ val dbfile = "nexus-test.sqlite3"
+ File(dbfile).also {
+ if (it.exists()) {
+ it.delete()
+ }
+ }
+ Database.connect("jdbc:sqlite:$dbfile", "org.sqlite.JDBC")
+ try {
+ f()
+ }
+ finally {
+ File(dbfile).also {
+ if (it.exists()) {
+ it.delete()
+ }
+ }
+ }
+}
+
class DBTest {
@Test
fun exist() {
@@ -21,33 +46,34 @@ class DBTest {
@Test
fun betweenDates() {
- Database.connect("jdbc:sqlite:sandbox-test.sqlite3", "org.sqlite.JDBC")
- TransactionManager.manager.defaultIsolationLevel =
Connection.TRANSACTION_SERIALIZABLE
- transaction {
- SchemaUtils.create(PaymentsTable)
- PaymentEntity.new {
- creditorIban = "earns"
- creditorBic = "BIC"
- creditorName = "Creditor Name"
- debitorIban = "spends"
- debitorBic = "BIC"
- debitorName = "Debitor Name"
- subject = "deal"
- amount = "EUR:1"
- date = LocalDateTime.now().millis()
+ withTestDatabase {
+ transaction {
+ SchemaUtils.create(PaymentsTable)
+ PaymentEntity.new {
+ creditorIban = "earns"
+ creditorBic = "BIC"
+ creditorName = "Creditor Name"
+ debitorIban = "spends"
+ debitorBic = "BIC"
+ debitorName = "Debitor Name"
+ subject = "deal"
+ amount = "EUR:1"
+ date = LocalDateTime.now().millis()
+ currency = "EUR"
+ }
}
+ val result = transaction {
+ addLogger(StdOutSqlLogger)
+ PaymentEntity.find {
+ PaymentsTable.date.between(
+ parseDashedDate(
+ "1970-01-01"
+ ).millis(),
+ LocalDateTime.now().millis()
+ )
+ }.firstOrNull()
+ }
+ assert(result != null)
}
- val result = transaction {
- addLogger(StdOutSqlLogger)
- PaymentEntity.find {
- PaymentsTable.date.between(
- parseDashedDate(
- "1970-01-01"
- ).millis(),
- LocalDateTime.now().millis()
- )
- }.firstOrNull()
- }
- assert(result != null)
}
}
\ No newline at end of file
--
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: make test case pass,
gnunet <=