corda / net.corda.testing.node / MockNetworkParameters


data class MockNetworkParameters

Immutable builder for configuring a MockNetwork. Kotlin users can also use named parameters to the constructor of MockNetwork, which is more convenient.



MockNetworkParameters(networkSendManuallyPumped: Boolean = false, threadPerNode: Boolean = false, servicePeerAllocationStrategy: ServicePeerAllocationStrategy = InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random(), notarySpecs: List<MockNetworkNotarySpec> = listOf(MockNetworkNotarySpec(DUMMY_NOTARY_NAME)), networkParameters: NetworkParameters = testNetworkParameters())

Immutable builder for configuring a MockNetwork. Kotlin users can also use named parameters to the constructor of MockNetwork, which is more convenient.



val networkParameters: NetworkParameters

The network parameters to be used by all the nodes. NetworkParameters.notaries must be empty as notaries are defined by notarySpecs.


val networkSendManuallyPumped: Boolean

If true then messages will not be routed from sender to receiver until you use the MockNetwork.runNetwork method. This is useful for writing single-threaded unit test code that can examine the state of the mock network before and after a message is sent, without races and without the receiving node immediately sending a response. The default is false, so you must call runNetwork.


val notarySpecs: List<MockNetworkNotarySpec>

The notaries to use in the mock network. By default you get one mock notary and that is usually sufficient.


val servicePeerAllocationStrategy: ServicePeerAllocationStrategy

How messages are load balanced in the case where a single compound identity is used by multiple nodes. You rarely if ever need to change that, it's primarily of interest to people testing notary code.


val threadPerNode: Boolean

If true then each node will be run in its own thread. This can result in race conditions in your code if not carefully written, but is more realistic and may help if you have flows in your app that do long blocking operations. The default is false.



fun withNetworkParameters(networkParameters: NetworkParameters): MockNetworkParameters


fun withNetworkSendManuallyPumped(networkSendManuallyPumped: Boolean): MockNetworkParameters


fun withNotarySpecs(notarySpecs: List<MockNetworkNotarySpec>): MockNetworkParameters


fun withServicePeerAllocationStrategy(servicePeerAllocationStrategy: ServicePeerAllocationStrategy): MockNetworkParameters


fun withThreadPerNode(threadPerNode: Boolean): MockNetworkParameters

Extension Functions


fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.