public class MockServices implements ServiceHub
An implementation of interface 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 class 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.
interface ServiceHub
,
class MockNetwork
Modifier and Type | Class and Description |
---|---|
static class |
MockServices.Companion |
ServiceHub.DefaultImpls
Modifier and Type | Field and Description |
---|---|
static MockServices.Companion |
Companion |
Constructor and Description |
---|
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
IdentityService identityService,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
IdentityService identityService,
NetworkParameters networkParameters,
java.security.KeyPair moreKeys) |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
IdentityService identityService,
NetworkParameters networkParameters,
java.security.KeyPair[] moreKeys,
KeyManagementService keyManagementService) |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName,
IdentityService identityService,
java.security.KeyPair key,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName,
java.security.KeyPair key,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName,
IdentityService identityService)
Create a mock
interface ServiceHub that can't load CorDapp code, which uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName)
Create a mock
interface ServiceHub that can't load CorDapp code, which uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. |
MockServices(java.lang.Iterable<java.lang.String> cordappPackages)
Create a mock
interface ServiceHub that can't load CorDapp code, and which uses a default service identity. |
MockServices(CordaX500Name initialIdentityName,
IdentityService identityService,
java.security.KeyPair key,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. |
MockServices(CordaX500Name initialIdentityName,
java.security.KeyPair key,
java.security.KeyPair moreKeys)
Create a mock
interface ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. |
MockServices(CordaX500Name initialIdentityName,
IdentityService identityService)
Create a mock
interface ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. It has no keys. |
MockServices(CordaX500Name initialIdentityName)
Create a mock
interface ServiceHub which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService ) and which represents the given identity. It has no keys. |
MockServices(java.util.List<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName,
IdentityService identityService,
NetworkParameters networkParameters) |
MockServices(java.util.List<java.lang.String> cordappPackages,
CordaX500Name initialIdentityName,
IdentityService identityService,
NetworkParameters networkParameters,
java.security.KeyPair key) |
MockServices(TestIdentity firstIdentity,
net.corda.testing.core.TestIdentity moreIdentities)
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.
|
MockServices(TestIdentity firstIdentity,
NetworkParameters networkParameters,
net.corda.testing.core.TestIdentity moreIdentities) |
MockServices(java.util.List<java.lang.String> cordappPackages,
TestIdentity firstIdentity,
net.corda.testing.core.TestIdentity moreIdentities) |
MockServices(java.util.List<java.lang.String> cordappPackages,
TestIdentity firstIdentity,
NetworkParameters networkParameters,
net.corda.testing.core.TestIdentity moreIdentities) |
MockServices()
Create a mock
interface ServiceHub which uses the package of the caller to find CorDapp code. It uses a default service
identity. |
Modifier and Type | Method and Description |
---|---|
void |
addMockCordapp(java.lang.String contractClassName)
Add the given package name to the list of packages which will be scanned for cordapp contract verification code
|
<T extends SerializeAsToken> |
cordaService(java.lang.Class<T> type)
Return the singleton instance of the given Corda service type. This is a class that is annotated with
interface CordaService and will have automatically been registered by the node. |
MockAttachmentStorage |
getAttachments()
Provides access to storage of arbitrary JAR files (which may contain only data, no code).
|
TestClock |
getClock()
A Clock representing the node's current time. This should be used in preference to directly accessing the
clock so the current time can be controlled during unit testing.
|
ContractUpgradeService |
getContractUpgradeService()
The
interface ContractUpgradeService is responsible for securely upgrading contract state objects according to
a specified and mutually agreed (amongst participants) contract version. |
java.lang.ClassLoader |
getCordappClassloader()
Returns the classloader containing all jar deployed in the 'cordapps' folder.
|
CordappProvider |
getCordappProvider()
Provides access to anything relating to cordapps including contract attachment resolution and app context
|
IdentityService |
getIdentityService()
An identity service maintains a directory of parties by their associated distinguished name/public keys and thus
|
KeyManagementService |
getKeyManagementService()
The key management service is responsible for storing and using private keys to sign things. An
implementation of this may, for example, call out to a hardware security module that enforces various
auditing and frequency-of-use requirements.
|
NodeInfo |
getMyInfo()
The
class NodeInfo object corresponding to our own entry in the network map. |
NetworkMapCache |
getNetworkMapCache()
A network map contains lists of nodes on the network along with information about their identity keys, services
they provide and host names or IP addresses where they can be connected to. The cache wraps around a map fetched
from an authoritative service, and adds easy lookup of the data stored within it. Generally it would be initialised
with a specified network map service, which it fetches data from and then subscribes to updates of.
|
NetworkParameters |
getNetworkParameters()
Returns the network parameters the node is operating under.
|
NetworkParametersService |
getNetworkParametersService()
Provides access to historical network parameters that are used in transaction resolution.
|
ServicesForResolution |
getServicesForResolution() |
net.corda.core.node.services.TransactionVerifierService |
getTransactionVerifierService()
INTERNAL. DO NOT USE.
|
TransactionStorage |
getValidatedTransactions()
A map of hash-
|
VaultService |
getVaultService()
The vault service lets you observe, soft lock and add notes to states that involve you or are relevant to your
node in some way. Additionally you may query and track states that correspond to various criteria.
|
java.sql.Connection |
jdbcSession()
Exposes a JDBC connection (session) object using the currently configured database.
Applications can use this to execute arbitrary SQL queries (native, direct, prepared, callable)
against its Node database tables (including custom contract tables defined by extending
interface QueryableState ). |
Attachment |
loadContractAttachment(StateRef stateRef)
Returns a dummy Attachment, in context of signature constrains non-downgrade rule this default to contract class version
1 . |
TransactionState<?> |
loadState(StateRef stateRef)
Given a
class StateRef loads the referenced transaction and looks up the specified output interface ContractState . |
java.util.Set<net.corda.core.contracts.StateAndRef> |
loadStates(java.util.Set<net.corda.core.contracts.StateRef> stateRefs)
Given a Set of
class StateRef 's loads the referenced transaction and looks up the specified output interface ContractState . |
static java.util.Properties |
makeTestDataSourceProperties(java.lang.String nodeName)
Make properties appropriate for creating a DataSource for unit tests.
Defaults configuration of in-memory H2 instance. If 'databaseProvider' system property is set then creates
a config from the relevant config file is present in resources folder (used to parametrize test to run against a remote database).
|
static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> |
makeTestDatabaseAndMockServices(java.util.List<java.lang.String> cordappPackages,
IdentityService identityService,
TestIdentity initialIdentity,
NetworkParameters networkParameters,
java.security.KeyPair moreKeys)
Makes database and mock services appropriate for unit tests.
|
static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> |
makeTestDatabaseAndMockServices(java.util.List<java.lang.String> cordappPackages,
IdentityService identityService,
TestIdentity initialIdentity,
java.security.KeyPair moreKeys)
Makes database and mock services appropriate for unit tests.
|
static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> |
makeTestDatabaseAndPersistentServices(java.util.List<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
NetworkParameters networkParameters,
java.util.Set<java.security.KeyPair> moreKeys,
java.util.Set<net.corda.core.identity.PartyAndCertificate> moreIdentities)
Makes database and persistent services appropriate for unit tests which require persistence across the vault, identity service
and key managment service.
|
static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> |
makeTestDatabaseAndPersistentServices(java.util.List<java.lang.String> cordappPackages,
TestIdentity initialIdentity,
java.util.Set<java.security.KeyPair> moreKeys,
java.util.Set<net.corda.core.identity.PartyAndCertificate> moreIdentities)
Makes database and persistent services appropriate for unit tests which require persistence across the vault, identity service
and key managment service.
|
void |
recordTransactions(StatesToRecord statesToRecord,
java.lang.Iterable<net.corda.core.transactions.SignedTransaction> txs)
Stores the given
class SignedTransaction s in the local transaction storage and then sends them to the vault for
further processing if statesToRecord is not StatesToRecord.NONE.
This is expected to be run within a database transaction. |
java.lang.Void |
registerUnloadHandler(kotlin.jvm.functions.Function0<kotlin.Unit> runOnStop)
Allows the registration of a callback that may inform services when the app is shutting down.
|
void |
setNetworkParametersService(NetworkParametersService p)
Provides access to historical network parameters that are used in transaction resolution.
|
<T> T |
withEntityManager(kotlin.jvm.functions.Function1<? super javax.persistence.EntityManager,? extends T> block)
Exposes the Java Persistence API (JPA) to flows via a restricted EntityManager. This method can be used to
persist and query entities which inherit from MappedSchema. This is particularly useful if off-ledger data
needs to be kept in conjunction with on-ledger state data.
|
void |
withEntityManager(java.util.function.Consumer<javax.persistence.EntityManager> block)
Exposes the Java Persistence API (JPA) to flows via a restricted EntityManager. This method can be used to
persist and query entities which inherit from MappedSchema. This is particularly useful if off-ledger data
needs to be kept in conjunction with on-ledger state data.
|
addSignature, addSignature, cordaService, createSignature, createSignature, createSignature, createSignature, getAppContext, getClock, getContractUpgradeService, getKeyManagementService, getMyInfo, getNetworkMapCache, getValidatedTransactions, getVaultService, jdbcSession, recordTransactions, recordTransactions, recordTransactions, recordTransactions, recordTransactions, registerUnloadHandler, signInitialTransaction, signInitialTransaction, signInitialTransaction, toStateAndRef, withEntityManager, withEntityManager
getAttachments, getCordappProvider, getIdentityService, getNetworkParameters, getNetworkParametersService, loadContractAttachment, loadState, loadStates
public static MockServices.Companion Companion
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, TestIdentity initialIdentity, IdentityService identityService, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, TestIdentity initialIdentity, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, TestIdentity initialIdentity, IdentityService identityService, NetworkParameters networkParameters, java.security.KeyPair moreKeys)
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, TestIdentity initialIdentity, IdentityService identityService, NetworkParameters networkParameters, java.security.KeyPair[] moreKeys, KeyManagementService keyManagementService)
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, CordaX500Name initialIdentityName, IdentityService identityService, java.security.KeyPair key, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, CordaX500Name initialIdentityName, java.security.KeyPair key, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
that looks for app code in the given package names, uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, CordaX500Name initialIdentityName, IdentityService identityService)
Create a mock interface ServiceHub
that can't load CorDapp code, which uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages, CordaX500Name initialIdentityName)
Create a mock interface ServiceHub
that can't load CorDapp code, which uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity.
public MockServices(java.lang.Iterable<java.lang.String> cordappPackages)
Create a mock interface ServiceHub
that can't load CorDapp code, and which uses a default service identity.
interface ServiceHub
public MockServices(CordaX500Name initialIdentityName, IdentityService identityService, java.security.KeyPair key, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity.
public MockServices(CordaX500Name initialIdentityName, java.security.KeyPair key, java.security.KeyPair moreKeys)
Create a mock interface ServiceHub
which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity.
public MockServices(CordaX500Name initialIdentityName, IdentityService identityService)
Create a mock interface ServiceHub
which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity. It has no keys.
public MockServices(CordaX500Name initialIdentityName)
Create a mock interface ServiceHub
which uses the package of the caller to find CorDapp code. It uses the provided identity service
(you can get one from MockServicesKt.makeTestIdentityService
) and which represents the given identity. It has no keys.
public MockServices(java.util.List<java.lang.String> cordappPackages, CordaX500Name initialIdentityName, IdentityService identityService, NetworkParameters networkParameters)
public MockServices(java.util.List<java.lang.String> cordappPackages, CordaX500Name initialIdentityName, IdentityService identityService, NetworkParameters networkParameters, java.security.KeyPair key)
public MockServices(TestIdentity firstIdentity, net.corda.testing.core.TestIdentity moreIdentities)
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.
public MockServices(TestIdentity firstIdentity, NetworkParameters networkParameters, net.corda.testing.core.TestIdentity moreIdentities)
public MockServices(java.util.List<java.lang.String> cordappPackages, TestIdentity firstIdentity, net.corda.testing.core.TestIdentity moreIdentities)
public MockServices(java.util.List<java.lang.String> cordappPackages, TestIdentity firstIdentity, NetworkParameters networkParameters, net.corda.testing.core.TestIdentity moreIdentities)
public MockServices()
Create a mock interface ServiceHub
which uses the package of the caller to find CorDapp code. It uses a default service
identity.
interface ServiceHub
public java.lang.ClassLoader getCordappClassloader()
Returns the classloader containing all jar deployed in the 'cordapps' folder.
public void recordTransactions(StatesToRecord statesToRecord, java.lang.Iterable<net.corda.core.transactions.SignedTransaction> txs)
Stores the given class SignedTransaction
s in the local transaction storage and then sends them to the vault for
further processing if statesToRecord is not StatesToRecord.NONE.
This is expected to be run within a database transaction.
txs
- The transactions to record.statesToRecord
- how the vault should treat the output states of the transaction.class SignedTransaction
public NetworkParameters getNetworkParameters()
Returns the network parameters the node is operating under.
public MockAttachmentStorage getAttachments()
Provides access to storage of arbitrary JAR files (which may contain only data, no code).
public VaultService getVaultService()
The vault service lets you observe, soft lock and add notes to states that involve you or are relevant to your node in some way. Additionally you may query and track states that correspond to various criteria.
public ContractUpgradeService getContractUpgradeService()
The interface ContractUpgradeService
is responsible for securely upgrading contract state objects according to
a specified and mutually agreed (amongst participants) contract version.
public NetworkMapCache getNetworkMapCache()
A network map contains lists of nodes on the network along with information about their identity keys, services they provide and host names or IP addresses where they can be connected to. The cache wraps around a map fetched from an authoritative service, and adds easy lookup of the data stored within it. Generally it would be initialised with a specified network map service, which it fetches data from and then subscribes to updates of.
public TestClock getClock()
A Clock representing the node's current time. This should be used in preference to directly accessing the clock so the current time can be controlled during unit testing.
public NodeInfo getMyInfo()
The class NodeInfo
object corresponding to our own entry in the network map.
class NodeInfo
public net.corda.core.node.services.TransactionVerifierService getTransactionVerifierService()
INTERNAL. DO NOT USE.
public CordappProvider getCordappProvider()
Provides access to anything relating to cordapps including contract attachment resolution and app context
public NetworkParametersService getNetworkParametersService()
Provides access to historical network parameters that are used in transaction resolution.
public void setNetworkParametersService(NetworkParametersService p)
Provides access to historical network parameters that are used in transaction resolution.
public ServicesForResolution getServicesForResolution()
public <T extends SerializeAsToken> T cordaService(java.lang.Class<T> type)
Return the singleton instance of the given Corda service type. This is a class that is annotated with
interface CordaService
and will have automatically been registered by the node.
interface CordaService
or if the instance is not found.interface CordaService
public java.sql.Connection jdbcSession()
Exposes a JDBC connection (session) object using the currently configured database.
Applications can use this to execute arbitrary SQL queries (native, direct, prepared, callable)
against its Node database tables (including custom contract tables defined by extending
interface QueryableState
).
When used within a flow, this session automatically forms part of the enclosing flow transaction boundary, and thus queryable data will include everything committed as of the last checkpoint.
interface QueryableState
public <T> T withEntityManager(kotlin.jvm.functions.Function1<? super javax.persistence.EntityManager,? extends T> block)
Exposes the Java Persistence API (JPA) to flows via a restricted EntityManager. This method can be used to persist and query entities which inherit from MappedSchema. This is particularly useful if off-ledger data needs to be kept in conjunction with on-ledger state data.
NOTE: Suspendable flow operations such as send, receive, subFlow and sleep, cannot be called within the lambda.
block
- a lambda function with access to an EntityManager.public void withEntityManager(java.util.function.Consumer<javax.persistence.EntityManager> block)
Exposes the Java Persistence API (JPA) to flows via a restricted EntityManager. This method can be used to persist and query entities which inherit from MappedSchema. This is particularly useful if off-ledger data needs to be kept in conjunction with on-ledger state data.
NOTE: Suspendable flow operations such as send, receive, subFlow and sleep, cannot be called within the lambda.
block
- a lambda function with access to an EntityManager.public java.lang.Void registerUnloadHandler(kotlin.jvm.functions.Function0<kotlin.Unit> runOnStop)
Allows the registration of a callback that may inform services when the app is shutting down.
The intent is to allow the cleaning up of resources - e.g. releasing ports.
You should not rely on this to clean up executing flows - that's what quasar is for.
Please note that the shutdown handler is not guaranteed to be called. In production the node process may crash, be killed by the operating system and other forms of fatal termination may occur that result in this code never running. So you should use this functionality only for unit/integration testing or for code that can optimise this shutdown e.g. by cleaning up things that would otherwise trigger a slow recovery process next time the node starts.
public void addMockCordapp(java.lang.String contractClassName)
Add the given package name to the list of packages which will be scanned for cordapp contract verification code
public TransactionState<?> loadState(StateRef stateRef)
Given a class StateRef
loads the referenced transaction and looks up the specified output interface ContractState
.
WARNING Do not use this method unless you really only want a single state - any batch loading should
go through ServicesForResolution.loadStates
as repeatedly calling ServicesForResolution.loadState
can lead to repeat deserialsiation work and
severe performance degradation.
class StateRef
,
interface ContractState
,
ServicesForResolution.loadStates
,
ServicesForResolution.loadState
public java.util.Set<net.corda.core.contracts.StateAndRef> loadStates(java.util.Set<net.corda.core.contracts.StateRef> stateRefs)
Given a Set of class StateRef
's loads the referenced transaction and looks up the specified output interface ContractState
.
class StateRef
,
interface ContractState
public Attachment loadContractAttachment(StateRef stateRef)
Returns a dummy Attachment, in context of signature constrains non-downgrade rule this default to contract class version 1
.
public TransactionStorage getValidatedTransactions()
A map of hash-
>tx where tx has been signature/contract validated and the states are known to be correct.The signatures aren't technically needed after that point, but we keep them around so that we can relaythe transaction data to other nodes that need it.
public IdentityService getIdentityService()
An identity service maintains a directory of parties by their associated distinguished name/public keys and thus
supports lookup of a party given its key, or name. The service also manages the certificates linking confidentialidentities back to the well known identity (i.e. the identity in the network map) of a party.
public KeyManagementService getKeyManagementService()
The key management service is responsible for storing and using private keys to sign things. An implementation of this may, for example, call out to a hardware security module that enforces various auditing and frequency-of-use requirements.
You don't normally need to use this directly. If you have a class TransactionBuilder
and wish to sign it to
get a class SignedTransaction
, look at signInitialTransaction.
class TransactionBuilder
,
class SignedTransaction
public static java.util.Properties makeTestDataSourceProperties(java.lang.String nodeName)
Make properties appropriate for creating a DataSource for unit tests. Defaults configuration of in-memory H2 instance. If 'databaseProvider' system property is set then creates a config from the relevant config file is present in resources folder (used to parametrize test to run against a remote database).
nodeName
- Reflects the "instance" of the in-memory database or database username/schema.
Defaults to a random string.public static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> makeTestDatabaseAndMockServices(java.util.List<java.lang.String> cordappPackages, IdentityService identityService, TestIdentity initialIdentity, NetworkParameters networkParameters, java.security.KeyPair moreKeys)
Makes database and mock services appropriate for unit tests.
cordappPackages
- A List of cordapp packages to scan for any cordapp code, e.g. contract verification code, flows and services.identityService
- An instance of interface IdentityService
, see MockServicesKt.makeTestIdentityService
.initialIdentity
- The first (typically sole) identity the services will represent.moreKeys
- A list of additional KeyPair instances to be used by class MockServices
.class MockServices
.public static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> makeTestDatabaseAndMockServices(java.util.List<java.lang.String> cordappPackages, IdentityService identityService, TestIdentity initialIdentity, java.security.KeyPair moreKeys)
Makes database and mock services appropriate for unit tests.
cordappPackages
- A List of cordapp packages to scan for any cordapp code, e.g. contract verification code, flows and services.identityService
- An instance of interface IdentityService
, see MockServicesKt.makeTestIdentityService
.initialIdentity
- The first (typically sole) identity the services will represent.moreKeys
- A list of additional KeyPair instances to be used by class MockServices
.class MockServices
.public static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> makeTestDatabaseAndPersistentServices(java.util.List<java.lang.String> cordappPackages, TestIdentity initialIdentity, NetworkParameters networkParameters, java.util.Set<java.security.KeyPair> moreKeys, java.util.Set<net.corda.core.identity.PartyAndCertificate> moreIdentities)
Makes database and persistent services appropriate for unit tests which require persistence across the vault, identity service and key managment service.
cordappPackages
- A List of cordapp packages to scan for any cordapp code, e.g. contract verification code, flows and services.initialIdentity
- The first (typically sole) identity the services will represent.moreKeys
- A list of additional KeyPair instances to be used by class MockServices
.moreIdentities
- A list of additional KeyPair instances to be used by class MockServices
.class MockServices
.public static kotlin.Pair<net.corda.nodeapi.internal.persistence.CordaPersistence,net.corda.testing.node.MockServices> makeTestDatabaseAndPersistentServices(java.util.List<java.lang.String> cordappPackages, TestIdentity initialIdentity, java.util.Set<java.security.KeyPair> moreKeys, java.util.Set<net.corda.core.identity.PartyAndCertificate> moreIdentities)
Makes database and persistent services appropriate for unit tests which require persistence across the vault, identity service and key managment service.
cordappPackages
- A List of cordapp packages to scan for any cordapp code, e.g. contract verification code, flows and services.initialIdentity
- The first (typically sole) identity the services will represent.moreKeys
- A list of additional KeyPair instances to be used by class MockServices
.moreIdentities
- A list of additional KeyPair instances to be used by class MockServices
.class MockServices
.