Skip to content

Commit

Permalink
CORDA-1003: Fix duplicate detection on cache evict (corda#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
exFalso authored and Katelyn Baker committed Feb 12, 2018
1 parent 10f3c0b commit 805178d
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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(NodeConfiguration.defaultTransactionCacheSize)
transactionStorage = DBTransactionStorage(cacheSizeBytesOverride ?: NodeConfiguration.defaultTransactionCacheSize)
}
}

Expand Down

0 comments on commit 805178d

Please sign in to comment.