Trdelník is Rust based testing framework providing several convenient developer tools for testing Solana programs written in Anchor.
nightly
release)stable
release)Currently Trdelnik is only available as a beta release, we are working hard toward the first official release coming within a few days.
```shell cargo install trdelnik-cli
cargo install --version
```shell
trdelnik init
.program_client
and trdelnik-tests
directories with all the necessary filestrdelnik test
trdelnik --help ```
``rust
// <my_project>/trdelnik-tests/tests/test.rs
// @todo: do not forget to add all necessary dependencies to the generated
trdelnik-tests/Cargo.toml`
use programclient::myinstruction;
use trdelnikclient::*;
use myprogram;
async fn initfixture() -> Fixture { // create a test fixture let mut fixture = Fixture { client: Client::new(systemkeypair(0)), program: programkeypair(1), state: keypair(42), }; // deploy a tested program fixture.deploy().await?; // call instruction init myinstruction::initialize( &fixture.client, fixture.state.pubkey(), fixture.client.payer().pubkey(), System::id(), Some(fixture.state.clone()), ).await?; fixture }
async fn testhappypath(#[future] initfixture: Result
#[ignore]
macro to skip the test.```rust
async fn test() {} ```
Trdelnik
does not export anchor-spl
and spl-associated-token-account
, so you have to add it manually.```toml
anchor-spl = "0.24.2" spl-associated-token-account = "1.0.3" ```
```rust
//
async fn initfixture() -> Fixture { // ... let account = keypair(1); let mint = keypair(2); // constructs a token mint client .createtokenmint(&mint, mint.pubkey(), None, 0) .await?; // constructs associated token account let tokenaccount = client .createassociatedtokenaccount(&account, mint.pubkey()) .await?; let associatedtokenprogram = splassociatedtokenaccount::id(); // derives the associated token account address for the given wallet and mint let associatedtokenaddress = splassociatedtokenaccount::getassociatedtokenaddress(&account.pubkey(), mint); Fixture { // ... token_program: Token::id(), } } ```
trdelnik init
command generated a dummy test suite for you.Anchor
and Solana
versions specified in the table below.| Trdelnik CLI | Anchor | Solana |
| ------------ | :------: | ------: |
| latest
| >=0.24
| >=1.9
|
Marinade Community Prize - winner of the Marinade grant for the 2022 Solana Riptide Hackathon.
Thank you for your interest in contributing to Trdelník! Please see the CONTRIBUTING.md to learn how.
This project is licensed under the MIT license.