public class StartedMockNode
A class that represents a started mock node for testing.
@NotNull public net.corda.core.node.ServiceHub getServices()
The ServiceHub for the underlying node.
public int getId()
An identifier for the node. By default this is allocated sequentially in a class MockNetwork
.
class MockNetwork
@NotNull public net.corda.core.node.NodeInfo getInfo()
The NodeInfo for the underlying node.
@NotNull public <T> net.corda.core.concurrent.CordaFuture<T> startFlow(@NotNull net.corda.core.flows.FlowLogic<? extends T> logic)
Starts an already constructed flow. Note that you must be on the server thread to call this method.
@NotNull public <F extends FlowLogic<?>> rx.Observable<F> registerInitiatedFlow(@NotNull java.lang.Class<F> initiatedFlowClass)
Manually register an initiating-responder flow pair based on the FlowLogic annotations.
NOTE: There is no need to call this method if the flow pair is defined in the CorDapp and the class TestCordapp
API is used.
initiatedFlowClass
- FlowLogic class which is annotated with InitiatedBy.class TestCordapp
@NotNull public <F extends FlowLogic<?>> rx.Observable<F> registerInitiatedFlow(@NotNull java.lang.Class<? extends net.corda.core.flows.FlowLogic<?>> initiatingFlowClass, @NotNull java.lang.Class<F> initiatedFlowClass)
Register a custom relationship between initiating and receiving flow on a node-by-node basis. This is used when we want to manually specify that a particular initiating flow class will have a particular responder.
Note that this change affects only the node on which this method is called, and not the entire network.
initiatingFlowClass
- The FlowLogic-inheriting class to register a new responder for.initiatedFlowClass
- The class of the responder flow.public void stop()
Stop the node.
@Nullable public net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer pumpReceive(boolean block)
Delivers a single message from the internal queue. If there are no messages waiting to be delivered and block is true, waits until one has been provided on a different thread via send. If block is false, the return result indicates whether a message was delivered or not.
@NotNull public <F extends FlowLogic<?>> java.util.List<kotlin.Pair> findStateMachines(@NotNull java.lang.Class<F> flowClass)
Returns the currently live flows of type flowClass
, and their corresponding result future.
flowClass
public <T> T transaction(@NotNull kotlin.jvm.functions.Function0<? extends T> statement)
Executes given statement in the scope of transaction.
statement
- to be executed in the scope of this transaction.