Corda Bi-Weekly FAQ #5

April 05, 2021

This week, we wanted to share some of our top tips for one of your most-asked-about topics: debugging CorDapps.

How should I test my CorDapps?

Unit tests are the most efficient way to test your Cordapps – much faster than recompiling your nodes and re-running the network locally to hand-test them. If your flows pass unit tests, they will work in the live shell and production. Just make sure that your tests are comprehensive.

How do I set up unit tests? 

We recommend using  JUnit and a Corda mock network. You can find many setup examples in our samples repos for Java and Kotlin.

How do I debug my unit tests?

You may run into issues or bugs that are hard to find with the usual calls to print.

One of the most powerful ways to debug unit tests is with IntelliJ breakpoints, where you can inspect your variables comprehensively:

You’ll want to mark the specific lines with breakpoints – just click the red dots in the sidebar. Then run your test in debug mode, and you’ll see all your variables at each breakpoint at each point in time.

You can learn more about breakpoints in this article from JetBrains.

What are some common errors? 

“X does not belong to this contract” –  you might find this if you haven’t correctly specified a contract ID. You always want to use the fully qualified class name.

Does errors.https://corda.net still work? 

Sometimes when developers get errors in Corda, their debug message referserrors.https://corda.net – which no longer exists. For example:

2020-10-15T21:02:52.653322440Z [ERROR] 21:02:52+0000 [flow-worker] proxies.ExceptionSerialisingRpcOpsProxy.log – Error during RPC invocation [errorCode=g3v6fv, moreInformationAt=https://errors.https://corda.net/ENT/4.2/g3v6fv] {actor_id=user1, actor_owning_identity=O=MCC, L=New York, C=US, actor_store_id=NODE_CONFIG, fiber-id=10000007, flow-id=68a4b569-1a01-4541-9fd6-bfe7c719cf57, invocation_id=e6655c29-bffe-49c7-821e-67fd55e8ee7c, invocation_timestamp=2020-10-15T21:02:52.530Z, origin=user1, session_id=231ec56b-ca6d-4e98-94ba-385ed7c28575, session_timestamp=2020-10-15T20:50:34.602Z, thread-id=425}

Here are some other resources if you’re looking for guidance on debugging CorDapps:

If you’d like to see more blog posts like these or have ideas on what we should add, feel free to send a note to [email protected].

Share: