问题
When creating a mock network for testing flows in Corda, how can I get an RPC connection to one of the mock nodes?
回答1:
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.")
}
}
来源:https://stackoverflow.com/questions/51495748/in-the-corda-flow-testing-framework-how-can-i-get-an-rpc-connection-to-a-mock-n