v0.3.14-pre.006
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-worker-raw-transaction-ingest-lib/unit_tests/runtime_resources.rs
|
||||
// version: 25
|
||||
// version: 26
|
||||
|
||||
fn grpc_endpoint(cluster: &str) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings> {
|
||||
return grpc_endpoint_with_identity(cluster, "yellowstone-fixture", "fixture-provider");
|
||||
@@ -2968,6 +2968,178 @@ fn v0_3_13_pre_006_http_block_polling_discovery_never_moves_before_run_frontier_
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_14_pre_006_http_scan_capabilities_prefer_closed_range_and_require_safe_fallback() {
|
||||
let exact = super::RawTransactionIngestHttpScanCapabilities { get_block: true, get_blocks: true, get_blocks_with_limit: true, get_slot: true };
|
||||
assert!(exact.can_scan());
|
||||
let exact_strategy = match exact.strategy() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(exact_strategy, super::RawTransactionIngestHttpDiscoveryStrategy::ClosedRange);
|
||||
let fallback = super::RawTransactionIngestHttpScanCapabilities { get_block: true, get_blocks: false, get_blocks_with_limit: true, get_slot: true };
|
||||
assert!(fallback.can_scan());
|
||||
let fallback_strategy = match fallback.strategy() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(fallback_strategy, super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary);
|
||||
for incomplete in [
|
||||
super::RawTransactionIngestHttpScanCapabilities { get_block: false, get_blocks: true, get_blocks_with_limit: true, get_slot: true },
|
||||
super::RawTransactionIngestHttpScanCapabilities { get_block: true, get_blocks: false, get_blocks_with_limit: true, get_slot: false },
|
||||
super::RawTransactionIngestHttpScanCapabilities { get_block: true, get_blocks: false, get_blocks_with_limit: false, get_slot: true },
|
||||
] {
|
||||
assert!(!incomplete.can_scan());
|
||||
assert!(incomplete.strategy().is_err());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_14_pre_006_http_scan_capability_detection_is_role_local_and_io_free() {
|
||||
let cases = [
|
||||
(&["get_block", "get_blocks"][..], std::option::Option::Some(super::RawTransactionIngestHttpDiscoveryStrategy::ClosedRange)),
|
||||
(
|
||||
&["get_block", "get_blocks_with_limit", "get_slot"][..],
|
||||
std::option::Option::Some(super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary),
|
||||
),
|
||||
(&["get_transaction"][..], std::option::Option::None),
|
||||
];
|
||||
for (request_kinds, expected_strategy) in cases {
|
||||
let pool = match http_polling_pool_with_identity("devnet", "scan", "scan-fixture", "fixture-provider", request_kinds) {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
let capabilities = match super::http_role_scan_capabilities(&pool, &ksp_onchain_transport_lib::HttpRoleName::new("scan"), "devnet") {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
match expected_strategy {
|
||||
std::option::Option::Some(expected) => {
|
||||
assert!(capabilities.can_scan());
|
||||
let actual = match capabilities.strategy() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(actual, expected);
|
||||
},
|
||||
std::option::Option::None => {
|
||||
assert!(!capabilities.can_scan());
|
||||
assert!(capabilities.strategy().is_err());
|
||||
},
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_14_pre_006_http_discovery_window_is_inclusive_bounded_and_overflow_safe() {
|
||||
let single = match super::http_discovery_window_slot_count(100, 100) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(single, 1);
|
||||
let maximum = match super::http_discovery_window_slot_count(100, 611) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(maximum, crate::MAX_RAW_TRANSACTION_INGEST_CONTINUITY_DISCOVERY_WINDOW_SLOTS);
|
||||
assert!(super::http_discovery_window_slot_count(100, 612).is_err());
|
||||
assert!(super::http_discovery_window_slot_count(101, 100).is_err());
|
||||
assert!(super::http_discovery_window_slot_count(0, u64::MAX).is_err());
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_14_pre_006_closed_range_discovery_proves_skipped_slots_only_inside_exact_window() {
|
||||
let complete = match super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::ClosedRange,
|
||||
std::option::Option::None,
|
||||
&[100, 102, 105],
|
||||
) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(complete.produced_slots, std::vec![100, 102, 105]);
|
||||
assert_eq!(complete.proven_end_slot, std::option::Option::Some(105));
|
||||
let all_skipped = match super::validate_http_block_discovery_result(
|
||||
200,
|
||||
203,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::ClosedRange,
|
||||
std::option::Option::None,
|
||||
&[],
|
||||
) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert!(all_skipped.produced_slots.is_empty());
|
||||
assert_eq!(all_skipped.proven_end_slot, std::option::Option::Some(203));
|
||||
assert!(
|
||||
super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::ClosedRange,
|
||||
std::option::Option::None,
|
||||
&[100, 106],
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_14_pre_006_with_limit_discovery_never_uses_tip_alone_as_tail_coverage_proof() {
|
||||
let crossed = match super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary,
|
||||
std::option::Option::Some(110),
|
||||
&[100, 103, 107],
|
||||
) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(crossed.produced_slots, std::vec![100, 103]);
|
||||
assert_eq!(crossed.proven_end_slot, std::option::Option::Some(105));
|
||||
let partial = match super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary,
|
||||
std::option::Option::Some(110),
|
||||
&[100, 103],
|
||||
) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(partial.produced_slots, std::vec![100, 103]);
|
||||
assert_eq!(partial.proven_end_slot, std::option::Option::Some(103));
|
||||
let tip_only = match super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary,
|
||||
std::option::Option::Some(110),
|
||||
&[],
|
||||
) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert!(tip_only.produced_slots.is_empty());
|
||||
assert_eq!(tip_only.proven_end_slot, std::option::Option::None);
|
||||
assert!(
|
||||
super::validate_http_block_discovery_result(
|
||||
100,
|
||||
105,
|
||||
super::RawTransactionIngestHttpDiscoveryStrategy::WithLimitBoundary,
|
||||
std::option::Option::None,
|
||||
&[100, 103, 107],
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_13_pre_006_http_block_polling_qualifies_legacy_v0_v1_and_rejects_ambiguous_or_future_versions() {
|
||||
let cases = [
|
||||
|
||||
Reference in New Issue
Block a user