Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
test_utils_solana
Provides utilities and extensions for testing Solana programs. This includes helpers for setting up a test validator, managing test accounts, and interacting with programs in a test environment. It is designed to be compatible with WASM environments.
Installation
To install you can used the following command:
Or directly add the following to your Cargo.toml:
[]
= "0.8.0"
Features
| Feature | Description |
|---|---|
test_validator |
Enables the test_validator feature for the solana_test_validator crate. |
Usage
The following requires the test_validator feature to be enabled.
use pubkey;
use TestValidatorRunner;
use TestValidatorRunnerProps;
async
Guide
When writing tests that use this library, you'll need to use the #[tokio::test(flavor = "multi_thread")] attribute on your test functions. This is because the test validator runs in a separate thread, and your test will need to communicate with it asynchronously.
Using TestValidatorRunner for Integration Tests
For integration tests that require a realistic Solana runtime, you can use TestValidatorRunner.
use pubkey;
use TestValidatorRunner;
use TestValidatorRunnerProps;
async
Using ProgramTest for Unit Tests
For more lightweight unit tests, you can use ProgramTest from solana-program-test. This library provides helpers to make it easier to work with.
use Account;
use sol_str_to_lamports;
use ProgramTest;
use Pubkey;
use TestRpcProvider;
async