In the Corda flow testing framework, how can I get an RPC connection to a mock node?

喜夏-厌秋 提交于 2019-12-23 05:12:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!