1#![deny(clippy::implicit_return)]
2#![allow(clippy::needless_return)]
3
4mod common;
5mod util;
6mod api;
7mod request_handler;
8
9pub use {
10 api::*,
11 common::*,
12 util::*,
13};
14
15#[cfg(test)]
23mod tests {
24 use super::*;
25 struct Config {
26 client: Helius,
27 address: String,
28 webhook_url: String,
29 txn: String,
30 collection: String,
31 token_mint: String
32 }
33
34 impl Config {
35 pub fn new() -> Config {
36 return Config {
37 client: Helius::new(std::env::var("API_KEY").unwrap(), Cluster::MainnetBeta),
38 address: std::env::var("ADDRESS").unwrap(),
39 webhook_url: std::env::var("WEBHOOK_URL").unwrap(),
40 txn: std::env::var("TXN").unwrap(),
41 collection: std::env::var("COL").unwrap(),
42 token_mint: std::env::var("TMINT").unwrap()
43 };
44 }
45 }
46
47 #[test]
48 #[ignore]
49 fn test_balances() {
50 let config = Config::new();
51 assert!(config.client.balances(config.address.as_str()).is_ok())
52 }
53
54 #[test]
55 #[ignore]
56 fn test_webhook() {
57 let config = Config::new();
58 let req = CreateWebhookRequest {
59 data: WebhookData {
60 webhook_url: config.webhook_url,
61 transaction_types: vec![TransactionType::Burn],
62 account_addresses: vec![config.address],
63 webhook_type: None,
64 auth_header: None,
65 txn_status: None,
66 encoding: None,
67 },
68 };
69 let hook_res = config.client.create_webhook(&req);
70 assert!(hook_res.is_ok());
71 let hook = hook_res.unwrap();
72 assert_eq!(config.client.get_all_webhooks().unwrap().len(), 1);
73 let mut hooky = config.client.get_webhook_by_id(hook.webhook_id.as_str()).unwrap();
74 hooky.webhook_data.transaction_types.push(TransactionType::Fuse);
75 let edited_hook = config.client.edit_webhook(
76 &EditWebhookRequest {
77 webhook_id: hooky.webhook_id.clone(),
78 data: hooky.webhook_data
79 }).unwrap();
80 assert_eq!(edited_hook.webhook_data.transaction_types, vec![TransactionType::Burn, TransactionType::Fuse]);
81 assert!(config.client.delete_webhook(edited_hook.webhook_id.as_str()).is_ok());
82 }
83
84 #[test]
85 #[ignore]
86 fn test_get_names() {
87 let config = Config::new();
88 assert!(config.client.get_names(config.address.as_str()).is_ok());
89 }
90
91 #[test]
92 #[ignore]
93 fn test_enhanced_txn() {
94 let config = Config::new();
95 let res = config.client.parse_transaction(
96 &ParseTransactionsRequest {
97 transactions: vec![config.txn],
98 }).unwrap();
99 }
100
101 #[test]
102 #[ignore]
103 fn test_get_mintlist() {
104 let config = Config::new();
105 assert!(config.client.get_mintlist(&MintlistRequest {
106 query: CollectionIdentifier::FirstVerifiedCreators(vec![config.collection]),
107 options: Some(HeliusOptions{limit: Some(10), pagination_token: None}),
108 }).is_ok());
109 }
110
111 #[test]
112 #[ignore]
113 fn test_get_metadata() {
114 let config = Config::new();
115 config.client.get_token_metadata(&TokenMetadataRequest{
116 mint_accounts: vec![config.token_mint],
117 include_off_chain: true,
118 disable_cache: false
119 }).unwrap();
120 }
121}