corda / net.corda.testing.node / MockNetwork / <init>

<init>

MockNetwork(cordappPackages: List<String>, parameters: MockNetworkParameters = MockNetworkParameters())
MockNetwork(parameters: MockNetworkParameters) MockNetwork(cordappPackages: List<String>, defaultParameters: MockNetworkParameters = MockNetworkParameters(), networkSendManuallyPumped: Boolean = defaultParameters.networkSendManuallyPumped, threadPerNode: Boolean = defaultParameters.threadPerNode, servicePeerAllocationStrategy: ServicePeerAllocationStrategy = defaultParameters.servicePeerAllocationStrategy, notarySpecs: List<MockNetworkNotarySpec> = defaultParameters.notarySpecs, networkParameters: NetworkParameters = defaultParameters.networkParameters)

A mock node brings up a suite of in-memory services in a fast manner suitable for unit testing. Components that do IO are either swapped out for mocks, or pointed to a Jimfs in memory filesystem or an in memory H2 database instance.

Java users can use the constructor that takes an (optional) MockNetworkParameters builder, which may be more convenient than specifying all the defaults by hand. Please see MockNetworkParameters for the documentation of each parameter.

Mock network nodes require manual pumping by default: they will not run asynchronous. This means that for message exchanges to take place (and associated handlers to run), you must call the runNetwork method. If you want messages to flow automatically, use automatic pumping with a thread per node but watch out for code running parallel to your unit tests: you will need to use futures correctly to ensure race-free results.

By default a single notary node is automatically started, which forms part of the network parameters for all the nodes. This node is available by calling defaultNotaryNode.