From c3455053acbe56c67b831d4a7e42e0073f28702e Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Mon, 12 Feb 2018 17:50:35 +0000 Subject: [PATCH] Adds constructors for creating mock nodes by passing params. --- .../net/corda/testing/node/MockNetwork.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt index 070fec8ef9..66a930ce3e 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt @@ -152,9 +152,45 @@ open class MockNetwork( /** Create a started node with the given parameters. **/ fun createNode(parameters: MockNodeParameters = MockNodeParameters()): StartedMockNode = StartedMockNode.create(internalMockNetwork.createNode(parameters)) + /** Create a started node with the given parameters. + * @param legalName the node's legal name. + * @param forcedID a unique identifier for the node. + * @param entropyRoot the initial entropy value to use when generating keys. Defaults to an (insecure) random value, + * but can be overridden to cause nodes to have stable or colliding identity/service keys. + * @param configOverrides add/override behaviour of the [NodeConfiguration] mock object. + * @param version the mock node's platform, release, revision and vendor versions. + */ + @JvmOverloads + fun createNode(legalName: CordaX500Name? = null, + forcedID: Int? = null, + entropyRoot: BigInteger = BigInteger.valueOf(random63BitValue()), + configOverrides: (NodeConfiguration) -> Any? = {}, + version: VersionInfo = MockServices.MOCK_VERSION_INFO): StartedMockNode { + val parameters = MockNodeParameters(forcedID, legalName, entropyRoot, configOverrides, version) + return StartedMockNode.create(internalMockNetwork.createNode(parameters)) + } + /** Create an unstarted node with the given parameters. **/ fun createUnstartedNode(parameters: MockNodeParameters = MockNodeParameters()): UnstartedMockNode = UnstartedMockNode.create(internalMockNetwork.createUnstartedNode(parameters)) + /** Create an unstarted node with the given parameters. + * @param legalName the node's legal name. + * @param forcedID a unique identifier for the node. + * @param entropyRoot the initial entropy value to use when generating keys. Defaults to an (insecure) random value, + * but can be overridden to cause nodes to have stable or colliding identity/service keys. + * @param configOverrides add/override behaviour of the [NodeConfiguration] mock object. + * @param version the mock node's platform, release, revision and vendor versions. + */ + @JvmOverloads + fun createUnstartedNode(legalName: CordaX500Name? = null, + forcedID: Int? = null, + entropyRoot: BigInteger = BigInteger.valueOf(random63BitValue()), + configOverrides: (NodeConfiguration) -> Any? = {}, + version: VersionInfo = MockServices.MOCK_VERSION_INFO): UnstartedMockNode { + val parameters = MockNodeParameters(forcedID, legalName, entropyRoot, configOverrides, version) + return UnstartedMockNode.create(internalMockNetwork.createUnstartedNode(parameters)) + } + /** Start all nodes that aren't already started. **/ fun startNodes() = internalMockNetwork.startNodes()