Skip to content

Commit 0f29c30

Browse files
committed
never kill yourself
1 parent afb7211 commit 0f29c30

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rpc_url": "https://api.mainnet-beta.solana.com",
2+
"rpc_url": "https://api.opensvm.com",
33
"commitment": "confirmed",
44
"protocol_version": "2024-11-05"
55
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl Config {
2121

2222
// Fall back to environment variables
2323
let rpc_url = env::var("SOLANA_RPC_URL")
24-
.unwrap_or_else(|_| "http://api.opensvm.com".to_string());
24+
.unwrap_or_else(|_| "https://api.opensvm.com".to_string());
2525

2626
let commitment = env::var("SOLANA_COMMITMENT")
2727
.unwrap_or_else(|_| "confirmed".to_string());

tests/e2e.rs

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ use solana_client::nonblocking::rpc_client::RpcClient;
22
use solana_sdk::{
33
commitment_config::CommitmentConfig,
44
pubkey::Pubkey,
5+
signer::{keypair::Keypair, Signer},
56
};
67

78
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
8-
async fn test_blockchain_operations() {
9+
async fn test_solana_operations() {
910
// Connect to Solana devnet
11+
// Use Solana's devnet endpoint
12+
// Use official devnet with longer timeout
1013
let rpc_url = "https://api.opensvm.com".to_string();
11-
let client = RpcClient::new_with_commitment(rpc_url.clone(), CommitmentConfig::confirmed());
14+
let timeout = std::time::Duration::from_secs(60);
15+
let commitment = CommitmentConfig::finalized();
16+
let client = RpcClient::new_with_timeout_and_commitment(rpc_url.clone(), timeout, commitment);
1217

13-
// Configure RPC client to support latest transaction versions
14-
let config = solana_client::rpc_config::RpcBlockConfig {
15-
encoding: None,
16-
transaction_details: None,
17-
rewards: None,
18-
commitment: None,
19-
max_supported_transaction_version: Some(0),
20-
};
21-
2218
println!("\nTesting health check:");
23-
let health = client.get_health().await.unwrap();
24-
println!("Health status: {:?}", health);
19+
match client.get_health().await {
20+
Ok(health) => println!("Health status: {:?}", health),
21+
Err(err) => {
22+
println!("Error details: {:?}", err);
23+
panic!("Health check failed: {}", err);
24+
}
25+
}
2526

2627
println!("\nTesting version info:");
2728
let version = client.get_version().await.unwrap();
@@ -56,13 +57,39 @@ async fn test_blockchain_operations() {
5657
}
5758
}
5859

59-
// Get block data using a slot we know exists from recent transactions
60-
if let Some(first_sig) = signatures.first() {
61-
println!("\nTesting block data for slot {}:", first_sig.slot);
62-
let block = client.get_block_with_config(first_sig.slot, config).await;
63-
match block {
64-
Ok(block) => println!("Block data: {:#?}", block),
65-
Err(e) => println!("Could not fetch block: {}", e),
66-
}
60+
// Test creating a new keypair and getting its info
61+
println!("\nTesting keypair operations:");
62+
let keypair = Keypair::new();
63+
let pubkey = keypair.pubkey();
64+
println!("Generated keypair with pubkey: {}", pubkey);
65+
66+
// Get account info (should be empty/not found)
67+
match client.get_account(&pubkey).await {
68+
Ok(account) => println!("Account exists with {} lamports", account.lamports),
69+
Err(e) => println!("Account not found as expected: {}", e),
70+
}
71+
72+
// Get minimum rent
73+
println!("\nTesting rent calculation:");
74+
let rent = client.get_minimum_balance_for_rent_exemption(0).await.unwrap();
75+
println!("Minimum balance for rent exemption: {} lamports", rent);
76+
77+
// Get recent block
78+
println!("\nTesting block info:");
79+
let slot = client.get_slot().await.unwrap();
80+
println!("Current slot: {}", slot);
81+
82+
// Get block production
83+
println!("\nTesting block production:");
84+
let production = client.get_block_production().await.unwrap();
85+
println!("Block production: {:?}", production);
86+
87+
// Get cluster nodes
88+
println!("\nTesting cluster info:");
89+
let nodes = client.get_cluster_nodes().await.unwrap();
90+
println!("Found {} cluster nodes", nodes.len());
91+
for node in nodes.iter().take(3) {
92+
let version = node.version.as_ref().map_or("unknown", |v| v.as_str());
93+
println!(" {}: {}", node.pubkey, version);
6794
}
6895
}

0 commit comments

Comments
 (0)