v0.2.9-pre.013-fix.003
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-config-lib/unit_tests/transport.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
#[test]
|
||||
fn fixture_transport_profile_maps_complete_runtime_contract() {
|
||||
@@ -134,22 +134,35 @@ fn committed_transport_document_maps_default_and_explicit_profiles() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn committed_v3_publicnode_profiles_map_provider_neutral_yellowstone_grpc_with_secret_x_token() {
|
||||
fn committed_v3_publicnode_profiles_map_provider_neutral_yellowstone_grpc_with_network_scoped_secret_x_tokens() {
|
||||
let engine = committed_engine();
|
||||
let engine = match engine {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let canary = "PUBLICNODE-GRPC-X-TOKEN-CANARY";
|
||||
let mut process = std::collections::BTreeMap::<String, String>::new();
|
||||
process.insert("KSP_SECRET_PUBLICNODE_GRPC_X_TOKEN".to_owned(), canary.to_owned());
|
||||
let environment = crate::ConfigEnvironment::from_maps(process, std::collections::BTreeMap::new());
|
||||
for (profile_id, endpoint_name, cluster, url) in [
|
||||
("publicnode_mainnet", "publicnode_solana_mainnet_yellowstone", "mainnet-beta", "https://solana-yellowstone-grpc.publicnode.com:443"),
|
||||
("publicnode_testnet", "publicnode_solana_testnet_yellowstone", "testnet", "https://solana-testnet-yellowstone-grpc.publicnode.com:443"),
|
||||
for (profile_id, endpoint_name, cluster, url, environment_name, canary) in [
|
||||
(
|
||||
"publicnode_mainnet",
|
||||
"publicnode_solana_mainnet_yellowstone",
|
||||
"mainnet-beta",
|
||||
"https://solana-yellowstone-grpc.publicnode.com:443",
|
||||
"KSP_SECRET_PUBLICNODE_MAINNET_GRPC_X_TOKEN",
|
||||
"PUBLICNODE-MAINNET-GRPC-X-TOKEN-CANARY",
|
||||
),
|
||||
(
|
||||
"publicnode_testnet",
|
||||
"publicnode_solana_testnet_yellowstone",
|
||||
"testnet",
|
||||
"https://solana-testnet-yellowstone-grpc.publicnode.com:443",
|
||||
"KSP_SECRET_PUBLICNODE_TESTNET_GRPC_X_TOKEN",
|
||||
"PUBLICNODE-TESTNET-GRPC-X-TOKEN-CANARY",
|
||||
),
|
||||
] {
|
||||
let mut process = std::collections::BTreeMap::<String, String>::new();
|
||||
process.insert(environment_name.to_owned(), canary.to_owned());
|
||||
let environment = crate::ConfigEnvironment::from_maps(process, std::collections::BTreeMap::new());
|
||||
let resolved = engine.load_resolved_transport_config(std::option::Option::Some(profile_id), &environment);
|
||||
assert!(resolved.is_ok(), "committed PublicNode V3 profile {profile_id} should map: {resolved:?}");
|
||||
assert!(resolved.is_ok(), "committed PublicNode V3 profile {profile_id} should map from its network-scoped token: {resolved:?}");
|
||||
let resolved = match resolved {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => continue,
|
||||
@@ -170,7 +183,7 @@ fn committed_v3_publicnode_profiles_map_provider_neutral_yellowstone_grpc_with_s
|
||||
assert_eq!(endpoint.metadata()[0].key(), "x-token");
|
||||
assert!(endpoint.metadata()[0].is_secret());
|
||||
let endpoint_debug = format!("{endpoint:?}");
|
||||
assert!(!endpoint_debug.contains(canary), "PublicNode x-token must stay redacted from endpoint Debug");
|
||||
assert!(!endpoint_debug.contains(canary), "PublicNode {cluster} x-token must stay redacted from endpoint Debug");
|
||||
assert_eq!(endpoint.session().connect_timeout(), std::time::Duration::from_millis(10_000));
|
||||
assert_eq!(endpoint.session().unary_timeout(), std::time::Duration::from_millis(10_000));
|
||||
assert_eq!(endpoint.session().close_timeout(), std::time::Duration::from_millis(5_000));
|
||||
@@ -178,6 +191,7 @@ fn committed_v3_publicnode_profiles_map_provider_neutral_yellowstone_grpc_with_s
|
||||
assert!(grpc.validate().is_ok(), "Config-produced Yellowstone gRPC settings should satisfy Transport validation");
|
||||
let debug = format!("{grpc:?}");
|
||||
assert!(!debug.contains("publicnode.com"), "Transport settings Debug must not expose gRPC endpoint URLs");
|
||||
assert!(!debug.contains(canary), "Transport settings Debug must not expose the network-scoped PublicNode x-token");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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