Reputation: 23140
When creating a mock network for testing flows in Corda, how can I get an RPC connection to one of the mock nodes?
Upvotes: 0
Views: 296
Reputation: 23140
The mock nodes do not expose an API for getting an RPC connection.
If you need to run tests that involve a node's RPC connection, you should start the nodes via the node driver:
fun main(args: Array<String>) {
val user = User("user1", "test", permissions = setOf("ALL"))
driver(DriverParameters(startNodesInProcess = true, waitForAllNodesToFinish = true)) {
val partyA = startNode(providedName = CordaX500Name("PartyA", "London", "GB"), rpcUsers = listOf(user)).getOrThrow()
val cordaRPCOps = partyA.rpc
TODO("Tests using the RPC connection.")
}
}
Upvotes: 2