Attribute Macro trdelnik_sandbox_client::trdelnik_test
source · [−]#[trdelnik_test]
Expand description
The macro starts the Solana validator (localnet), runs your program test and then shuts down the validator.
- The test implicitly returns anyhow::Result<()>.
- All tests are run sequentially - each test uses a new/reset validator. (See serial_test::serial)
- Async support is provided by Tokio: tokio::test(flavor = “multi_thread”).
- The macro accepts one optional argument
root
with the default value"../../"
.- Example:
#[trdelnik_test(root = "../../")]
- Example:
- You can see the macro expanded in the crate’s tests.
Example
ⓘ
// tests/test.rs
use trdelnik_client::*;
#[trdelnik_test]
async fn test_turnstile() {
let reader = Reader::new();
let mut turnstile = Turnstile {
client: Client::new(reader.keypair("id").await?),
state: reader.keypair("state").await?,
program: reader.keypair("program").await?,
program_data: reader.program_data("turnstile").await?,
locked: bool::default(),
};
turnstile.initialize().await?;
}