Skip to content

Commit

Permalink
feat: add test_utils_keypairs crate
Browse files Browse the repository at this point in the history
- Introduced a new `test_utils_keypairs` crate to provide utilities for working with predefined keypairs, improving the testing framework for Solana applications.
- Updated `Cargo.toml` and `Cargo.lock` files across multiple crates to include `test_utils_keypairs` as a dependency.
- Modified existing tests to utilize the new keypair utilities, replacing references to `test_utils_solana`.
- Enhanced documentation in `readme.md` to reflect the addition of the new crate and its purpose.

This commit enhances the testing capabilities by providing essential keypair utilities, streamlining the development process for Solana-based projects.
  • Loading branch information
ifiokjr committed Dec 13, 2024
1 parent c56d14e commit e7c7abe
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .release-plz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ changelog_path = "crates/memory_wallet/changelog.md"
name = "test_utils_insta"
changelog_path = "crates/test_utils_insta/changelog.md"

[[package]]
name = "test_utils_keypairs"
changelog_path = "crates/test_utils_keypairs/changelog.md"

[[package]]
name = "test_utils_solana"
changelog_path = "crates/test_utils_solana/changelog.md"
Expand Down
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ zstd = { version = "0.13", default-features = false }
# internal crates
example_client = { path = "./programs/example_client" }
example_program = { path = "./programs/example_program" }
test_utils_insta = { path = "./crates/test_utils_insta" }

