MockServices

open class MockServices

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.

There are a variety of constructors that can be used to supply enough data to simulate a node. Each mock service hub must have at least an identity of its own. The other components have defaults that work in most situations.

Constructors

Link copied to clipboard
constructor(cordappPackages: Iterable<String>, initialIdentity: <Error class: unknown class>, identityService: <Error class: unknown class> = makeTestIdentityService(), vararg moreKeys: KeyPair)

Create a mock ServiceHub that looks for app code in the given package names, uses the provided identity service (you can get one from makeTestIdentityService) and represents the given identity.

constructor(cordappPackages: Iterable<String>, initialIdentity: <Error class: unknown class>, identityService: <Error class: unknown class>, networkParameters: <Error class: unknown class>, vararg moreKeys: KeyPair)
constructor(cordappPackages: Iterable<String>, initialIdentity: <Error class: unknown class>, identityService: <Error class: unknown class>, networkParameters: <Error class: unknown class>, vararg moreKeys: KeyPair, keyManagementService: <Error class: unknown class>)
constructor(cordappPackages: Iterable<String>, initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class> = makeTestIdentityService(), key: KeyPair, vararg moreKeys: KeyPair)

Create a mock ServiceHub that looks for app code in the given package names, uses the provided identity service (you can get one from makeTestIdentityService) and represents the given identity.

constructor(cordappPackages: Iterable<String>, initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class> = makeTestIdentityService())

Create a mock ServiceHub that can't load CorDapp code, which uses the provided identity service (you can get one from makeTestIdentityService) and which represents the given identity.

constructor(cordappPackages: Iterable<String>)

Create a mock ServiceHub that can't load CorDapp code, and which uses a default service identity.

constructor(initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class> = makeTestIdentityService(), key: KeyPair, vararg moreKeys: KeyPair)

Create a mock ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service (you can get one from makeTestIdentityService) and which represents the given identity.

constructor(initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class> = makeTestIdentityService())

Create a mock ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service (you can get one from makeTestIdentityService) and which represents the given identity. It has no keys.

constructor(cordappPackages: List<String>, initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class>, networkParameters: <Error class: unknown class>)
constructor(cordappPackages: List<String>, initialIdentityName: <Error class: unknown class>, identityService: <Error class: unknown class>, networkParameters: <Error class: unknown class>, key: KeyPair)
constructor(firstIdentity: <Error class: unknown class>, vararg moreIdentities: <Error class: unknown class>)

A helper constructor that requires at least one test identity to be registered, and which takes the package of the caller as the package in which to find app code. This is the most convenient constructor and the one that is normally worth using. The first identity is the identity of this service hub, the rest are identities that it is aware of.

constructor(firstIdentity: <Error class: unknown class>, networkParameters: <Error class: unknown class>, vararg moreIdentities: <Error class: unknown class>)
constructor(cordappPackages: List<String>, firstIdentity: <Error class: unknown class>, vararg moreIdentities: <Error class: unknown class>)
constructor(cordappPackages: List<String>, firstIdentity: <Error class: unknown class>, networkParameters: <Error class: unknown class>, vararg moreIdentities: <Error class: unknown class>)
constructor()

Create a mock ServiceHub which uses the package of the caller to find CorDapp code. It uses a default service identity.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open val clock: TestClock
Link copied to clipboard
open val contractUpgradeService: <Error class: unknown class>
Link copied to clipboard

Returns the classloader containing all jar deployed in the 'cordapps' folder.

Link copied to clipboard
open val cordappProvider: <Error class: unknown class>
Link copied to clipboard
open val diagnosticsService: <Error class: unknown class>
Link copied to clipboard
open val identityService: <Error class: unknown class>
Link copied to clipboard
open val keyManagementService: <Error class: unknown class>
Link copied to clipboard
open val myInfo: <Error class: unknown class>
Link copied to clipboard
open val networkMapCache: <Error class: unknown class>
Link copied to clipboard
open val networkParameters: <Error class: unknown class>
Link copied to clipboard
open var networkParametersService: <Error class: unknown class>
Link copied to clipboard
open val telemetryService: <Error class: unknown class>
Link copied to clipboard
open val validatedTransactions: <Error class: unknown class>
Link copied to clipboard
open val vaultService: <Error class: unknown class>

Functions

Link copied to clipboard
fun addMockCordapp(contractClassName: <Error class: unknown class>)

Add the given package name to the list of packages which will be scanned for cordapp contract verification code

Link copied to clipboard
open fun <T> cordaService(type: Class<T>): T
Link copied to clipboard
open fun <T> cordaTelemetryComponent(type: Class<T>): T
Link copied to clipboard
Link copied to clipboard
open fun loadContractAttachment(stateRef: <Error class: unknown class>): <Error class: unknown class>

Returns a dummy Attachment, in context of signature constrains non-downgrade rule this default to contract class version 1.

Link copied to clipboard
open fun loadState(stateRef: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open fun loadStates(stateRefs: Set<<Error class: unknown class>>): Set<<Error class: unknown class><<Error class: unknown class>>>
Link copied to clipboard
fun recordTransactions(txn: <Error class: unknown class>, disableSignatureVerification: Boolean): <Error class: unknown class>
open fun recordTransactions(statesToRecord: <Error class: unknown class>, txs: Iterable<<Error class: unknown class>>): <Error class: unknown class>
fun recordTransactions(txs: Iterable<<Error class: unknown class>>, disableSignatureVerification: Boolean)
Link copied to clipboard
open fun registerUnloadHandler(runOnStop: () -> Unit): Nothing
Link copied to clipboard
open fun withEntityManager(block: Consumer<<Error class: unknown class>>)
open fun <T> withEntityManager(block: <Error class: unknown class>.() -> T): T