1 unstable release
new 0.1.0 | May 7, 2025 |
---|
#353 in Magic Beans
Used in 2 crates
18KB
284 lines
Chaos testing library for Internet Computer inter-canister calls
ic_call_chaos
is a small library to enable testing the resilience of Internet Computer canisters to inter-canister call failures.
It allows you to simulate various failure scenarios, such as dropped, timed out, or rejected calls, to ensure that your canisters
can handle these situations gracefully.
It is designed to be used in conjunction with the ic-cdk
library, which provides the necessary tools for building canisters on
the Internet Computer.
Usage
- Import
Call
and friends fromic_call_chaos
instead ofic_cdk::call
. The provided interface is the same asic_cdk::call
, but with additional functionality to simulate failures. The default policy isAllowAll
, which means that all calls will be passed to the underlyingic_cdk
library. You likely want to make the replacement import conditional on a feature flag, so that you don't inherit the overhead of (or any bugs in) the wrapper in production. - Provide a way to change the failure policy from tests.
- In your tests, apply the desired policy.
For examples, look at the source of this library, and in particular canister/src/lib.rs
for an example of how to
add ic_call_chaos
to your canister code, and pocket_ic_test/tests/integration_test.rs
for an example of how to
use it in your tests.
Dependencies
~4–11MB
~119K SLoC