Skip to content

Commit

Permalink
update entitiy, start test
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Aug 26, 2024
1 parent bb9a31f commit e66d1e9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
SELECT 'Create tx_processing_failures table' AS comment;

CREATE TABLE IF NOT EXISTS tx_processing_failures (
id SERIAL PRIMARY KEY,
block_height INT NOT NULL,
tx_hash VARCHAR(128) NOT NULL,
process_type VARCHAR(64) NOT NULL,
failure_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
error_message TEXT DEFAULT NULL,
retried BOOLEAN NOT NULL DEFAULT FALSE,
success BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (block_height, tx_hash, process_type)
UNIQUE (block_height, tx_hash, process_type)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import io.provenance.explorer.domain.entities.TxProcessingFailureRecord

Check failure on line 1 in service/src/test/kotlin/io/provenance/explorer/domain/entities/TxProcessingFailuresTableTest.kt

View workflow job for this annotation

GitHub Actions / ktlint

Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
import io.provenance.explorer.domain.entities.TxProcessingFailuresTable
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.Database
import org.junit.jupiter.api.Test

class TxProcessingFailureRecordTest {

@Test
fun testInsertOrUpdate_newRecord() {
Database.connect("jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;", driver = "org.h2.Driver")
transaction {
val sql = this::class.java.getResource("/db/migration/V1_91__Create_tx_processing_failures_table.sql")!!.readText()
exec(sql)
}
transaction {
TxProcessingFailureRecord.insertOrUpdate(
blockHeight = 100,
txHash = "testHash",
processType = "testProcess",
errorMessage = "testError",
success = false
)

val record = TxProcessingFailureRecord.find {
(TxProcessingFailuresTable.blockHeight eq 100) and
(TxProcessingFailuresTable.txHash eq "testHash") and

Check failure on line 28 in service/src/test/kotlin/io/provenance/explorer/domain/entities/TxProcessingFailuresTableTest.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (24) (should be 20)
(TxProcessingFailuresTable.processType eq "testProcess")
}.firstOrNull()
}
}

// @Test
// fun testInsertOrUpdate_updateRecord() {
// transaction {
// TxProcessingFailureRecord.insertOrUpdate(
// blockHeight = 100,
// txHash = "testHash",
// processType = "testProcess",
// errorMessage = "testError",
// success = false
// )
//
// TxProcessingFailureRecord.insertOrUpdate(
// blockHeight = 100,
// txHash = "testHash",
// processType = "testProcess",
// errorMessage = "updatedError",
// success = true
// )
//
// val record = TxProcessingFailureRecord.find {
// (TxProcessingFailuresTable.blockHeight eq 100) and
// (TxProcessingFailuresTable.txHash eq "testHash") and
// (TxProcessingFailuresTable.processType eq "testProcess")
// }.firstOrNull()
//
// }
// }
}

0 comments on commit e66d1e9

Please sign in to comment.