Joel
Joel

Reputation: 23140

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

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

Answers (1)

Joel
Joel

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

Related Questions