com.r3corda.core.node.services.testing / MockServices

MockServices

open class MockServices : ServiceHub

A singleton utility that only provides a mock identity, key and storage service. However, this is sufficient for building chains of transactions and verifying them. It isnt sufficient for testing protocols however.



Constructors

<init> MockServices(key: KeyPair = generateKeyPair())

A singleton utility that only provides a mock identity, key and storage service. However, this is sufficient for building chains of transactions and verifying them. It isnt sufficient for testing protocols however.

Properties

clock open val clock: Clock
identityService open val identityService: MockIdentityService
key val key: KeyPair
keyManagementService open val keyManagementService: MockKeyManagementService
networkMapCache open val networkMapCache: NetworkMapCache
networkService open val networkService: MessagingService
schedulerService open val schedulerService: SchedulerService
storageService open val storageService: TxWritableStorageService
walletService open val walletService: WalletService

Functions

invokeProtocolAsync open fun <T : Any> invokeProtocolAsync(logicType: Class<out ProtocolLogic<T>>, vararg args: Any?): <ERROR CLASS><T>

Will check logicType and args against a whitelist and if acceptable then construct and initiate the protocol.

recordTransactions open fun recordTransactions(txs: Iterable<SignedTransaction>): Unit

Given a list of SignedTransactions, writes them to the local storage for validated transactions and then sends them to the wallet for further processing.

Inherited Functions

loadState open fun loadState(stateRef: StateRef): TransactionState<*>

Given a StateRef loads the referenced transaction and looks up the specified output ContractState.

recordTransactions open fun recordTransactions(vararg txs: SignedTransaction): <ERROR CLASS>

Given some SignedTransactions, writes them to the local storage for validated transactions and then sends them to the wallet for further processing.

Extension Functions

fillWithSomeTestCash fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>, notary: Party = DUMMY_NOTARY, atLeastThisManyStates: Int = 3, atMostThisManyStates: Int = 10, rng: Random = Random(), ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })), ownedBy: PublicKey? = null): Wallet

Creates a random set of between (by default) 3 and 10 cash states that add up to the given amount and adds them to the wallet. This is intended for unit tests. The cash is issued by DUMMY_CASH_ISSUER and owned by the legal identity key from the storage service.