-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use solana_sdk::signature::Keypair; | ||
|
||
/// Generates a specified number of keypairs | ||
/// | ||
/// # Arguments | ||
/// * `amount` - The number of keypairs to generate | ||
/// | ||
/// # Returns | ||
/// A vector of `Keypair` | ||
pub fn make_keypairs(amount: usize) -> Vec<Keypair> { | ||
(0..amount).map(|_| Keypair::new()).collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub use self::deserialize_str_to_number::deserialize_str_to_number; | ||
pub use self::is_valid_solana_address::is_valid_solana_address; | ||
pub use self::make_keypairs::make_keypairs; | ||
|
||
mod deserialize_str_to_number; | ||
mod is_valid_solana_address; | ||
mod make_keypairs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use helius_sdk::utils::make_keypairs; | ||
use solana_sdk::{signature::Keypair, signer::Signer}; | ||
use std::collections::HashSet; | ||
|
||
#[test] | ||
fn test_make_keypairs_generates_correct_amount() { | ||
let amounts: Vec<usize> = vec![1, 5, 10]; | ||
|
||
for amount in amounts { | ||
let keypairs: Vec<Keypair> = make_keypairs(amount); | ||
assert_eq!(keypairs.len(), amount, "Should generate the correct number of keypairs"); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_make_keypairs_are_unique() { | ||
let keypairs: Vec<Keypair> = make_keypairs(10); | ||
let mut seen: HashSet<_> = HashSet::new(); | ||
|
||
for keypair in keypairs { | ||
let pk = keypair.pubkey().to_string(); | ||
assert!(seen.insert(pk), "Each keypair should be unique"); | ||
} | ||
} |