corda / net.corda.testing.core

Package net.corda.testing.core

Generic test utilities for contracts and flows

Types

DummyCommandData

object DummyCommandData : TypeOnlyCommandData

Trivial implementation of TypeOnlyCommandData for test purposes

ExpectCompose

sealed class ExpectCompose<out E>

Part of the Expectation DSL

SerializationEnvironmentRule

class SerializationEnvironmentRule

A test serialization rule implementation for use in tests

TestIdentity

class TestIdentity

A class that encapsulates a test identity containing a CordaX500Name and a KeyPair, alongside a range of utility methods for use during testing.

Extensions for External Classes

kotlin.collections.Iterable

rx.Observable

Properties

ALICE_NAME

val ALICE_NAME: CordaX500Name

A test node name

BOB_NAME

val BOB_NAME: CordaX500Name

A test node name

BOC_NAME

val BOC_NAME: CordaX500Name

A test node name

CHARLIE_NAME

val CHARLIE_NAME: CordaX500Name

A test node name

DUMMY_BANK_A_NAME

val DUMMY_BANK_A_NAME: CordaX500Name

A test node name

DUMMY_BANK_B_NAME

val DUMMY_BANK_B_NAME: CordaX500Name

A test node name

DUMMY_BANK_C_NAME

val DUMMY_BANK_C_NAME: CordaX500Name

A test node name

DUMMY_NOTARY_NAME

val DUMMY_NOTARY_NAME: CordaX500Name

A test notary name

MAX_MESSAGE_SIZE

const val MAX_MESSAGE_SIZE: Int

Maximum artemis message size. 10 MiB maximum allowed file size for attachments, including message headers.

Functions

dummyCommand

fun dummyCommand(vararg signers: PublicKey = arrayOf(generateKeyPair().public)): Command<TypeOnlyCommandData>

Generates a dummy command that doesn't do anything useful for use in tests

expect

fun <E : Any> expect(klass: Class<E>, match: (E) -> Boolean, expectClosure: (E) -> Unit): ExpectCompose<E>

Expect an event of type T and run expectClosure on it

fun <E : Any> expect(match: (E) -> Boolean = { true }, expectClosure: (E) -> Unit): ExpectCompose<E>

Convenience variant of expect reifying the Class parameter

fun <E : Any> expect(event: E, expectClosure: (E) -> Unit = {}): ExpectCompose<E>

Convenience variant of expect that only matches events that are strictly equal to event

freeLocalHostAndPort

fun freeLocalHostAndPort(): NetworkHostAndPort

Returns a localhost address with a free port.

freePort

fun freePort(): Int

Returns a free port.

generateStateRef

fun generateStateRef(): StateRef

Returns a fake state reference for testing purposes

genericExpectEvents

fun <S, E : Any> S.genericExpectEvents(isStrict: Boolean = true, stream: S.((E) -> Unit) -> Unit, expectCompose: () -> ExpectCompose<E>): Unit

Run the specified DSL against the generic event Stream

getFreeLocalPorts

fun getFreeLocalPorts(hostName: String, numberToAlloc: Int): List<NetworkHostAndPort>

Creates a specified number of ports for use by the Node.

getTestPartyAndCertificate

fun getTestPartyAndCertificate(party: Party): PartyAndCertificatefun getTestPartyAndCertificate(name: CordaX500Name, publicKey: PublicKey): PartyAndCertificate

Build a test party with a nonsense certificate authority for testing purposes.

parallel

fun <E> parallel(vararg expectations: ExpectCompose<E>): ExpectCompose<E>
fun <E> parallel(expectations: List<ExpectCompose<E>>): ExpectCompose<E>

Tests that events arrive in unspecified order.

replicate

fun <E> replicate(number: Int, expectation: (Int) -> ExpectCompose<E>): ExpectCompose<E>

Tests that N events of the same type arrive

sequence

fun <E> sequence(vararg expectations: ExpectCompose<E>): ExpectCompose<E>

Tests that events arrive in the specified order.

fun <E> sequence(expectations: List<ExpectCompose<E>>): ExpectCompose<E>

singleIdentity

fun NodeInfo.singleIdentity(): Party

Extract a single identity from the node info. Throws an error if the node has multiple identities.

singleIdentityAndCert

fun NodeInfo.singleIdentityAndCert(): PartyAndCertificate

Extract a single identity from the node info. Throws an error if the node has multiple identities.