corda / net.corda.testing.node

Package net.corda.testing.node

Test utilites to help running nodes programmatically for tests

Types

ClusterSpec

abstract class ClusterSpec

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

InMemoryMessagingNetwork

class InMemoryMessagingNetwork : SingletonSerializeAsToken

An in-memory network allows you to manufacture InternalMockMessagingServices for a set of participants. Each InternalMockMessagingService 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).

MockNetwork

open class MockNetwork

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.

MockNetworkNotarySpec

data class MockNetworkNotarySpec

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.

MockNetworkParameters

data class MockNetworkParameters

Immutable builder for configuring a MockNetwork. Kotlin users can also use named parameters to the constructor of MockNetwork, which is more convenient.

MockNodeParameters

data class MockNodeParameters

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.

MockServices

open class MockServices : ServiceHub

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.

NotarySpec

data class NotarySpec

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.

StartedMockNode

class StartedMockNode

A class that represents a started mock node for testing.

TestClock

class TestClock : MutableClock

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

UnstartedMockNode

class UnstartedMockNode

A class that represents an unstarted mock node for testing.

User

data class User

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

Functions

createMockCordaService

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.

ledger

fun ServiceHub.ledger(notary: Party = TestIdentity.fresh("ledger notary").party, script: LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit): LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>

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

makeTestIdentityService

fun makeTestIdentityService(vararg identities: PartyAndCertificate): InMemoryIdentityService

Returns a simple InMemoryIdentityService containing the supplied identities.

testActor

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

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

testContext

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

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

transaction

fun ServiceHub.transaction(notary: Party = TestIdentity.fresh("transaction notary").party, script: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail): LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>

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