-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb9a31f
commit e66d1e9
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
database/src/main/resources/db/migration/V1_91__Create_tx_processing_failures_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); |
61 changes: 61 additions & 0 deletions
61
...e/src/test/kotlin/io/provenance/explorer/domain/entities/TxProcessingFailuresTableTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / ktlint
|
||
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 | ||
(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() | ||
// | ||
// } | ||
// } | ||
} |