v0.2.9-pre.013-fix.003
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
// file: crates/ksp-onchain-transport-lib/tests/yellowstone_publicnode_smoke.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
//! Opt-in live PublicNode Mainnet/Testnet smokes for authenticated provider-neutral Yellowstone gRPC Subscribe.
|
||||
|
||||
use std::io::IsTerminal; // rust-rules: trait-import
|
||||
|
||||
static PUBLICNODE_X_TOKEN: std::sync::OnceLock<std::string::String> = std::sync::OnceLock::new();
|
||||
struct PublicNodeTokens {
|
||||
mainnet: std::string::String,
|
||||
testnet: std::string::String,
|
||||
}
|
||||
|
||||
fn publicnode_x_token() -> &'static str {
|
||||
return PUBLICNODE_X_TOKEN
|
||||
.get_or_init(|| {
|
||||
assert!(
|
||||
!std::io::stdin().is_terminal(),
|
||||
"pipe the PublicNode personal x-token to this ignored smoke on stdin; never pass it as a command-line argument"
|
||||
);
|
||||
let mut token = std::string::String::new();
|
||||
std::io::stdin().read_line(&mut token).expect("PublicNode x-token must be readable from smoke stdin");
|
||||
let token = token.trim().to_owned();
|
||||
assert!(!token.is_empty(), "PublicNode x-token provided on smoke stdin must not be empty");
|
||||
return token;
|
||||
})
|
||||
.as_str();
|
||||
static PUBLICNODE_X_TOKENS: std::sync::OnceLock<PublicNodeTokens> = std::sync::OnceLock::new();
|
||||
|
||||
fn read_token_line(label: &str) -> std::string::String {
|
||||
let mut token = std::string::String::new();
|
||||
std::io::stdin().read_line(&mut token).expect("PublicNode x-token must be readable from smoke stdin");
|
||||
let token = token.trim().to_owned();
|
||||
assert!(!token.is_empty(), "PublicNode {label} x-token provided on smoke stdin must not be empty");
|
||||
return token;
|
||||
}
|
||||
|
||||
fn publicnode_x_tokens() -> &'static PublicNodeTokens {
|
||||
return PUBLICNODE_X_TOKENS.get_or_init(|| {
|
||||
assert!(
|
||||
!std::io::stdin().is_terminal(),
|
||||
"pipe two PublicNode personal x-tokens to this ignored smoke on stdin: Mainnet first, Testnet second; never pass them as command-line arguments"
|
||||
);
|
||||
return PublicNodeTokens { mainnet: read_token_line("Mainnet"), testnet: read_token_line("Testnet") };
|
||||
});
|
||||
}
|
||||
|
||||
fn publicnode_endpoint(
|
||||
@@ -65,11 +72,10 @@ fn slot_request() -> ksp_core_lib::Result<ksp_onchain_transport_lib::Yellowstone
|
||||
return std::result::Result::Ok(request);
|
||||
}
|
||||
|
||||
async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str) {
|
||||
let endpoint = publicnode_endpoint(name, cluster, url, publicnode_x_token())
|
||||
.expect("programmatic PublicNode Yellowstone settings must accept secret x-token metadata");
|
||||
async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str, x_token: &str) {
|
||||
let endpoint = publicnode_endpoint(name, cluster, url, x_token).expect("programmatic PublicNode Yellowstone settings must accept secret x-token metadata");
|
||||
let endpoint_debug = format!("{endpoint:?}");
|
||||
assert!(!endpoint_debug.contains(publicnode_x_token()), "PublicNode x-token must not appear in endpoint Debug");
|
||||
assert!(!endpoint_debug.contains(x_token), "PublicNode x-token must not appear in endpoint Debug");
|
||||
let channel = ksp_onchain_transport_lib::YellowstoneGrpcChannel::connect(&endpoint).await.expect("PublicNode Yellowstone TLS connection must succeed");
|
||||
assert_eq!(channel.endpoint_name(), name);
|
||||
assert_eq!(channel.provider().as_str(), "publicnode");
|
||||
@@ -88,17 +94,43 @@ async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str) {
|
||||
.await
|
||||
.expect("PublicNode Yellowstone Subscribe must publish a slot update before the smoke deadline");
|
||||
assert!(slot > 0);
|
||||
session.close().await.expect("PublicNode Yellowstone Subscribe must close cleanly");
|
||||
let close_result = tokio::time::timeout(std::time::Duration::from_secs(7), session.close())
|
||||
.await
|
||||
.expect("KSP Yellowstone Subscribe close must remain bounded beyond the configured five-second provider half-close deadline");
|
||||
match close_result {
|
||||
std::result::Result::Ok(()) => {},
|
||||
std::result::Result::Err(error) => {
|
||||
assert_eq!(
|
||||
error.code(),
|
||||
ksp_onchain_transport_lib::ERROR_CODE_TIMEOUT,
|
||||
"after a live slot was observed, PublicNode close may time out waiting for provider half-close but must not fail for another reason: {error:?}"
|
||||
);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
#[ignore = "opt-in live PublicNode Mainnet Yellowstone gRPC smoke; reads one personal x-token from stdin and performs an external TLS/Subscribe request"]
|
||||
async fn publicnode_mainnet_yellowstone_streams_slots_with_secret_x_token() {
|
||||
assert_publicnode_slot_stream("publicnode_mainnet_yellowstone", "mainnet-beta", "https://solana-yellowstone-grpc.publicnode.com:443").await;
|
||||
#[ignore = "opt-in live PublicNode Mainnet Yellowstone gRPC smoke; reads the first personal x-token line from stdin and performs an external TLS/Subscribe request"]
|
||||
async fn publicnode_mainnet_yellowstone_streams_slots_with_network_scoped_secret_x_token() {
|
||||
let tokens = publicnode_x_tokens();
|
||||
assert_publicnode_slot_stream(
|
||||
"publicnode_mainnet_yellowstone",
|
||||
"mainnet-beta",
|
||||
"https://solana-yellowstone-grpc.publicnode.com:443",
|
||||
tokens.mainnet.as_str(),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
#[ignore = "opt-in live PublicNode Testnet Yellowstone gRPC smoke; reuses the personal x-token read from stdin and performs an external TLS/Subscribe request"]
|
||||
async fn publicnode_testnet_yellowstone_streams_slots_with_secret_x_token() {
|
||||
assert_publicnode_slot_stream("publicnode_testnet_yellowstone", "testnet", "https://solana-testnet-yellowstone-grpc.publicnode.com:443").await;
|
||||
#[ignore = "opt-in live PublicNode Testnet Yellowstone gRPC smoke; reads the second personal x-token line from stdin and performs an external TLS/Subscribe request"]
|
||||
async fn publicnode_testnet_yellowstone_streams_slots_with_network_scoped_secret_x_token() {
|
||||
let tokens = publicnode_x_tokens();
|
||||
assert_publicnode_slot_stream(
|
||||
"publicnode_testnet_yellowstone",
|
||||
"testnet",
|
||||
"https://solana-testnet-yellowstone-grpc.publicnode.com:443",
|
||||
tokens.testnet.as_str(),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user