v0.2.9-pre.013-fix.002

This commit is contained in:
2026-08-24 23:02:18 +02:00
parent d98ee736be
commit c6c5793c61
6 changed files with 249 additions and 20 deletions

View File

@@ -1,9 +1,34 @@
// file: crates/ksp-onchain-transport-lib/tests/yellowstone_publicnode_smoke.rs
// version: 2
// version: 3
//! Opt-in live PublicNode Mainnet/Testnet smokes for the provider-neutral Yellowstone gRPC Subscribe facade.
//! Opt-in live PublicNode Mainnet/Testnet smokes for authenticated provider-neutral Yellowstone gRPC Subscribe.
fn publicnode_endpoint(name: &str, cluster: &str, url: &str) -> ksp_core_lib::Result<ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings> {
use std::io::IsTerminal; // rust-rules: trait-import
static PUBLICNODE_X_TOKEN: std::sync::OnceLock<std::string::String> = std::sync::OnceLock::new();
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();
}
fn publicnode_endpoint(
name: &str,
cluster: &str,
url: &str,
x_token: &str,
) -> ksp_core_lib::Result<ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings> {
let url = match ksp_onchain_transport_lib::YellowstoneGrpcEndpointUrl::parse(url) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error),
@@ -18,14 +43,16 @@ fn publicnode_endpoint(name: &str, cluster: &str, url: &str) -> ksp_core_lib::Re
16 * 1024 * 1024,
4 * 1024 * 1024,
);
return std::result::Result::Ok(ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings::new(
let endpoint = ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings::new(
name,
true,
ksp_onchain_transport_lib::YellowstoneGrpcProviderName::new("publicnode"),
ksp_onchain_transport_lib::YellowstoneGrpcClusterName::new(cluster),
url,
session,
));
);
let metadata = ksp_onchain_transport_lib::YellowstoneGrpcMetadataEntry::secret("x-token", x_token)?;
return endpoint.with_metadata(vec![metadata]);
}
fn slot_request() -> ksp_core_lib::Result<ksp_onchain_transport_lib::YellowstoneSubscribeRequest> {
@@ -39,13 +66,16 @@ fn slot_request() -> ksp_core_lib::Result<ksp_onchain_transport_lib::Yellowstone
}
async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str) {
let endpoint = publicnode_endpoint(name, cluster, url).expect("programmatic PublicNode Yellowstone settings must construct an unauthenticated endpoint");
let endpoint = publicnode_endpoint(name, cluster, url, publicnode_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");
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");
assert_eq!(channel.cluster().as_str(), cluster);
let request = slot_request().expect("PublicNode Yellowstone slot request must be valid");
let mut session = channel.open_standard_subscribe(request).await.expect("PublicNode Yellowstone Subscribe must open without authentication metadata");
let mut session = channel.open_standard_subscribe(request).await.expect("PublicNode Yellowstone authenticated Subscribe must open");
let slot = tokio::time::timeout(std::time::Duration::from_secs(20), async {
loop {
match session.next_update().await.expect("PublicNode Yellowstone Subscribe update must decode") {
@@ -62,13 +92,13 @@ async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str) {
}
#[tokio::test(flavor = "current_thread")]
#[ignore = "opt-in live PublicNode Mainnet Yellowstone gRPC smoke; performs an unauthenticated external TLS/Subscribe request"]
async fn publicnode_mainnet_yellowstone_streams_slots_without_authentication_metadata() {
#[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;
}
#[tokio::test(flavor = "current_thread")]
#[ignore = "opt-in live PublicNode Testnet Yellowstone gRPC smoke; performs an unauthenticated external TLS/Subscribe request"]
async fn publicnode_testnet_yellowstone_streams_slots_without_authentication_metadata() {
#[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;
}