swapnil
swapnil

Reputation: 124

How do I create nodes at runtime?

I recently started working with corda and try to create POC. There is one requirement is to create corda node at runtime. I have searched into corda documentation, but bad luck.

Is there any way to create nodes at runtime?

Upvotes: 0

Views: 59

Answers (1)

Clyde D'Cruz
Clyde D'Cruz

Reputation: 2065

You could have a look at net.corda.testing.driver which can be used to start up a set of test nodes for integration testing

class DriverBasedTest {
    private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB"))
    private val bankB = TestIdentity(CordaX500Name("BankB", "", "US"))

    @Test
    fun `node test`() = withDriver {
        // Start a pair of nodes and wait for them both to be ready.
        val (partyAHandle, partyBHandle) = startNodes(bankA, bankB)

        // From each node, make an RPC call to retrieve another node's name from the network map, to verify that the
        // nodes have started and can communicate.

        // This is a very basic test: in practice tests would be starting flows, and verifying the states in the vault
        // and other important metrics to ensure that your CorDapp is working as intended.
        assertEquals(bankB.name, partyAHandle.resolveName(bankB.name))
        assertEquals(bankA.name, partyBHandle.resolveName(bankA.name))
    }
}

From here -> https://github.com/corda/corda-settler/blob/master/cordapp/src/integrationTest/kotlin/com/template/DriverBasedTest.kt

Upvotes: 1

Related Questions