# publishable crates
memory_wallet = { path = "./crates/memory_wallet", version = "0.1.16" }
test_utils_anchor = { path = "./crates/test_utils_anchor" }
test_utils_insta = { path = "./crates/test_utils_insta", version = "0.1.0" }
test_utils_keypairs = { path = "./crates/test_utils_keypairs", version = "0.1.0" }
test_utils_solana = { path = "./crates/test_utils_solana", version = "0.6.1" }
wasm_client_anchor = { path = "./crates/wasm_client_anchor", version = "0.8.0" }
wasm_client_solana = { path = "./crates/wasm_client_solana", version = "0.7.0" }
Expand Down
1 change: 1 addition & 0 deletions crates/memory_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ anyhow = { workspace = true }
assert2 = { workspace = true }
test-log = { workspace = true, features = ["trace"] }
test_utils_insta = { workspace = true }
test_utils_keypairs = { workspace = true }
test_utils_solana = { workspace = true, features = ["test_validator"] }
tokio = { workspace = true, features = ["test-util"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/memory_wallet/tests/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use solana_sdk::signature::Signature;
use solana_sdk::system_instruction::transfer;
use solana_sdk::transaction::VersionedTransaction;
use test_log::test;
use test_utils_solana::get_wallet_keypair;
use test_utils_keypairs::get_wallet_keypair;
use test_utils_solana::prelude::*;
use test_utils_solana::ProgramTest;
use test_utils_solana::ProgramTestContext;
Expand Down
17 changes: 17 additions & 0 deletions crates/test_utils_keypairs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "test_utils_keypairs"
version = "0.1.0"
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
readme = "readme.md"
repository = { workspace = true }
rust-version = { workspace = true }
description = "Test utils to make working with pre defined keypairs easier."

[dependencies]
solana-sdk = { workspace = true }

[lints]
workspace = true
9 changes: 9 additions & 0 deletions crates/test_utils_keypairs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# test_utils_keypairs

> Test utils to make working with pre defined keypairs easier.
## Usage

```rust
use test_utils_keypairs::*;
```
File renamed without changes.
1 change: 1 addition & 0 deletions crates/test_utils_solana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ assert2 = { workspace = true }
insta = { workspace = true, features = ["redactions", "json"] }
test-log = { workspace = true, features = ["trace"] }
test_utils_insta = { workspace = true }
test_utils_keypairs = { workspace = true }
tokio = { workspace = true, features = ["test-util", "time"] }

[features]
Expand Down
2 changes: 0 additions & 2 deletions crates/test_utils_solana/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub use keypairs::*;
pub use solana_banks_client::BanksClientExt;
pub use solana_banks_interface::BanksTransactionResultWithSimulation;
pub use solana_program_runtime;
Expand All @@ -16,7 +15,6 @@ pub use test_rpc_provider::*;
pub use test_validator_runner::*;
pub use utils::*;

mod keypairs;
mod macros;
mod test_rpc_provider;
#[cfg(feature = "test_validator")]
Expand Down
2 changes: 1 addition & 1 deletion crates/test_utils_solana/tests/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::Duration;

use assert2::check;
use solana_sdk::signature::Keypair;
use test_utils_solana::get_wallet_keypair;
use test_utils_keypairs::get_wallet_keypair;
use test_utils_solana::prelude::*;
use test_utils_solana::TestValidatorRunner;
use test_utils_solana::TestValidatorRunnerProps;
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm_client_solana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ insta = { workspace = true, features = ["redactions", "json"] }
spl-pod = { workspace = true }
test-log = { workspace = true, features = ["trace"] }
test_utils_insta = { workspace = true }
test_utils_solana = { workspace = true }
test_utils_keypairs = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }
wasm-bindgen-test = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/wasm_client_solana/tests/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use assert2::check;
use futures_timer::Delay;
use solana_sdk::native_token::sol_to_lamports;
use solana_sdk::signature::Keypair;
use test_utils_solana::get_wallet_keypair;
use test_utils_keypairs::get_wallet_keypair;
use wasm_bindgen_test::*;
use wasm_client_solana::prelude::*;
use wasm_client_solana::rpc_config::LogsSubscribeRequest;
Expand Down
1 change: 1 addition & 0 deletions programs/example_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ memory_wallet = { workspace = true }
test-log = { workspace = true, features = ["log", "trace"] }
test_utils_anchor = { workspace = true, features = ["test_validator"] }
test_utils_insta = { workspace = true }
test_utils_keypairs = { workspace = true }
test_utils_solana = { workspace = true, features = ["test_validator"] }
tokio = { workspace = true, features = ["test-util", "rt", "macros", "time"] }

Expand Down
2 changes: 1 addition & 1 deletion programs/example_client/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signature;
use test_utils_anchor::anchor_processor;
use test_utils_anchor::prelude::*;
use test_utils_solana::get_wallet_keypair;
use test_utils_keypairs::get_wallet_keypair;
use test_utils_solana::ProgramTest;
use test_utils_solana::TestRpcProvider;

Expand Down
21 changes: 15 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@

This repository contains several crates that make it easier to interact with Solana in WebAssembly environments:

| Crate | Version | Description |
| -------------------- | ------- | ------------------------------------------------------- |
| `test_utils_solana` | 0.5.5 | Testing utilities for Solana programs |
| `test_utils_anchor` | 0.5.5 | Testing utilities specific to Anchor programs |
| `wasm_client_anchor` | 0.7.0 | WebAssembly client for interacting with Anchor programs |
| `wasm_client_solana` | 0.7.0 | WebAssembly client for interacting with Solana programs |
| Crate | Version | Description |
| --------------------- | ------- | ------------------------------------------------------------------------- |
| `memory_wallet` | 0.1.16 | A memory based wallet standard implementation primarily used for testing. |
| `test_utils_insta` | 0.1 | Test utilities for working with `insta` redactions |
| `test_utils_keypairs` | 0.1 | Test utilities for working with pre defined keypairs |
| `test_utils_solana` | 0.5 | Testing utilities for Solana programs |
| `test_utils_anchor` | 0.5 | Testing utilities specific to Anchor programs |
| `wasm_client_anchor` | 0.7.0 | WebAssembly client for interacting with Anchor programs |
| `wasm_client_solana` | 0.7.0 | WebAssembly client for interacting with Solana programs |

### Crate Details

- **memory_wallet**: A memory based wallet standard implementation primarily used for testing.

- **test_utils_insta**: Test utilities for working with `insta` redactions.

- **test_utils_keypairs**: Test utilities for working with pre defined keypairs.

- **test_utils_solana**: A collection of utilities to make testing Solana programs easier. Includes helpers for setting up test validators, creating test accounts, and managing test transactions.

- **test_utils_anchor**: Extension of test utilities specifically designed for testing Anchor programs. Provides additional helpers for working with Anchor IDLs and program testing.
Expand Down

0 comments on commit e7c7abe

Please sign in to comment.