MockNetworkParameters
Keywords: net.corda.testing.node.MockNetworkParameters class
Date: 2023-09-18

net.corda.testing.node

## Class MockNetworkParameters

- net.corda.testing.node.MockNetworkParameters

-     public class MockNetworkParameters

  Immutable builder for configuring a `class MockNetwork`.

  See Also:
    `class MockNetwork`

- - ### Constructor Detail

    - #### MockNetworkParameters

          public MockNetworkParameters(boolean networkSendManuallyPumped,
                                       boolean threadPerNode,
                                       @NotNull
                                       net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy servicePeerAllocationStrategy,
                                       @NotNull
                                       java.util.List<net.corda.testing.node.MockNetworkNotarySpec> notarySpecs,
                                       @NotNull
                                       NetworkParameters networkParameters,
                                       @NotNull
                                       java.util.Collection<? extends net.corda.testing.node.TestCordapp> cordappsForAllNodes)

      Immutable builder for configuring a `class MockNetwork`.

      Parameters:
        `networkSendManuallyPumped` - If false then messages will not be routed from sender to receiver until you usethe `MockNetwork.runNetwork` method. This is useful for writing single-threaded unit test code that can examine thestate of the mock network before and after a message is sent, without races and without the receiving node immediatelysending a response. The default is false, so you must call runNetwork.
        `threadPerNode` - If true then each node will be run in its own thread. This can result in race conditions inyour code if not carefully written, but is more realistic and may help if you have flows in your app that do longblocking operations. The default is false.
        `servicePeerAllocationStrategy` - How messages are load balanced in the case where a single compound identityis used by multiple nodes. You rarely if ever need to change that, it's primarily of interest to people testingnotary code.
        `notarySpecs` - The notaries to use in the mock network. By default you get one mock notary and that is usually sufficient.
        `networkParameters` - The network parameters to be used by all the nodes. NetworkParameters.notaries must beempty as notaries are defined by notarySpecs.
        `cordappsForAllNodes` - `class TestCordapp`s added to all nodes.
      See Also:
        `class MockNetwork`

    - #### MockNetworkParameters

          public MockNetworkParameters()

      Immutable builder for configuring a `class MockNetwork`.

      See Also:
        `class MockNetwork`

    - #### MockNetworkParameters

          public MockNetworkParameters(boolean networkSendManuallyPumped,
                                       boolean threadPerNode,
                                       @NotNull
                                       net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy servicePeerAllocationStrategy,
                                       @NotNull
                                       java.util.List<net.corda.testing.node.MockNetworkNotarySpec> notarySpecs,
                                       @NotNull
                                       NetworkParameters networkParameters)

    - #### MockNetworkParameters

          public MockNetworkParameters(@NotNull
                                       java.util.Collection<? extends net.corda.testing.node.TestCordapp> cordappsForAllNodes)

  - ### Method Detail

    - #### withNetworkParameters

          @NotNull
          public MockNetworkParameters withNetworkParameters(@NotNull
                                                                      NetworkParameters networkParameters)

    - #### withNetworkSendManuallyPumped

          @NotNull
          public MockNetworkParameters withNetworkSendManuallyPumped(boolean networkSendManuallyPumped)

    - #### withThreadPerNode

          @NotNull
          public MockNetworkParameters withThreadPerNode(boolean threadPerNode)

    - #### withServicePeerAllocationStrategy

          @NotNull
          public MockNetworkParameters withServicePeerAllocationStrategy(@NotNull
                                                                                  net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy servicePeerAllocationStrategy)

    - #### withNotarySpecs

          @NotNull
          public MockNetworkParameters withNotarySpecs(@NotNull
                                                                java.util.List<net.corda.testing.node.MockNetworkNotarySpec> notarySpecs)

    - #### withCordappsForAllNodes

          @NotNull
          public MockNetworkParameters withCordappsForAllNodes(@NotNull
                                                                        java.util.Collection<? extends net.corda.testing.node.TestCordapp> cordappsForAllNodes)

    - #### copy

          @NotNull
          public MockNetworkParameters copy(boolean networkSendManuallyPumped,
                                                     boolean threadPerNode,
                                                     @NotNull
                                                     net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy servicePeerAllocationStrategy,
                                                     @NotNull
                                                     java.util.List<net.corda.testing.node.MockNetworkNotarySpec> notarySpecs,
                                                     @NotNull
                                                     NetworkParameters networkParameters)

    - #### getNetworkSendManuallyPumped

          public boolean getNetworkSendManuallyPumped()

      If false 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 thestate of the mock network before and after a message is sent, without races and without the receiving node immediatelysending a response. The default is false, so you must call runNetwork.

      See Also:
        `MockNetwork.runNetwork`

    - #### getThreadPerNode

          public boolean getThreadPerNode()

      If true then each node will be run in its own thread.

      This can result in race conditions inyour code if not carefully written, but is more realistic and may help if you have flows in your app that do longblocking operations. The default is false.

    - #### getServicePeerAllocationStrategy

          @NotNull
          public net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy getServicePeerAllocationStrategy()

      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 testingnotary code.

    - #### getNotarySpecs

          @NotNull
          public java.util.List<net.corda.testing.node.MockNetworkNotarySpec> getNotarySpecs()

      The notaries to use in the mock network.

      By default you get one mock notary and that is usually sufficient.

    - #### getNetworkParameters

          @NotNull
          public NetworkParameters getNetworkParameters()

      The network parameters to be used by all the nodes.

      NetworkParameters.notaries must beempty as notaries are defined by notarySpecs.

    - #### getCordappsForAllNodes

          @NotNull
          public java.util.Collection<net.corda.testing.node.TestCordapp> getCordappsForAllNodes()

      `class TestCordapp`

      s added to all nodes.

      See Also:
        `class TestCordapp`

    - #### component1

          public boolean component1()

      If false 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 thestate of the mock network before and after a message is sent, without races and without the receiving node immediatelysending a response. The default is false, so you must call runNetwork.

      See Also:
        `MockNetwork.runNetwork`

    - #### component2

          public boolean component2()

      If true then each node will be run in its own thread.

      This can result in race conditions inyour code if not carefully written, but is more realistic and may help if you have flows in your app that do longblocking operations. The default is false.

    - #### component3

          @NotNull
          public net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy component3()

      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 testingnotary code.

    - #### component4

          @NotNull
          public java.util.List<net.corda.testing.node.MockNetworkNotarySpec> component4()

      The notaries to use in the mock network.

      By default you get one mock notary and that is usually sufficient.

    - #### component5

          @NotNull
          public NetworkParameters component5()

      The network parameters to be used by all the nodes.

      NetworkParameters.notaries must beempty as notaries are defined by notarySpecs.

    - #### component6

          @NotNull
          public java.util.Collection<net.corda.testing.node.TestCordapp> component6()

      `class TestCordapp`

      s added to all nodes.

      See Also:
        `class TestCordapp`

    - #### copy

          @NotNull
          public MockNetworkParameters copy(boolean networkSendManuallyPumped,
                                                     boolean threadPerNode,
                                                     @NotNull
                                                     net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy servicePeerAllocationStrategy,
                                                     @NotNull
                                                     java.util.List<net.corda.testing.node.MockNetworkNotarySpec> notarySpecs,
                                                     @NotNull
                                                     NetworkParameters networkParameters,
                                                     @NotNull
                                                     java.util.Collection<? extends net.corda.testing.node.TestCordapp> cordappsForAllNodes)

      Immutable builder for configuring a `class MockNetwork`.

      See Also:
        `class MockNetwork`

    - #### toString

          @NotNull
          public java.lang.String toString()

      Immutable builder for configuring a `class MockNetwork`.

      See Also:
        `class MockNetwork`

    - #### hashCode

          public int hashCode()

      Immutable builder for configuring a `class MockNetwork`.

      See Also:
        `class MockNetwork`

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object p)

      Immutable builder for configuring a `class MockNetwork`.

      See Also:
        `class MockNetwork`