Add helper for checking whether to check checkpoints and unit test it.

This commit is contained in:
Christian Sailer 2017-10-30 11:55:04 +00:00
parent 0d4c2d3526
commit 3f43d8ad21
3 changed files with 10 additions and 5 deletions

View File

@ -49,6 +49,10 @@ interface NodeConfiguration : NodeSSLConfiguration {
val detectPublicIp: Boolean get() = true
}
fun NodeConfiguration.shouldCheckCheckpoints(): Boolean{
return this.devMode && this.devModeOptions?.disableCheckpointChecker != true
}
data class NotaryConfig(val validating: Boolean,
val raft: RaftConfig? = null,
val bftSMaRt: BFTSMaRtConfiguration? = null,

View File

@ -31,6 +31,7 @@ import net.corda.node.internal.InitiatedFlowFactory
import net.corda.node.services.api.Checkpoint
import net.corda.node.services.api.CheckpointStorage
import net.corda.node.services.api.ServiceHubInternal
import net.corda.node.services.config.shouldCheckCheckpoints
import net.corda.node.services.messaging.ReceivedMessage
import net.corda.node.services.messaging.TopicSession
import net.corda.node.utilities.*
@ -88,7 +89,7 @@ class StateMachineManagerImpl(
private val scheduler = FiberScheduler()
private val mutex = ThreadBox(InnerState())
// This thread (only enabled in dev mode) deserialises checkpoints in the background to shake out bugs in checkpoint restore.
private val checkpointCheckerThread = if (serviceHub.configuration.devModeOptions?.disableCheckpointChecker != true) {
private val checkpointCheckerThread = if (serviceHub.configuration.shouldCheckCheckpoints()) {
newNamedSingleThreadExecutor("CheckpointChecker")
} else {
null

View File

@ -23,10 +23,10 @@ class NodeConfigurationImplTest {
@Test
fun `check devModeOptions flag helper`() {
assertFalse { configDebugOptions(true, null).devModeOptions?.disableCheckpointChecker == true }
assertFalse { configDebugOptions(true, DevModeOptions()).devModeOptions?.disableCheckpointChecker == true }
assertFalse { configDebugOptions(true, DevModeOptions(false)).devModeOptions?.disableCheckpointChecker == true }
assertTrue { configDebugOptions(true, DevModeOptions(true)).devModeOptions?.disableCheckpointChecker == true }
assertTrue { configDebugOptions(true, null).shouldCheckCheckpoints() }
assertTrue { configDebugOptions(true, DevModeOptions()).shouldCheckCheckpoints() }
assertTrue { configDebugOptions(true, DevModeOptions(false)).shouldCheckCheckpoints() }
assertFalse { configDebugOptions(true, DevModeOptions(true)).shouldCheckCheckpoints() }
}
private fun configDebugOptions(devMode: Boolean, devModeOptions: DevModeOptions?) : NodeConfiguration {