mirror of
https://github.com/corda/corda.git
synced 2025-02-01 08:48:09 +00:00
Cleaned up devModeOptions
This commit is contained in:
parent
8359fe9514
commit
cde1587ac7
@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="BankOfCordaDriverKt - Issue Web" type="JetRunConfigurationType" factoryName="Kotlin">
|
<configuration default="false" name="BankOfCordaDriverKt - Issue Web" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
|
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
|
||||||
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
|
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="--role ISSUE_CASH_WEB --quantity 100 --currency USD" />
|
<option name="PROGRAM_PARAMETERS" value="--role ISSUE_CASH_WEB --quantity 100 --currency USD" />
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="BankOfCordaDriverKt - Run Stack" type="JetRunConfigurationType" factoryName="Kotlin">
|
<configuration default="false" name="BankOfCordaDriverKt - Run Stack" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
|
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
|
||||||
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
|
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="--role ISSUER" />
|
<option name="PROGRAM_PARAMETERS" value="--role ISSUER" />
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Explorer - demo nodes" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
<configuration default="false" name="Explorer - demo nodes" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
|
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
|
||||||
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Explorer - demo nodes (simulation)" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
<configuration default="false" name="Explorer - demo nodes (simulation)" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
|
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
|
||||||
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="-S" />
|
<option name="PROGRAM_PARAMETERS" value="-S" />
|
||||||
|
@ -13,7 +13,7 @@ import java.net.URL
|
|||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
data class DevModeOptions(val disableCheckpointChecker: Boolean?)
|
data class DevModeOptions(val disableCheckpointChecker: Boolean = false)
|
||||||
|
|
||||||
interface NodeConfiguration : NodeSSLConfiguration {
|
interface NodeConfiguration : NodeSSLConfiguration {
|
||||||
// myLegalName should be only used in the initial network registration, we should use the name from the certificate instead of this.
|
// myLegalName should be only used in the initial network registration, we should use the name from the certificate instead of this.
|
||||||
@ -44,6 +44,7 @@ interface NodeConfiguration : NodeSSLConfiguration {
|
|||||||
val p2pAddress: NetworkHostAndPort
|
val p2pAddress: NetworkHostAndPort
|
||||||
val rpcAddress: NetworkHostAndPort?
|
val rpcAddress: NetworkHostAndPort?
|
||||||
val messagingServerAddress: NetworkHostAndPort?
|
val messagingServerAddress: NetworkHostAndPort?
|
||||||
|
// TODO Move into DevModeOptions
|
||||||
val useTestClock: Boolean get() = false
|
val useTestClock: Boolean get() = false
|
||||||
val detectPublicIp: Boolean get() = true
|
val detectPublicIp: Boolean get() = true
|
||||||
}
|
}
|
||||||
@ -81,11 +82,6 @@ data class ActiveMqServerConfiguration(val bridge: BridgeConfiguration)
|
|||||||
|
|
||||||
fun Config.parseAsNodeConfiguration(): NodeConfiguration = this.parseAs<NodeConfigurationImpl>()
|
fun Config.parseAsNodeConfiguration(): NodeConfiguration = this.parseAs<NodeConfigurationImpl>()
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of [NodeConfiguration]
|
|
||||||
* This should be private but it can't because its constructor needs to be invoked reflectively by [parseAs] and
|
|
||||||
* kotlin doesn't allow that.
|
|
||||||
*/
|
|
||||||
data class NodeConfigurationImpl(
|
data class NodeConfigurationImpl(
|
||||||
/** This is not retrieved from the config file but rather from a command line argument. */
|
/** This is not retrieved from the config file but rather from a command line argument. */
|
||||||
override val baseDirectory: Path,
|
override val baseDirectory: Path,
|
||||||
@ -101,6 +97,8 @@ data class NodeConfigurationImpl(
|
|||||||
override val minimumPlatformVersion: Int = 1,
|
override val minimumPlatformVersion: Int = 1,
|
||||||
override val rpcUsers: List<User>,
|
override val rpcUsers: List<User>,
|
||||||
override val verifierType: VerifierType,
|
override val verifierType: VerifierType,
|
||||||
|
// TODO typesafe config supports the notion of durations. Make use of that by mapping it to java.time.Duration.
|
||||||
|
// Then rename this to messageRedeliveryDelay and make it of type Duration
|
||||||
override val messageRedeliveryDelaySeconds: Int = 30,
|
override val messageRedeliveryDelaySeconds: Int = 30,
|
||||||
override val useHTTPS: Boolean,
|
override val useHTTPS: Boolean,
|
||||||
override val p2pAddress: NetworkHostAndPort,
|
override val p2pAddress: NetworkHostAndPort,
|
||||||
@ -115,6 +113,7 @@ data class NodeConfigurationImpl(
|
|||||||
override val useTestClock: Boolean = false,
|
override val useTestClock: Boolean = false,
|
||||||
override val detectPublicIp: Boolean = true,
|
override val detectPublicIp: Boolean = true,
|
||||||
override val activeMQServer: ActiveMqServerConfiguration,
|
override val activeMQServer: ActiveMqServerConfiguration,
|
||||||
|
// TODO See TODO above. Rename this to nodeInfoPollingFrequency and make it of type Duration
|
||||||
override val additionalNodeInfoPollingFrequencyMsec: Long = 5.seconds.toMillis()
|
override val additionalNodeInfoPollingFrequencyMsec: Long = 5.seconds.toMillis()
|
||||||
) : NodeConfiguration {
|
) : NodeConfiguration {
|
||||||
override val exportJMXto: String get() = "http"
|
override val exportJMXto: String get() = "http"
|
||||||
|
@ -31,7 +31,6 @@ import net.corda.node.internal.InitiatedFlowFactory
|
|||||||
import net.corda.node.services.api.Checkpoint
|
import net.corda.node.services.api.Checkpoint
|
||||||
import net.corda.node.services.api.CheckpointStorage
|
import net.corda.node.services.api.CheckpointStorage
|
||||||
import net.corda.node.services.api.ServiceHubInternal
|
import net.corda.node.services.api.ServiceHubInternal
|
||||||
import net.corda.node.services.config.NodeConfiguration
|
|
||||||
import net.corda.node.services.messaging.ReceivedMessage
|
import net.corda.node.services.messaging.ReceivedMessage
|
||||||
import net.corda.node.services.messaging.TopicSession
|
import net.corda.node.services.messaging.TopicSession
|
||||||
import net.corda.node.utilities.*
|
import net.corda.node.utilities.*
|
||||||
@ -89,9 +88,11 @@ class StateMachineManagerImpl(
|
|||||||
private val scheduler = FiberScheduler()
|
private val scheduler = FiberScheduler()
|
||||||
private val mutex = ThreadBox(InnerState())
|
private val mutex = ThreadBox(InnerState())
|
||||||
// This thread (only enabled in dev mode) deserialises checkpoints in the background to shake out bugs in checkpoint restore.
|
// 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.devMode
|
private val checkpointCheckerThread = if (serviceHub.configuration.devModeOptions?.disableCheckpointChecker != true) {
|
||||||
&& serviceHub.configuration.devModeOptions?.disableCheckpointChecker != true)
|
newNamedSingleThreadExecutor("CheckpointChecker")
|
||||||
newNamedSingleThreadExecutor("CheckpointChecker") else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
@Volatile private var unrestorableCheckpoints = false
|
@Volatile private var unrestorableCheckpoints = false
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package net.corda.node.services.config
|
package net.corda.node.services.config
|
||||||
|
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
import net.corda.core.utilities.seconds
|
|
||||||
import net.corda.nodeapi.User
|
|
||||||
import net.corda.testing.ALICE
|
import net.corda.testing.ALICE
|
||||||
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
||||||
import net.corda.testing.node.MockServices.Companion.makeTestDatabaseProperties
|
import net.corda.testing.node.MockServices.Companion.makeTestDatabaseProperties
|
||||||
@ -10,76 +8,49 @@ import org.assertj.core.api.Assertions.assertThatThrownBy
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.util.*
|
|
||||||
import kotlin.test.assertFalse
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class NodeConfigurationImplTest {
|
class NodeConfigurationImplTest {
|
||||||
@Test
|
@Test
|
||||||
fun `Can't have dev mode options if not in dev mode`() {
|
fun `can't have dev mode options if not in dev mode`() {
|
||||||
val testConfiguration = NodeConfigurationImpl(
|
val debugOptions = DevModeOptions()
|
||||||
baseDirectory = Paths.get("."),
|
|
||||||
myLegalName = ALICE.name,
|
|
||||||
networkMapService = null,
|
|
||||||
emailAddress = "",
|
|
||||||
keyStorePassword = "cordacadevpass",
|
|
||||||
trustStorePassword = "trustpass",
|
|
||||||
dataSourceProperties = makeTestDataSourceProperties(ALICE.name.organisation),
|
|
||||||
database = makeTestDatabaseProperties(),
|
|
||||||
certificateSigningService = URL("http://localhost"),
|
|
||||||
rpcUsers = emptyList(),
|
|
||||||
verifierType = VerifierType.InMemory,
|
|
||||||
useHTTPS = false,
|
|
||||||
p2pAddress = NetworkHostAndPort("localhost", 0),
|
|
||||||
rpcAddress = NetworkHostAndPort("localhost", 1),
|
|
||||||
messagingServerAddress = null,
|
|
||||||
notary = null,
|
|
||||||
certificateChainCheckPolicies = emptyList(),
|
|
||||||
devMode = true,
|
|
||||||
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)),
|
|
||||||
additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis())
|
|
||||||
|
|
||||||
fun configDebugOptions(devMode: Boolean, debugOptions: DevModeOptions?) {
|
|
||||||
testConfiguration.copy(devMode = devMode, devModeOptions = debugOptions)
|
|
||||||
}
|
|
||||||
val debugOptions = DevModeOptions(null)
|
|
||||||
configDebugOptions(true, debugOptions)
|
configDebugOptions(true, debugOptions)
|
||||||
configDebugOptions(true,null)
|
configDebugOptions(true, null)
|
||||||
assertThatThrownBy{configDebugOptions(false, debugOptions)}.hasMessageMatching( "Cannot use devModeOptions outside of dev mode" )
|
assertThatThrownBy { configDebugOptions(false, debugOptions) }.hasMessageMatching("Cannot use devModeOptions outside of dev mode")
|
||||||
configDebugOptions(false,null)
|
configDebugOptions(false, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `check devModeOptions flag helper`()
|
fun `check devModeOptions flag helper`() {
|
||||||
{
|
assertFalse { configDebugOptions(true, null).devModeOptions?.disableCheckpointChecker == true }
|
||||||
val testConfiguration = NodeConfigurationImpl(
|
assertFalse { configDebugOptions(true, DevModeOptions()).devModeOptions?.disableCheckpointChecker == true }
|
||||||
baseDirectory = Paths.get("."),
|
assertFalse { configDebugOptions(true, DevModeOptions(false)).devModeOptions?.disableCheckpointChecker == true }
|
||||||
myLegalName = ALICE.name,
|
assertTrue { configDebugOptions(true, DevModeOptions(true)).devModeOptions?.disableCheckpointChecker == true }
|
||||||
networkMapService = null,
|
|
||||||
emailAddress = "",
|
|
||||||
keyStorePassword = "cordacadevpass",
|
|
||||||
trustStorePassword = "trustpass",
|
|
||||||
dataSourceProperties = makeTestDataSourceProperties(ALICE.name.organisation),
|
|
||||||
database = makeTestDatabaseProperties(),
|
|
||||||
certificateSigningService = URL("http://localhost"),
|
|
||||||
rpcUsers = emptyList(),
|
|
||||||
verifierType = VerifierType.InMemory,
|
|
||||||
useHTTPS = false,
|
|
||||||
p2pAddress = NetworkHostAndPort("localhost", 0),
|
|
||||||
rpcAddress = NetworkHostAndPort("localhost", 1),
|
|
||||||
messagingServerAddress = null,
|
|
||||||
notary = null,
|
|
||||||
certificateChainCheckPolicies = emptyList(),
|
|
||||||
devMode = true,
|
|
||||||
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)),
|
|
||||||
additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis())
|
|
||||||
|
|
||||||
fun configDebugOptions(devMode: Boolean, devModeOptions: DevModeOptions?) : NodeConfiguration {
|
|
||||||
return testConfiguration.copy(devMode = devMode, devModeOptions = devModeOptions)
|
|
||||||
}
|
|
||||||
assertFalse { configDebugOptions(true,null).devModeOptions?.disableCheckpointChecker == true}
|
|
||||||
assertFalse { configDebugOptions(true,DevModeOptions(null)).devModeOptions?.disableCheckpointChecker == true}
|
|
||||||
assertFalse { configDebugOptions(true,DevModeOptions(false)).devModeOptions?.disableCheckpointChecker == true}
|
|
||||||
assert ( configDebugOptions(true,DevModeOptions(true)).devModeOptions?.disableCheckpointChecker == true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun configDebugOptions(devMode: Boolean, devModeOptions: DevModeOptions?) : NodeConfiguration {
|
||||||
|
return testConfiguration.copy(devMode = devMode, devModeOptions = devModeOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val testConfiguration = NodeConfigurationImpl(
|
||||||
|
baseDirectory = Paths.get("."),
|
||||||
|
myLegalName = ALICE.name,
|
||||||
|
networkMapService = null,
|
||||||
|
emailAddress = "",
|
||||||
|
keyStorePassword = "cordacadevpass",
|
||||||
|
trustStorePassword = "trustpass",
|
||||||
|
dataSourceProperties = makeTestDataSourceProperties(ALICE.name.organisation),
|
||||||
|
database = makeTestDatabaseProperties(),
|
||||||
|
certificateSigningService = URL("http://localhost"),
|
||||||
|
rpcUsers = emptyList(),
|
||||||
|
verifierType = VerifierType.InMemory,
|
||||||
|
useHTTPS = false,
|
||||||
|
p2pAddress = NetworkHostAndPort("localhost", 0),
|
||||||
|
rpcAddress = NetworkHostAndPort("localhost", 1),
|
||||||
|
messagingServerAddress = null,
|
||||||
|
notary = null,
|
||||||
|
certificateChainCheckPolicies = emptyList(),
|
||||||
|
devMode = true,
|
||||||
|
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)))
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,9 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
doReturn(myInfo).whenever(it).myInfo
|
doReturn(myInfo).whenever(it).myInfo
|
||||||
doReturn(kms).whenever(it).keyManagementService
|
doReturn(kms).whenever(it).keyManagementService
|
||||||
doReturn(CordappProviderImpl(CordappLoader.createWithTestPackages(listOf("net.corda.testing.contracts")), MockAttachmentStorage())).whenever(it).cordappProvider
|
doReturn(CordappProviderImpl(CordappLoader.createWithTestPackages(listOf("net.corda.testing.contracts")), MockAttachmentStorage())).whenever(it).cordappProvider
|
||||||
doCallRealMethod().whenever(it).recordTransactions(any<StatesToRecord>(), any<Iterable<SignedTransaction>>())
|
doCallRealMethod().whenever(it).recordTransactions(any<StatesToRecord>(), any())
|
||||||
doCallRealMethod().whenever(it).recordTransactions(any<Iterable<SignedTransaction>>())
|
doCallRealMethod().whenever(it).recordTransactions(any<Iterable<SignedTransaction>>())
|
||||||
doCallRealMethod().whenever(it).recordTransactions(any<SignedTransaction>(), anyVararg<SignedTransaction>())
|
doCallRealMethod().whenever(it).recordTransactions(any<SignedTransaction>(), anyVararg())
|
||||||
doReturn(NodeVaultService(testClock, kms, stateLoader, database.hibernateConfig)).whenever(it).vaultService
|
doReturn(NodeVaultService(testClock, kms, stateLoader, database.hibernateConfig)).whenever(it).vaultService
|
||||||
doReturn(this@NodeSchedulerServiceTest).whenever(it).testReference
|
doReturn(this@NodeSchedulerServiceTest).whenever(it).testReference
|
||||||
|
|
||||||
@ -142,6 +142,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
|
|
||||||
// Ignore IntelliJ when it says these properties can be private, if they are we cannot serialise them
|
// Ignore IntelliJ when it says these properties can be private, if they are we cannot serialise them
|
||||||
// in AMQP.
|
// in AMQP.
|
||||||
|
@Suppress("MemberVisibilityCanPrivate")
|
||||||
class TestState(val flowLogicRef: FlowLogicRef, val instant: Instant, val myIdentity: Party) : LinearState, SchedulableState {
|
class TestState(val flowLogicRef: FlowLogicRef, val instant: Instant, val myIdentity: Party) : LinearState, SchedulableState {
|
||||||
override val participants: List<AbstractParty>
|
override val participants: List<AbstractParty>
|
||||||
get() = listOf(myIdentity)
|
get() = listOf(myIdentity)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user