Adds constructors for creating mock nodes by passing params.

This commit is contained in:
Joel Dudley 2018-02-12 17:50:35 +00:00 committed by GitHub
parent e5857b8e45
commit c3455053ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()