Package-level declarations

Types

Link copied to clipboard

Abstract class specifying information about the consensus algorithm used for a cluster of nodes.

Link copied to clipboard
Link copied to clipboard

An in-memory network allows you to manufacture MockNodeMessagingServices for a set of participants. Each MockNodeMessagingService maintains a queue of messages it has received, and a background thread that dispatches messages one by one to registered handlers. Alternatively, a messaging system may be manually pumped, in which case no thread is created and a caller is expected to force delivery one at a time (this is useful for unit testing).

Link copied to clipboard
class MockNetFlowTimeOut(val timeout: Duration, val maxRestartCount: Int, val backoffBase: Double)

MockNetFlowTimeOut can be used to configure flow time out settings for a node via the mock network API.

Link copied to clipboard
class MockNetNotaryConfig(val validating: Boolean, val extraConfig: <Error class: unknown class>? = null, val className: String? = null, val serviceLegalName: CordaX500Name? = null)

MockNetNotaryConfig can be used to configure a node to be a notary via the mock network API. Internally this will be translated into a NotaryConfiguration and passed to the respective node.

Link copied to clipboard
open class MockNetwork(val cordappPackages: List<String>, val defaultParameters: MockNetworkParameters = MockNetworkParameters(), val networkSendManuallyPumped: Boolean = defaultParameters.networkSendManuallyPumped, val threadPerNode: Boolean = defaultParameters.threadPerNode, val servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = defaultParameters.servicePeerAllocationStrategy, val notarySpecs: List<MockNetworkNotarySpec> = defaultParameters.notarySpecs, val 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.

Link copied to clipboard
data class MockNetworkNotarySpec constructor(val name: CordaX500Name, val validating: Boolean = true)

The spec for a notary which will used by the MockNetwork to automatically start a notary node. This notary will become part of the network parameters used by all the nodes.

Link copied to clipboard
data class MockNetworkParameters(val networkSendManuallyPumped: Boolean = false, val threadPerNode: Boolean = false, val servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random(), val notarySpecs: List<MockNetworkNotarySpec> = listOf(MockNetworkNotarySpec(DUMMY_NOTARY_NAME)), val networkParameters: NetworkParameters = testNetworkParameters(), val cordappsForAllNodes: Collection<TestCordapp> = emptyList())

Immutable builder for configuring a MockNetwork.

Link copied to clipboard
class MockNodeConfigOverrides(val extraDataSourceProperties: Map<String, String>? = null, val notary: MockNetNotaryConfig? = null, val flowTimeout: MockNetFlowTimeOut? = null)

This is a data class to configure overrides to the node configuration used in the mock network without having to expose/use the actual (internal) node configuration interface on the API. When passing one of these to createNode or createUnstartedNode functions, the bits that are set will be injected into the node configuration for the node to be created.

Link copied to clipboard
data class MockNodeParameters(val forcedID: Int? = null, val legalName: CordaX500Name? = null, val entropyRoot: BigInteger = BigInteger.valueOf(random63BitValue()), val configOverrides: MockNodeConfigOverrides? = null, val additionalCordapps: Collection<TestCordapp> = emptyList())

Immutable builder for configuring a StartedMockNode or an UnstartedMockNode via MockNetwork.createNode and MockNetwork.createUnstartedNode. Kotlin users can also use the named parameters overloads of those methods which are more convenient.

Link copied to clipboard

An implementation of ServiceHub that is designed for in-memory unit tests of contract validation logic. It has enough functionality to do tests of code that queries the vault, inserts to the vault, and constructs/checks transactions. However it isn't enough to test flows and other aspects of an app that require a network. For that you should investigate MockNetwork.

Link copied to clipboard
data class NotarySpec(val name: CordaX500Name, val validating: Boolean = true, val rpcUsers: List<User> = emptyList(), val verifierType: VerifierType = VerifierType.InMemory, val cluster: ClusterSpec? = null, val startInProcess: Boolean = true)

A notary spec for describing a notary which will be started automatically by the driver and which will be part of the network parameters used by all the nodes.

Link copied to clipboard

A class that represents a started mock node for testing.

Link copied to clipboard
class TestClock(delegateClock: Clock)

A Clock that can have the time advanced for use in testing.

Link copied to clipboard

Encapsulates a CorDapp that exists on the current classpath, which can be pulled in for testing. Use TestCordapp.findCordapp to locate an existing CorDapp.

Link copied to clipboard

A class that represents an unstarted mock node for testing.

Link copied to clipboard
data class User(val username: String, val password: String, val permissions: Set<String>)

Object encapsulating a node rpc user and their associated permissions for use when testing using the driver

Functions

Link copied to clipboard
fun <T : SerializeAsToken> createMockCordaService(serviceHub: MockServices, serviceConstructor: (AppServiceHub) -> T): T

Function which can be used to create a mock CordaService for use within testing, such as an Oracle.

Link copied to clipboard

Creates and tests a ledger built by the passed in dsl.

Link copied to clipboard

Returns a simple IdentityService containing the supplied identities.

Link copied to clipboard
fun testActor(owningLegalIdentity: CordaX500Name = CordaX500Name("Test Company Inc.", "London", "GB")): Actor

Creates a new Actor for use in testing with the given owningLegalIdentity.

Link copied to clipboard
fun testContext(owningLegalIdentity: CordaX500Name = CordaX500Name("Test Company Inc.", "London", "GB")): InvocationContext

Creates a new InvocationContext for use in testing with the given owningLegalIdentity.

Link copied to clipboard

Creates a ledger with a single transaction, built by the passed in dsl.