Expand description
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
Calland friends fromic_call_chaosinstead 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_cdklibrary. 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.
Structs§
- Allow
All - A simple policy that allows all calls.
- Allow
Every Other - A simple policy that fails every other call with a
SysTransientreject code. - Call
- A wrapper around
ic_cdk::call::Callthat enables “chaos testing” by failing calls according to a policy set byset_policy. It’s implemented as a drop-in replacement foric_cdk::call::Call, so it can be used in lieu of it by simple changing imports. See the documentation onic_cdk::call::Callfor more details on the individual methods. - Call
Future - DenyAll
- A simple policy that denies all calls, returning a
SysTransientreject code. - With
Probability - A policy that allows calls with a given probability. The probability is a float between 0 and 1.
For bounded wait calls, if
silently_perform_bounded_wait_callsis set to true, bounded-wat calls A will be executed though a reject code (SysUnknown) will be returned. This is useful for simulating timeouts in production.
Enums§
Traits§
- Policy
- A trait that defines a policy for allowing or rejecting calls.