CORDA-1003: Fix duplicate detection on cache evict (#2499)

This commit is contained in:
Andras Slemmer 2018-02-12 10:17:34 +00:00 committed by Katelyn Baker
parent 10f3c0bcf9
commit 805178debc

View File

@ -172,9 +172,22 @@ class DBTransactionStorageTests {
assertEquals(expected, actual)
}
private fun newTransactionStorage() {
@Test
fun `duplicates are detected when transaction is evicted from cache`() {
newTransactionStorage(cacheSizeBytesOverride = 0)
val transaction = newTransaction()
database.transaction {
transactionStorage = DBTransactionStorage(NodeConfiguration.defaultTransactionCacheSize)
val firstInserted = transactionStorage.addTransaction(transaction)
val secondInserted = transactionStorage.addTransaction(transaction)
require(firstInserted) { "We inserted a fresh transaction" }
require(!secondInserted) { "Second time should be redundant" }
println("$firstInserted $secondInserted")
}
}
private fun newTransactionStorage(cacheSizeBytesOverride: Long? = null) {
database.transaction {
transactionStorage = DBTransactionStorage(cacheSizeBytesOverride ?: NodeConfiguration.defaultTransactionCacheSize)
}
}