Skip to content

Commit

Permalink
General Updates n Add test_client.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo committed Apr 18, 2024
1 parent ecbe283 commit f8302c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::types::Cluster;
use reqwest::Client;

pub struct Helius {
config: Config,
client: Client,
pub config: Config,
pub client: Client,
}

impl Helius {
Expand Down
1 change: 0 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ impl Config {
return Err(HeliusError::InvalidInput("API key must not be empty".to_string()));
}


let endpoints: HeliusEndpoints = match cluster {
Cluster::Devnet => HeliusEndpoints {
api: "https://api-devnet.helius-rpc.com".to_string(),
Expand Down
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub enum HeliusError {
#[error("Unknown error has occurred: HTTP {code} - {text}")]
Unknown { code: StatusCode, text: String },
}


// Handy type alias
pub type Result<T> = std::result::Result<T, HeliusError>;
15 changes: 15 additions & 0 deletions tests/test_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use helius_rust_sdk::client::Helius;
use helius_rust_sdk::error::HeliusError;
use helius_rust_sdk::types::Cluster;

#[test]
fn test_creating_new_client_success() {
let api_key: &str = "valid-api-key";
let cluster: Cluster = Cluster::Devnet;

let result: Result<Helius, HeliusError> = Helius::new(api_key, cluster);
assert!(result.is_ok());

let helius: Helius = result.unwrap();
assert_eq!(helius.config.api_key, api_key);
}
2 changes: 1 addition & 1 deletion tests/test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn test_config_new_with_valid_api_key() {
let result: Result<Config, HeliusError> = Config::new("valid-api-key", Cluster::Devnet);
assert!(result.is_ok());

let config = result.unwrap();
let config: Config = result.unwrap();
assert_eq!(config.api_key, "valid-api-key");
assert_eq!(config.endpoints.api, "https://api-devnet.helius-rpc.com");
assert_eq!(config.endpoints.rpc, "https://devnet.helius-rpc.com");
Expand Down

0 comments on commit f8302c4

Please sign in to comment.