mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
CORDA-2269: Removed DriverParameters.initialiseSerialization as it's not needed (#4321)
This commit is contained in:
parent
5d1652bacb
commit
9100636b8c
@ -5893,8 +5893,6 @@ public interface net.corda.testing.driver.DriverDSL
|
|||||||
public final class net.corda.testing.driver.DriverParameters extends java.lang.Object
|
public final class net.corda.testing.driver.DriverParameters extends java.lang.Object
|
||||||
public <init>()
|
public <init>()
|
||||||
public <init>(boolean, java.nio.file.Path, net.corda.testing.driver.PortAllocation, net.corda.testing.driver.PortAllocation, java.util.Map<String, String>, boolean, boolean, boolean, java.util.List<net.corda.testing.node.NotarySpec>, java.util.List<String>, net.corda.testing.driver.JmxPolicy, net.corda.core.node.NetworkParameters)
|
public <init>(boolean, java.nio.file.Path, net.corda.testing.driver.PortAllocation, net.corda.testing.driver.PortAllocation, java.util.Map<String, String>, boolean, boolean, boolean, java.util.List<net.corda.testing.node.NotarySpec>, java.util.List<String>, net.corda.testing.driver.JmxPolicy, net.corda.core.node.NetworkParameters)
|
||||||
public <init>(boolean, java.nio.file.Path, net.corda.testing.driver.PortAllocation, net.corda.testing.driver.PortAllocation, java.util.Map<String, String>, boolean, boolean, boolean, java.util.List<net.corda.testing.node.NotarySpec>, java.util.List<String>, net.corda.testing.driver.JmxPolicy, net.corda.core.node.NetworkParameters, java.util.Map<String, ?>, boolean, boolean)
|
|
||||||
public <init>(boolean, java.nio.file.Path, net.corda.testing.driver.PortAllocation, net.corda.testing.driver.PortAllocation, java.util.Map<String, String>, boolean, boolean, boolean, java.util.List<net.corda.testing.node.NotarySpec>, java.util.List<String>, net.corda.testing.driver.JmxPolicy, net.corda.core.node.NetworkParameters, boolean, boolean)
|
|
||||||
public final boolean component1()
|
public final boolean component1()
|
||||||
@NotNull
|
@NotNull
|
||||||
public final java.util.List<String> component10()
|
public final java.util.List<String> component10()
|
||||||
|
@ -5,7 +5,6 @@ import net.corda.core.KeepForDJVM
|
|||||||
import net.corda.core.internal.InheritableThreadLocalToggleField
|
import net.corda.core.internal.InheritableThreadLocalToggleField
|
||||||
import net.corda.core.internal.SimpleToggleField
|
import net.corda.core.internal.SimpleToggleField
|
||||||
import net.corda.core.internal.ThreadLocalToggleField
|
import net.corda.core.internal.ThreadLocalToggleField
|
||||||
import net.corda.core.internal.VisibleForTesting
|
|
||||||
import net.corda.core.serialization.SerializationContext
|
import net.corda.core.serialization.SerializationContext
|
||||||
import net.corda.core.serialization.SerializationFactory
|
import net.corda.core.serialization.SerializationFactory
|
||||||
|
|
||||||
@ -71,11 +70,13 @@ private class SerializationEnvironmentImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val _nodeSerializationEnv = SimpleToggleField<SerializationEnvironment>("nodeSerializationEnv", true)
|
private val _nodeSerializationEnv = SimpleToggleField<SerializationEnvironment>("nodeSerializationEnv", true)
|
||||||
@VisibleForTesting
|
/** Should be set once in main. */
|
||||||
val _globalSerializationEnv = SimpleToggleField<SerializationEnvironment>("globalSerializationEnv")
|
var nodeSerializationEnv by _nodeSerializationEnv
|
||||||
@VisibleForTesting
|
|
||||||
|
val _driverSerializationEnv = SimpleToggleField<SerializationEnvironment>("driverSerializationEnv")
|
||||||
|
|
||||||
val _contextSerializationEnv = ThreadLocalToggleField<SerializationEnvironment>("contextSerializationEnv")
|
val _contextSerializationEnv = ThreadLocalToggleField<SerializationEnvironment>("contextSerializationEnv")
|
||||||
@VisibleForTesting
|
|
||||||
val _inheritableContextSerializationEnv = InheritableThreadLocalToggleField<SerializationEnvironment>("inheritableContextSerializationEnv") { stack ->
|
val _inheritableContextSerializationEnv = InheritableThreadLocalToggleField<SerializationEnvironment>("inheritableContextSerializationEnv") { stack ->
|
||||||
stack.fold(false) { isAGlobalThreadBeingCreated, e ->
|
stack.fold(false) { isAGlobalThreadBeingCreated, e ->
|
||||||
isAGlobalThreadBeingCreated ||
|
isAGlobalThreadBeingCreated ||
|
||||||
@ -83,12 +84,17 @@ val _inheritableContextSerializationEnv = InheritableThreadLocalToggleField<Seri
|
|||||||
(e.className == "java.util.concurrent.ForkJoinPool\$DefaultForkJoinWorkerThreadFactory" && e.methodName == "newThread")
|
(e.className == "java.util.concurrent.ForkJoinPool\$DefaultForkJoinWorkerThreadFactory" && e.methodName == "newThread")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val serializationEnvProperties = listOf(_nodeSerializationEnv, _globalSerializationEnv, _contextSerializationEnv, _inheritableContextSerializationEnv)
|
|
||||||
|
private val serializationEnvFields = listOf(_nodeSerializationEnv, _driverSerializationEnv, _contextSerializationEnv, _inheritableContextSerializationEnv)
|
||||||
|
|
||||||
|
val _allEnabledSerializationEnvs: List<Pair<String, SerializationEnvironment>>
|
||||||
|
get() = serializationEnvFields.mapNotNull { it.get()?.let { env -> Pair(it.name, env) } }
|
||||||
|
|
||||||
val effectiveSerializationEnv: SerializationEnvironment
|
val effectiveSerializationEnv: SerializationEnvironment
|
||||||
get() = serializationEnvProperties.map { Pair(it, it.get()) }.filter { it.second != null }.run {
|
get() {
|
||||||
singleOrNull()?.run {
|
return _allEnabledSerializationEnvs.let {
|
||||||
second!!
|
checkNotNull(it.singleOrNull()?.second) {
|
||||||
} ?: throw IllegalStateException("Expected exactly 1 of {${serializationEnvProperties.joinToString(", ") { it.name }}} but got: {${joinToString(", ") { it.first.name }}}")
|
"Expected exactly 1 of {${serializationEnvFields.joinToString(", ") { it.name }}} but got: {${it.joinToString(", ") { it.first }}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/** Should be set once in main. */
|
|
||||||
var nodeSerializationEnv by _nodeSerializationEnv
|
|
||||||
|
@ -90,7 +90,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList()
|
notarySpecs = emptyList()
|
||||||
) {
|
) {
|
||||||
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow() as NodeHandleInternal
|
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow() as NodeHandleInternal
|
||||||
@ -143,7 +142,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList()
|
notarySpecs = emptyList()
|
||||||
) {
|
) {
|
||||||
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
|
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
|
||||||
@ -161,7 +159,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList()
|
notarySpecs = emptyList()
|
||||||
) {
|
) {
|
||||||
val (aliceNode, bobNode) = listOf(
|
val (aliceNode, bobNode) = listOf(
|
||||||
@ -179,7 +176,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList()
|
notarySpecs = emptyList()
|
||||||
) {
|
) {
|
||||||
val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
|
val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
|
||||||
@ -201,7 +197,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList()
|
notarySpecs = emptyList()
|
||||||
) {
|
) {
|
||||||
val (aliceNode, bobNode) = listOf(
|
val (aliceNode, bobNode) = listOf(
|
||||||
@ -226,7 +221,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = emptyList(),
|
notarySpecs = emptyList(),
|
||||||
systemProperties = mapOf("net.corda.node.internal.nodeinfo.publish.interval" to 1.seconds.toString())
|
systemProperties = mapOf("net.corda.node.internal.nodeinfo.publish.interval" to 1.seconds.toString())
|
||||||
) {
|
) {
|
||||||
|
@ -87,7 +87,6 @@ class NodeRegistrationTest {
|
|||||||
internalDriver(
|
internalDriver(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
compatibilityZone = compatibilityZone,
|
compatibilityZone = compatibilityZone,
|
||||||
initialiseSerialization = false,
|
|
||||||
notarySpecs = listOf(NotarySpec(notaryName)),
|
notarySpecs = listOf(NotarySpec(notaryName)),
|
||||||
cordappsForAllNodes = cordappsInCurrentAndAdditionalPackages("net.corda.finance"),
|
cordappsForAllNodes = cordappsInCurrentAndAdditionalPackages("net.corda.finance"),
|
||||||
notaryCustomOverrides = mapOf("devMode" to false)
|
notaryCustomOverrides = mapOf("devMode" to false)
|
||||||
|
@ -98,8 +98,7 @@ data class WebserverHandle(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract helper class which is used within the driver to allocate unused ports for testing. Use either
|
* An abstract helper class which is used within the driver to allocate unused ports for testing.
|
||||||
* the [Incremental] or [RandomFree] concrete implementations.
|
|
||||||
*/
|
*/
|
||||||
@DoNotImplement
|
@DoNotImplement
|
||||||
abstract class PortAllocation {
|
abstract class PortAllocation {
|
||||||
@ -159,8 +158,7 @@ fun <A> driver(defaultParameters: DriverParameters = DriverParameters(), dsl: Dr
|
|||||||
signCordapps = false
|
signCordapps = false
|
||||||
),
|
),
|
||||||
coerce = { it },
|
coerce = { it },
|
||||||
dsl = dsl,
|
dsl = dsl
|
||||||
initialiseSerialization = defaultParameters.initialiseSerialization
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +187,6 @@ fun <A> driver(defaultParameters: DriverParameters = DriverParameters(), dsl: Dr
|
|||||||
* @property networkParameters The network parameters to be used by all the nodes. [NetworkParameters.notaries] must be
|
* @property networkParameters The network parameters to be used by all the nodes. [NetworkParameters.notaries] must be
|
||||||
* empty as notaries are defined by [notarySpecs].
|
* empty as notaries are defined by [notarySpecs].
|
||||||
* @property notaryCustomOverrides Extra settings that need to be passed to the notary.
|
* @property notaryCustomOverrides Extra settings that need to be passed to the notary.
|
||||||
* @property initialiseSerialization Indicates whether to initialized the serialization subsystem.
|
|
||||||
* @property inMemoryDB Whether to use in-memory H2 for new nodes rather then on-disk (the node starts quicker, however
|
* @property inMemoryDB Whether to use in-memory H2 for new nodes rather then on-disk (the node starts quicker, however
|
||||||
* the data is not persisted between node restarts). Has no effect if node is configured
|
* the data is not persisted between node restarts). Has no effect if node is configured
|
||||||
* in any way to use database other than H2.
|
* in any way to use database other than H2.
|
||||||
@ -210,7 +207,6 @@ data class DriverParameters(
|
|||||||
@Suppress("DEPRECATION") val jmxPolicy: JmxPolicy = JmxPolicy(),
|
@Suppress("DEPRECATION") val jmxPolicy: JmxPolicy = JmxPolicy(),
|
||||||
val networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()),
|
val networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()),
|
||||||
val notaryCustomOverrides: Map<String, Any?> = emptyMap(),
|
val notaryCustomOverrides: Map<String, Any?> = emptyMap(),
|
||||||
val initialiseSerialization: Boolean = true,
|
|
||||||
val inMemoryDB: Boolean = true,
|
val inMemoryDB: Boolean = true,
|
||||||
val cordappsForAllNodes: Collection<TestCordapp>? = null
|
val cordappsForAllNodes: Collection<TestCordapp>? = null
|
||||||
) {
|
) {
|
||||||
@ -228,7 +224,6 @@ data class DriverParameters(
|
|||||||
@Suppress("DEPRECATION") jmxPolicy: JmxPolicy = JmxPolicy(),
|
@Suppress("DEPRECATION") jmxPolicy: JmxPolicy = JmxPolicy(),
|
||||||
networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()),
|
networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()),
|
||||||
notaryCustomOverrides: Map<String, Any?> = emptyMap(),
|
notaryCustomOverrides: Map<String, Any?> = emptyMap(),
|
||||||
initialiseSerialization: Boolean = true,
|
|
||||||
inMemoryDB: Boolean = true
|
inMemoryDB: Boolean = true
|
||||||
) : this(
|
) : this(
|
||||||
isDebug,
|
isDebug,
|
||||||
@ -244,7 +239,6 @@ data class DriverParameters(
|
|||||||
jmxPolicy,
|
jmxPolicy,
|
||||||
networkParameters,
|
networkParameters,
|
||||||
notaryCustomOverrides,
|
notaryCustomOverrides,
|
||||||
initialiseSerialization,
|
|
||||||
inMemoryDB,
|
inMemoryDB,
|
||||||
cordappsForAllNodes = null
|
cordappsForAllNodes = null
|
||||||
)
|
)
|
||||||
@ -277,7 +271,6 @@ data class DriverParameters(
|
|||||||
networkParameters,
|
networkParameters,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
cordappsForAllNodes = null
|
cordappsForAllNodes = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -310,7 +303,6 @@ data class DriverParameters(
|
|||||||
networkParameters,
|
networkParameters,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
cordappsForAllNodes
|
cordappsForAllNodes
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -327,7 +319,6 @@ data class DriverParameters(
|
|||||||
extraCordappPackagesToScan: List<String>,
|
extraCordappPackagesToScan: List<String>,
|
||||||
jmxPolicy: JmxPolicy,
|
jmxPolicy: JmxPolicy,
|
||||||
networkParameters: NetworkParameters,
|
networkParameters: NetworkParameters,
|
||||||
initialiseSerialization: Boolean,
|
|
||||||
inMemoryDB: Boolean
|
inMemoryDB: Boolean
|
||||||
) : this(
|
) : this(
|
||||||
isDebug,
|
isDebug,
|
||||||
@ -343,7 +334,6 @@ data class DriverParameters(
|
|||||||
jmxPolicy,
|
jmxPolicy,
|
||||||
networkParameters,
|
networkParameters,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
initialiseSerialization,
|
|
||||||
inMemoryDB,
|
inMemoryDB,
|
||||||
cordappsForAllNodes = null
|
cordappsForAllNodes = null
|
||||||
)
|
)
|
||||||
@ -361,7 +351,6 @@ data class DriverParameters(
|
|||||||
extraCordappPackagesToScan: List<String>,
|
extraCordappPackagesToScan: List<String>,
|
||||||
jmxPolicy: JmxPolicy,
|
jmxPolicy: JmxPolicy,
|
||||||
networkParameters: NetworkParameters,
|
networkParameters: NetworkParameters,
|
||||||
initialiseSerialization: Boolean,
|
|
||||||
inMemoryDB: Boolean,
|
inMemoryDB: Boolean,
|
||||||
cordappsForAllNodes: Set<TestCordapp>? = null
|
cordappsForAllNodes: Set<TestCordapp>? = null
|
||||||
) : this(
|
) : this(
|
||||||
@ -378,7 +367,6 @@ data class DriverParameters(
|
|||||||
jmxPolicy,
|
jmxPolicy,
|
||||||
networkParameters,
|
networkParameters,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
initialiseSerialization,
|
|
||||||
inMemoryDB,
|
inMemoryDB,
|
||||||
cordappsForAllNodes
|
cordappsForAllNodes
|
||||||
)
|
)
|
||||||
@ -389,7 +377,6 @@ data class DriverParameters(
|
|||||||
fun withDebugPortAllocation(debugPortAllocation: PortAllocation): DriverParameters = copy(debugPortAllocation = debugPortAllocation)
|
fun withDebugPortAllocation(debugPortAllocation: PortAllocation): DriverParameters = copy(debugPortAllocation = debugPortAllocation)
|
||||||
fun withSystemProperties(systemProperties: Map<String, String>): DriverParameters = copy(systemProperties = systemProperties)
|
fun withSystemProperties(systemProperties: Map<String, String>): DriverParameters = copy(systemProperties = systemProperties)
|
||||||
fun withUseTestClock(useTestClock: Boolean): DriverParameters = copy(useTestClock = useTestClock)
|
fun withUseTestClock(useTestClock: Boolean): DriverParameters = copy(useTestClock = useTestClock)
|
||||||
fun withInitialiseSerialization(initialiseSerialization: Boolean): DriverParameters = copy(initialiseSerialization = initialiseSerialization)
|
|
||||||
fun withStartNodesInProcess(startNodesInProcess: Boolean): DriverParameters = copy(startNodesInProcess = startNodesInProcess)
|
fun withStartNodesInProcess(startNodesInProcess: Boolean): DriverParameters = copy(startNodesInProcess = startNodesInProcess)
|
||||||
fun withWaitForAllNodesToFinish(waitForAllNodesToFinish: Boolean): DriverParameters = copy(waitForAllNodesToFinish = waitForAllNodesToFinish)
|
fun withWaitForAllNodesToFinish(waitForAllNodesToFinish: Boolean): DriverParameters = copy(waitForAllNodesToFinish = waitForAllNodesToFinish)
|
||||||
fun withNotarySpecs(notarySpecs: List<NotarySpec>): DriverParameters = copy(notarySpecs = notarySpecs)
|
fun withNotarySpecs(notarySpecs: List<NotarySpec>): DriverParameters = copy(notarySpecs = notarySpecs)
|
||||||
@ -426,39 +413,7 @@ data class DriverParameters(
|
|||||||
extraCordappPackagesToScan = extraCordappPackagesToScan,
|
extraCordappPackagesToScan = extraCordappPackagesToScan,
|
||||||
jmxPolicy = jmxPolicy,
|
jmxPolicy = jmxPolicy,
|
||||||
networkParameters = networkParameters,
|
networkParameters = networkParameters,
|
||||||
notaryCustomOverrides = emptyMap(),
|
notaryCustomOverrides = emptyMap()
|
||||||
initialiseSerialization = true
|
|
||||||
)
|
|
||||||
|
|
||||||
fun copy(
|
|
||||||
isDebug: Boolean,
|
|
||||||
driverDirectory: Path,
|
|
||||||
portAllocation: PortAllocation,
|
|
||||||
debugPortAllocation: PortAllocation,
|
|
||||||
systemProperties: Map<String, String>,
|
|
||||||
useTestClock: Boolean,
|
|
||||||
startNodesInProcess: Boolean,
|
|
||||||
waitForAllNodesToFinish: Boolean,
|
|
||||||
notarySpecs: List<NotarySpec>,
|
|
||||||
extraCordappPackagesToScan: List<String>,
|
|
||||||
jmxPolicy: JmxPolicy,
|
|
||||||
networkParameters: NetworkParameters,
|
|
||||||
initialiseSerialization: Boolean
|
|
||||||
) = this.copy(
|
|
||||||
isDebug = isDebug,
|
|
||||||
driverDirectory = driverDirectory,
|
|
||||||
portAllocation = portAllocation,
|
|
||||||
debugPortAllocation = debugPortAllocation,
|
|
||||||
systemProperties = systemProperties,
|
|
||||||
useTestClock = useTestClock,
|
|
||||||
startNodesInProcess = startNodesInProcess,
|
|
||||||
waitForAllNodesToFinish = waitForAllNodesToFinish,
|
|
||||||
notarySpecs = notarySpecs,
|
|
||||||
extraCordappPackagesToScan = extraCordappPackagesToScan,
|
|
||||||
jmxPolicy = jmxPolicy,
|
|
||||||
networkParameters = networkParameters,
|
|
||||||
notaryCustomOverrides = emptyMap(),
|
|
||||||
initialiseSerialization = initialiseSerialization
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fun copy(
|
fun copy(
|
||||||
@ -489,40 +444,6 @@ data class DriverParameters(
|
|||||||
jmxPolicy = jmxPolicy,
|
jmxPolicy = jmxPolicy,
|
||||||
networkParameters = networkParameters,
|
networkParameters = networkParameters,
|
||||||
notaryCustomOverrides = emptyMap(),
|
notaryCustomOverrides = emptyMap(),
|
||||||
initialiseSerialization = true,
|
|
||||||
cordappsForAllNodes = cordappsForAllNodes
|
|
||||||
)
|
|
||||||
|
|
||||||
fun copy(
|
|
||||||
isDebug: Boolean,
|
|
||||||
driverDirectory: Path,
|
|
||||||
portAllocation: PortAllocation,
|
|
||||||
debugPortAllocation: PortAllocation,
|
|
||||||
systemProperties: Map<String, String>,
|
|
||||||
useTestClock: Boolean,
|
|
||||||
startNodesInProcess: Boolean,
|
|
||||||
waitForAllNodesToFinish: Boolean,
|
|
||||||
notarySpecs: List<NotarySpec>,
|
|
||||||
extraCordappPackagesToScan: List<String>,
|
|
||||||
jmxPolicy: JmxPolicy,
|
|
||||||
networkParameters: NetworkParameters,
|
|
||||||
initialiseSerialization: Boolean,
|
|
||||||
cordappsForAllNodes: Set<TestCordapp>?
|
|
||||||
) = this.copy(
|
|
||||||
isDebug = isDebug,
|
|
||||||
driverDirectory = driverDirectory,
|
|
||||||
portAllocation = portAllocation,
|
|
||||||
debugPortAllocation = debugPortAllocation,
|
|
||||||
systemProperties = systemProperties,
|
|
||||||
useTestClock = useTestClock,
|
|
||||||
startNodesInProcess = startNodesInProcess,
|
|
||||||
waitForAllNodesToFinish = waitForAllNodesToFinish,
|
|
||||||
notarySpecs = notarySpecs,
|
|
||||||
extraCordappPackagesToScan = extraCordappPackagesToScan,
|
|
||||||
jmxPolicy = jmxPolicy,
|
|
||||||
networkParameters = networkParameters,
|
|
||||||
notaryCustomOverrides = emptyMap(),
|
|
||||||
initialiseSerialization = initialiseSerialization,
|
|
||||||
cordappsForAllNodes = cordappsForAllNodes
|
cordappsForAllNodes = cordappsForAllNodes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ import net.corda.testing.driver.*
|
|||||||
import net.corda.testing.driver.internal.InProcessImpl
|
import net.corda.testing.driver.internal.InProcessImpl
|
||||||
import net.corda.testing.driver.internal.NodeHandleInternal
|
import net.corda.testing.driver.internal.NodeHandleInternal
|
||||||
import net.corda.testing.driver.internal.OutOfProcessImpl
|
import net.corda.testing.driver.internal.OutOfProcessImpl
|
||||||
import net.corda.testing.internal.setGlobalSerialization
|
|
||||||
import net.corda.testing.internal.stubs.CertificateStoreStubs
|
import net.corda.testing.internal.stubs.CertificateStoreStubs
|
||||||
import net.corda.testing.node.ClusterSpec
|
import net.corda.testing.node.ClusterSpec
|
||||||
import net.corda.testing.node.NotarySpec
|
import net.corda.testing.node.NotarySpec
|
||||||
@ -956,11 +955,10 @@ interface InternalDriverDSL : DriverDSL {
|
|||||||
*/
|
*/
|
||||||
fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
||||||
driverDsl: D,
|
driverDsl: D,
|
||||||
initialiseSerialization: Boolean = true,
|
|
||||||
coerce: (D) -> DI,
|
coerce: (D) -> DI,
|
||||||
dsl: DI.() -> A
|
dsl: DI.() -> A
|
||||||
): A {
|
): A {
|
||||||
val serializationEnv = setGlobalSerialization(initialiseSerialization)
|
val serializationEnv = setDriverSerialization()
|
||||||
val shutdownHook = addShutdownHook(driverDsl::shutdown)
|
val shutdownHook = addShutdownHook(driverDsl::shutdown)
|
||||||
try {
|
try {
|
||||||
driverDsl.start()
|
driverDsl.start()
|
||||||
@ -971,7 +969,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
} finally {
|
} finally {
|
||||||
driverDsl.shutdown()
|
driverDsl.shutdown()
|
||||||
shutdownHook.cancel()
|
shutdownHook.cancel()
|
||||||
serializationEnv.unset()
|
serializationEnv?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,7 +986,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
driverDslWrapper: (DriverDSLImpl) -> D,
|
driverDslWrapper: (DriverDSLImpl) -> D,
|
||||||
coerce: (D) -> DI, dsl: DI.() -> A
|
coerce: (D) -> DI, dsl: DI.() -> A
|
||||||
): A {
|
): A {
|
||||||
val serializationEnv = setGlobalSerialization(true)
|
val serializationEnv = setDriverSerialization()
|
||||||
val driverDsl = driverDslWrapper(
|
val driverDsl = driverDslWrapper(
|
||||||
DriverDSLImpl(
|
DriverDSLImpl(
|
||||||
portAllocation = defaultParameters.portAllocation,
|
portAllocation = defaultParameters.portAllocation,
|
||||||
@ -1019,7 +1017,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
} finally {
|
} finally {
|
||||||
driverDsl.shutdown()
|
driverDsl.shutdown()
|
||||||
shutdownHook.cancel()
|
shutdownHook.cancel()
|
||||||
serializationEnv.unset()
|
serializationEnv?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,7 +1088,6 @@ fun <A> internalDriver(
|
|||||||
debugPortAllocation: PortAllocation = DriverParameters().debugPortAllocation,
|
debugPortAllocation: PortAllocation = DriverParameters().debugPortAllocation,
|
||||||
systemProperties: Map<String, String> = DriverParameters().systemProperties,
|
systemProperties: Map<String, String> = DriverParameters().systemProperties,
|
||||||
useTestClock: Boolean = DriverParameters().useTestClock,
|
useTestClock: Boolean = DriverParameters().useTestClock,
|
||||||
initialiseSerialization: Boolean = true,
|
|
||||||
startNodesInProcess: Boolean = DriverParameters().startNodesInProcess,
|
startNodesInProcess: Boolean = DriverParameters().startNodesInProcess,
|
||||||
waitForAllNodesToFinish: Boolean = DriverParameters().waitForAllNodesToFinish,
|
waitForAllNodesToFinish: Boolean = DriverParameters().waitForAllNodesToFinish,
|
||||||
notarySpecs: List<NotarySpec> = DriverParameters().notarySpecs,
|
notarySpecs: List<NotarySpec> = DriverParameters().notarySpecs,
|
||||||
@ -1123,8 +1120,7 @@ fun <A> internalDriver(
|
|||||||
signCordapps = signCordapps
|
signCordapps = signCordapps
|
||||||
),
|
),
|
||||||
coerce = { it },
|
coerce = { it },
|
||||||
dsl = dsl,
|
dsl = dsl
|
||||||
initialiseSerialization = initialiseSerialization
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ import net.corda.nodeapi.internal.persistence.CordaPersistence
|
|||||||
import net.corda.nodeapi.internal.persistence.DatabaseConfig
|
import net.corda.nodeapi.internal.persistence.DatabaseConfig
|
||||||
import net.corda.testing.common.internal.testNetworkParameters
|
import net.corda.testing.common.internal.testNetworkParameters
|
||||||
import net.corda.testing.internal.rigorousMock
|
import net.corda.testing.internal.rigorousMock
|
||||||
import net.corda.testing.internal.setGlobalSerialization
|
|
||||||
import net.corda.testing.internal.stubs.CertificateStoreStubs
|
import net.corda.testing.internal.stubs.CertificateStoreStubs
|
||||||
import net.corda.testing.internal.testThreadFactory
|
import net.corda.testing.internal.testThreadFactory
|
||||||
import net.corda.testing.node.*
|
import net.corda.testing.node.*
|
||||||
@ -169,11 +168,7 @@ open class InternalMockNetwork(defaultParameters: MockNetworkParameters = MockNe
|
|||||||
private val networkId = random63BitValue()
|
private val networkId = random63BitValue()
|
||||||
private val networkParametersCopier: NetworkParametersCopier
|
private val networkParametersCopier: NetworkParametersCopier
|
||||||
private val _nodes = mutableListOf<MockNode>()
|
private val _nodes = mutableListOf<MockNode>()
|
||||||
private val serializationEnv = try {
|
private val serializationEnv = checkNotNull(setDriverSerialization()) { "Using more than one mock network simultaneously is not supported." }
|
||||||
setGlobalSerialization(true)
|
|
||||||
} catch (e: IllegalStateException) {
|
|
||||||
throw IllegalStateException("Using more than one InternalMockNetwork simultaneously is not supported.", e)
|
|
||||||
}
|
|
||||||
private val sharedUserCount = AtomicInteger(0)
|
private val sharedUserCount = AtomicInteger(0)
|
||||||
|
|
||||||
/** A read only view of the current set of nodes. */
|
/** A read only view of the current set of nodes. */
|
||||||
@ -566,10 +561,9 @@ open class InternalMockNetwork(defaultParameters: MockNetworkParameters = MockNe
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun stopNodes() {
|
fun stopNodes() {
|
||||||
try {
|
// Serialization env must be unset even if other parts of this method fail.
|
||||||
|
serializationEnv.use {
|
||||||
nodes.forEach { it.started?.dispose() }
|
nodes.forEach { it.started?.dispose() }
|
||||||
} finally {
|
|
||||||
serializationEnv.unset() // Must execute even if other parts of this method fail.
|
|
||||||
}
|
}
|
||||||
messagingNetwork.stop()
|
messagingNetwork.stop()
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,9 @@ import net.corda.core.internal.FlowStateMachine
|
|||||||
import net.corda.core.internal.concurrent.openFuture
|
import net.corda.core.internal.concurrent.openFuture
|
||||||
import net.corda.core.internal.times
|
import net.corda.core.internal.times
|
||||||
import net.corda.core.messaging.CordaRPCOps
|
import net.corda.core.messaging.CordaRPCOps
|
||||||
|
import net.corda.core.serialization.internal.SerializationEnvironment
|
||||||
|
import net.corda.core.serialization.internal._allEnabledSerializationEnvs
|
||||||
|
import net.corda.core.serialization.internal._driverSerializationEnv
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.core.utilities.millis
|
import net.corda.core.utilities.millis
|
||||||
@ -18,6 +21,8 @@ import net.corda.node.services.api.StartedNodeServices
|
|||||||
import net.corda.node.services.messaging.Message
|
import net.corda.node.services.messaging.Message
|
||||||
import net.corda.testing.driver.NodeHandle
|
import net.corda.testing.driver.NodeHandle
|
||||||
import net.corda.testing.internal.chooseIdentity
|
import net.corda.testing.internal.chooseIdentity
|
||||||
|
import net.corda.testing.internal.createTestSerializationEnv
|
||||||
|
import net.corda.testing.internal.inVMExecutors
|
||||||
import net.corda.testing.node.InMemoryMessagingNetwork
|
import net.corda.testing.node.InMemoryMessagingNetwork
|
||||||
import net.corda.testing.node.User
|
import net.corda.testing.node.User
|
||||||
import net.corda.testing.node.testContext
|
import net.corda.testing.node.testContext
|
||||||
@ -115,15 +120,11 @@ fun InMemoryMessagingNetwork.MessageTransfer.getMessage(): Message = message
|
|||||||
|
|
||||||
fun CordaRPCClient.start(user: User) = start(user.username, user.password)
|
fun CordaRPCClient.start(user: User) = start(user.username, user.password)
|
||||||
|
|
||||||
fun NodeHandle.waitForShutdown(): Observable<Unit> {
|
fun NodeHandle.waitForShutdown(): Observable<Unit> = rpc.waitForShutdown().doAfterTerminate(::stop)
|
||||||
|
|
||||||
return rpc.waitForShutdown().doAfterTerminate(::stop)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun CordaRPCOps.waitForShutdown(): Observable<Unit> {
|
fun CordaRPCOps.waitForShutdown(): Observable<Unit> {
|
||||||
|
|
||||||
val completable = AsyncSubject.create<Unit>()
|
val completable = AsyncSubject.create<Unit>()
|
||||||
stateMachinesFeed().updates.subscribe({ _ -> }, { error ->
|
stateMachinesFeed().updates.subscribe({ }, { error ->
|
||||||
if (error is ConnectionFailureException) {
|
if (error is ConnectionFailureException) {
|
||||||
completable.onCompleted()
|
completable.onCompleted()
|
||||||
} else {
|
} else {
|
||||||
@ -131,4 +132,23 @@ fun CordaRPCOps.waitForShutdown(): Observable<Unit> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return completable
|
return completable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should only be used by Driver and MockNode.
|
||||||
|
*/
|
||||||
|
fun setDriverSerialization(): AutoCloseable? {
|
||||||
|
return if (_allEnabledSerializationEnvs.isEmpty()) {
|
||||||
|
DriverSerializationEnvironment().enable()
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DriverSerializationEnvironment : SerializationEnvironment by createTestSerializationEnv(), AutoCloseable {
|
||||||
|
fun enable() = apply { _driverSerializationEnv.set(this) }
|
||||||
|
override fun close() {
|
||||||
|
_driverSerializationEnv.set(null)
|
||||||
|
inVMExecutors.remove(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -146,8 +146,7 @@ fun <A> rpcDriver(
|
|||||||
), externalTrace
|
), externalTrace
|
||||||
),
|
),
|
||||||
coerce = { it },
|
coerce = { it },
|
||||||
dsl = dsl,
|
dsl = dsl
|
||||||
initialiseSerialization = false
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package net.corda.testing.internal
|
package net.corda.testing.internal
|
||||||
|
|
||||||
import com.nhaarman.mockito_kotlin.doNothing
|
|
||||||
import com.nhaarman.mockito_kotlin.whenever
|
|
||||||
import net.corda.client.rpc.internal.serialization.amqp.AMQPClientSerializationScheme
|
import net.corda.client.rpc.internal.serialization.amqp.AMQPClientSerializationScheme
|
||||||
import net.corda.core.DoNotImplement
|
import net.corda.core.serialization.internal.SerializationEnvironment
|
||||||
import net.corda.core.serialization.internal.*
|
import net.corda.core.serialization.internal._contextSerializationEnv
|
||||||
|
import net.corda.core.serialization.internal._inheritableContextSerializationEnv
|
||||||
import net.corda.node.serialization.amqp.AMQPServerSerializationScheme
|
import net.corda.node.serialization.amqp.AMQPServerSerializationScheme
|
||||||
import net.corda.node.serialization.kryo.KRYO_CHECKPOINT_CONTEXT
|
import net.corda.node.serialization.kryo.KRYO_CHECKPOINT_CONTEXT
|
||||||
import net.corda.node.serialization.kryo.KryoCheckpointSerializer
|
import net.corda.node.serialization.kryo.KryoCheckpointSerializer
|
||||||
@ -29,7 +28,7 @@ fun <T> withoutTestSerialization(callable: () -> T): T { // TODO: Delete this, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun createTestSerializationEnv(): SerializationEnvironment {
|
fun createTestSerializationEnv(): SerializationEnvironment {
|
||||||
val factory = SerializationFactoryImpl().apply {
|
val factory = SerializationFactoryImpl().apply {
|
||||||
registerScheme(AMQPClientSerializationScheme(emptyList()))
|
registerScheme(AMQPClientSerializationScheme(emptyList()))
|
||||||
registerScheme(AMQPServerSerializationScheme(emptyList()))
|
registerScheme(AMQPServerSerializationScheme(emptyList()))
|
||||||
@ -45,30 +44,3 @@ internal fun createTestSerializationEnv(): SerializationEnvironment {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Should only be used by Driver and MockNode.
|
|
||||||
* @param armed true to install, false to do nothing and return a dummy env.
|
|
||||||
*/
|
|
||||||
fun setGlobalSerialization(armed: Boolean): GlobalSerializationEnvironment {
|
|
||||||
return if (armed) {
|
|
||||||
object : GlobalSerializationEnvironment, SerializationEnvironment by createTestSerializationEnv() {
|
|
||||||
override fun unset() {
|
|
||||||
_globalSerializationEnv.set(null)
|
|
||||||
inVMExecutors.remove(this)
|
|
||||||
}
|
|
||||||
}.also {
|
|
||||||
_globalSerializationEnv.set(it)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rigorousMock<GlobalSerializationEnvironment>().also {
|
|
||||||
doNothing().whenever(it).unset()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@DoNotImplement
|
|
||||||
interface GlobalSerializationEnvironment : SerializationEnvironment {
|
|
||||||
/** Unset this environment. */
|
|
||||||
fun unset()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user