v0.2.9-pre.013-fix.004
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/tests/yellowstone_publicnode_smoke.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
//! Opt-in live PublicNode Mainnet/Testnet smokes for authenticated provider-neutral Yellowstone gRPC Subscribe.
|
||||
|
||||
@@ -14,7 +14,10 @@ static PUBLICNODE_X_TOKENS: std::sync::OnceLock<PublicNodeTokens> = std::sync::O
|
||||
|
||||
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");
|
||||
match std::io::stdin().read_line(&mut token) {
|
||||
std::result::Result::Ok(_) => {},
|
||||
std::result::Result::Err(error) => panic!("PublicNode {label} x-token must be readable from smoke stdin: {error}"),
|
||||
}
|
||||
let token = token.trim().to_owned();
|
||||
assert!(!token.is_empty(), "PublicNode {label} x-token provided on smoke stdin must not be empty");
|
||||
return token;
|
||||
@@ -58,7 +61,10 @@ fn publicnode_endpoint(
|
||||
url,
|
||||
session,
|
||||
);
|
||||
let metadata = ksp_onchain_transport_lib::YellowstoneGrpcMetadataEntry::secret("x-token", x_token)?;
|
||||
let metadata = match ksp_onchain_transport_lib::YellowstoneGrpcMetadataEntry::secret("x-token", x_token) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
return endpoint.with_metadata(vec![metadata]);
|
||||
}
|
||||
|
||||
@@ -68,35 +74,61 @@ fn slot_request() -> ksp_core_lib::Result<ksp_onchain_transport_lib::Yellowstone
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
request.insert_slot_filter(name, ksp_onchain_transport_lib::YellowstoneSubscribeSlotFilter::new())?;
|
||||
match request.insert_slot_filter(name, ksp_onchain_transport_lib::YellowstoneSubscribeSlotFilter::new()) {
|
||||
std::result::Result::Ok(()) => {},
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
}
|
||||
return std::result::Result::Ok(request);
|
||||
}
|
||||
|
||||
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 = match publicnode_endpoint(name, cluster, url, x_token) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("programmatic PublicNode Yellowstone settings must accept secret x-token metadata: {error:?}"),
|
||||
};
|
||||
let endpoint_debug = format!("{endpoint:?}");
|
||||
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");
|
||||
let channel = match ksp_onchain_transport_lib::YellowstoneGrpcChannel::connect(&endpoint).await {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("PublicNode Yellowstone TLS connection must succeed: {error:?}"),
|
||||
};
|
||||
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 authenticated Subscribe must open");
|
||||
let slot = tokio::time::timeout(std::time::Duration::from_secs(20), async {
|
||||
let request = match slot_request() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("PublicNode Yellowstone slot request must be valid: {error:?}"),
|
||||
};
|
||||
let mut session = match channel.open_standard_subscribe(request).await {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("PublicNode Yellowstone authenticated Subscribe must open: {error:?}"),
|
||||
};
|
||||
let slot_result = tokio::time::timeout(std::time::Duration::from_secs(20), async {
|
||||
loop {
|
||||
match session.next_update().await.expect("PublicNode Yellowstone Subscribe update must decode") {
|
||||
std::option::Option::Some(ksp_onchain_transport_lib::YellowstoneSubscribeUpdate::Slot(update)) => break update.slot(),
|
||||
let next_update = match session.next_update().await {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("PublicNode Yellowstone Subscribe update must decode: {error:?}"),
|
||||
};
|
||||
match next_update {
|
||||
std::option::Option::Some(ksp_onchain_transport_lib::YellowstoneSubscribeUpdate::Slot(update)) => return update.slot(),
|
||||
std::option::Option::Some(_) => {},
|
||||
std::option::Option::None => panic!("PublicNode Yellowstone Subscribe ended before a slot update"),
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("PublicNode Yellowstone Subscribe must publish a slot update before the smoke deadline");
|
||||
.await;
|
||||
let slot = match slot_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("PublicNode Yellowstone Subscribe must publish a slot update before the smoke deadline: {error}"),
|
||||
};
|
||||
assert!(slot > 0);
|
||||
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");
|
||||
let close_timeout_result = tokio::time::timeout(std::time::Duration::from_secs(7), session.close()).await;
|
||||
let close_result = match close_timeout_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
panic!("KSP Yellowstone Subscribe close must remain bounded beyond the configured five-second provider half-close deadline: {error}")
|
||||
},
|
||||
};
|
||||
match close_result {
|
||||
std::result::Result::Ok(()) => {},
|
||||
std::result::Result::Err(error) => {
|
||||
@@ -107,6 +139,7 @@ async fn assert_publicnode_slot_stream(name: &str, cluster: &str, url: &str, x_t
|
||||
);
|
||||
},
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
|
||||
Reference in New Issue
Block a user