Joel
Joel

Reputation: 23140

Corda service does not exist when running flow tests with a MockNetwork

I have a CorDapp where I define an oracle. The oracle works fine when running the nodes normally. However, when running flow tests using a MockNetwork, I get the following exception:

net.corda.core.flows.FlowException: java.lang.IllegalArgumentException: Corda service net.corda.option.oracle.oracle.Oracle does not exist

How can I register the Corda service with the MockNetwork or get it to recognise it?

Upvotes: 0

Views: 409

Answers (1)

Joel
Joel

Reputation: 23140

When initialising the MockNetwork, you must pass the package where the service is defined as one of the CorDapp packages to scan. So in your case, you would write:

private val mockNet: MockNetwork = MockNetwork(
    cordappPackages = listOf("net.corda.option.oracle.oracle")
)

Upvotes: 2

Related Questions