PocketIC concurrency testing: Simulate multiple users performing transactions simultaneously.

I am testing a DeFi application built on ICP using PocketIC. My goal is to simulate multiple users performing transactions (e.g., supply and withdraw) simultaneously to check for concurrency-related issues such as race conditions and state inconsistencies.

To achieve this, I have tried Rayon (for parallelism) and Tokio (for async tasks), but neither is working as expected.
I am looking for suggestions or alternative approaches to properly simulate multiple users performing transactions at the same time in PocketIC.

Possible Questions & Assistance Needed

  1. Is PocketIC handling transactions in a blocking manner internally, preventing true concurrency?
  2. Should I be using a different approach to simulate parallel execution of multiple users?

Please take a look at this tutorial.

2 Likes