v0.2.5-pre.009
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
// file: crates/ksp-onchain-transport-lib/unit_tests/rpc_method.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
#[test]
|
||||
fn audited_registry_has_expected_current_and_historical_counts() {
|
||||
assert_eq!(super::current_http_rpc_methods().len(), 52);
|
||||
assert_eq!(super::historical_http_rpc_methods().len(), 14);
|
||||
assert_eq!(crate::current_http_rpc_methods().len(), 52);
|
||||
assert_eq!(crate::historical_http_rpc_methods().len(), 14);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn audited_registry_method_names_are_unique() {
|
||||
let mut names = std::collections::BTreeSet::<&str>::new();
|
||||
for descriptor in super::current_http_rpc_methods() {
|
||||
for descriptor in crate::current_http_rpc_methods() {
|
||||
assert!(names.insert(descriptor.method()), "duplicate current method {}", descriptor.method());
|
||||
}
|
||||
for descriptor in super::historical_http_rpc_methods() {
|
||||
for descriptor in crate::historical_http_rpc_methods() {
|
||||
assert!(names.insert(descriptor.method()), "duplicate historical method {}", descriptor.method());
|
||||
}
|
||||
assert_eq!(names.len(), 66);
|
||||
@@ -26,13 +26,13 @@ fn coverage_release_counts_match_recalibrated_matrix() {
|
||||
let mut transactions = 0_usize;
|
||||
let mut blocks_economics = 0_usize;
|
||||
let mut historical = 0_usize;
|
||||
for descriptor in super::current_http_rpc_methods() {
|
||||
for descriptor in crate::current_http_rpc_methods() {
|
||||
match descriptor.coverage_release() {
|
||||
super::HttpRpcCoverageRelease::V0_2_1 => foundation += 1,
|
||||
super::HttpRpcCoverageRelease::V0_2_2 => accounts_tokens_cluster += 1,
|
||||
super::HttpRpcCoverageRelease::V0_2_3 => transactions += 1,
|
||||
super::HttpRpcCoverageRelease::V0_2_4 => blocks_economics += 1,
|
||||
super::HttpRpcCoverageRelease::Historical => historical += 1,
|
||||
crate::HttpRpcCoverageRelease::V0_2_1 => foundation += 1,
|
||||
crate::HttpRpcCoverageRelease::V0_2_2 => accounts_tokens_cluster += 1,
|
||||
crate::HttpRpcCoverageRelease::V0_2_3 => transactions += 1,
|
||||
crate::HttpRpcCoverageRelease::V0_2_4 => blocks_economics += 1,
|
||||
crate::HttpRpcCoverageRelease::Historical => historical += 1,
|
||||
}
|
||||
}
|
||||
assert_eq!(historical, 0);
|
||||
@@ -45,8 +45,8 @@ fn coverage_release_counts_match_recalibrated_matrix() {
|
||||
#[test]
|
||||
fn foundation_canary_assignment_is_exact() {
|
||||
let mut names = std::vec::Vec::<&str>::new();
|
||||
for descriptor in super::current_http_rpc_methods() {
|
||||
if descriptor.coverage_release() == super::HttpRpcCoverageRelease::V0_2_1 {
|
||||
for descriptor in crate::current_http_rpc_methods() {
|
||||
if descriptor.coverage_release() == crate::HttpRpcCoverageRelease::V0_2_1 {
|
||||
names.push(descriptor.method());
|
||||
}
|
||||
}
|
||||
@@ -56,62 +56,62 @@ fn foundation_canary_assignment_is_exact() {
|
||||
|
||||
#[test]
|
||||
fn historical_methods_are_deprecated_removed_and_not_retryable() {
|
||||
for descriptor in super::historical_http_rpc_methods() {
|
||||
assert_eq!(descriptor.documentation_status(), super::RpcDocumentationStatus::Deprecated);
|
||||
assert_eq!(descriptor.runtime_status(), super::RpcRuntimeStatus::Removed);
|
||||
assert_eq!(descriptor.transport_retry_class(), super::TransportRetryClass::NotApplicable);
|
||||
assert_eq!(descriptor.coverage_release(), super::HttpRpcCoverageRelease::Historical);
|
||||
for descriptor in crate::historical_http_rpc_methods() {
|
||||
assert_eq!(descriptor.documentation_status(), crate::RpcDocumentationStatus::Deprecated);
|
||||
assert_eq!(descriptor.runtime_status(), crate::RpcRuntimeStatus::Removed);
|
||||
assert_eq!(descriptor.transport_retry_class(), crate::TransportRetryClass::NotApplicable);
|
||||
assert_eq!(descriptor.coverage_release(), crate::HttpRpcCoverageRelease::Historical);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_transaction_and_get_block_track_deprecated_legacy_request_form() {
|
||||
let get_transaction = super::find_http_rpc_method("getTransaction").expect("getTransaction descriptor must exist");
|
||||
let get_block = super::find_http_rpc_method("getBlock").expect("getBlock descriptor must exist");
|
||||
let get_transaction = crate::find_http_rpc_method("getTransaction").expect("getTransaction descriptor must exist");
|
||||
let get_block = crate::find_http_rpc_method("getBlock").expect("getBlock descriptor must exist");
|
||||
assert!(get_transaction.request_form_status().has_deprecated_legacy());
|
||||
assert!(get_block.request_form_status().has_deprecated_legacy());
|
||||
let get_balance = super::find_http_rpc_method("getBalance").expect("getBalance descriptor must exist");
|
||||
let get_balance = crate::find_http_rpc_method("getBalance").expect("getBalance descriptor must exist");
|
||||
assert!(!get_balance.request_form_status().has_deprecated_legacy());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn write_submission_methods_are_never_retry_after_ambiguous_dispatch() {
|
||||
for method in ["sendTransaction", "requestAirdrop"] {
|
||||
let descriptor = super::find_http_rpc_method(method).expect("write descriptor must exist");
|
||||
assert_eq!(descriptor.operation_kind(), super::RpcOperationKind::WriteSubmission);
|
||||
assert_eq!(descriptor.transport_retry_class(), super::TransportRetryClass::NeverAfterDispatch);
|
||||
let descriptor = crate::find_http_rpc_method(method).expect("write descriptor must exist");
|
||||
assert_eq!(descriptor.operation_kind(), crate::RpcOperationKind::WriteSubmission);
|
||||
assert_eq!(descriptor.transport_retry_class(), crate::TransportRetryClass::NeverAfterDispatch);
|
||||
}
|
||||
let simulation = super::find_http_rpc_method("simulateTransaction").expect("simulation descriptor must exist");
|
||||
assert_eq!(simulation.operation_kind(), super::RpcOperationKind::Simulation);
|
||||
assert_eq!(simulation.transport_retry_class(), super::TransportRetryClass::RetrySafe);
|
||||
let simulation = crate::find_http_rpc_method("simulateTransaction").expect("simulation descriptor must exist");
|
||||
assert_eq!(simulation.operation_kind(), crate::RpcOperationKind::Simulation);
|
||||
assert_eq!(simulation.transport_retry_class(), crate::TransportRetryClass::RetrySafe);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removed_method_support_check_returns_method_removed_error() {
|
||||
let descriptor = super::find_http_rpc_method("confirmTransaction").expect("historical descriptor must exist");
|
||||
let descriptor = crate::find_http_rpc_method("confirmTransaction").expect("historical descriptor must exist");
|
||||
let error = descriptor.ensure_runtime_supported().expect_err("removed method must not be callable");
|
||||
assert_eq!(error.code(), crate::ERROR_CODE_METHOD_REMOVED);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stable_supported_method_passes_runtime_support_check() {
|
||||
let descriptor = super::find_http_rpc_method("getHealth").expect("current descriptor must exist");
|
||||
let descriptor = crate::find_http_rpc_method("getHealth").expect("current descriptor must exist");
|
||||
assert!(descriptor.ensure_runtime_supported().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn supported_unstable_descriptor_executes_central_warning_path() {
|
||||
let descriptor = super::HttpRpcMethodDescriptor::new(
|
||||
let descriptor = crate::HttpRpcMethodDescriptor::new(
|
||||
"experimentalMethod",
|
||||
super::HttpRpcCategory::Cluster,
|
||||
crate::HttpRpcCategory::Cluster,
|
||||
"experimental_method",
|
||||
super::RpcDocumentationStatus::Unstable,
|
||||
super::RpcRuntimeStatus::Supported,
|
||||
super::RpcRequestFormStatus::Stable,
|
||||
super::RpcOperationKind::Read,
|
||||
super::TransportRetryClass::RetrySafe,
|
||||
crate::RpcDocumentationStatus::Unstable,
|
||||
crate::RpcRuntimeStatus::Supported,
|
||||
crate::RpcRequestFormStatus::Stable,
|
||||
crate::RpcOperationKind::Read,
|
||||
crate::TransportRetryClass::RetrySafe,
|
||||
std::option::Option::None,
|
||||
super::HttpRpcCoverageRelease::V0_2_1,
|
||||
crate::HttpRpcCoverageRelease::V0_2_1,
|
||||
);
|
||||
assert!(descriptor.requires_method_usage_warning());
|
||||
assert!(descriptor.ensure_runtime_supported().is_ok());
|
||||
@@ -119,5 +119,5 @@ fn supported_unstable_descriptor_executes_central_warning_path() {
|
||||
|
||||
#[test]
|
||||
fn lookup_rejects_unknown_method_without_affecting_raw_provider_extensions() {
|
||||
assert!(super::find_http_rpc_method("providerCustomMethod").is_none());
|
||||
assert!(crate::find_http_rpc_method("providerCustomMethod").is_none());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user