v0.3.12-pre.007

This commit is contained in:
2026-09-09 16:21:23 +02:00
parent 07b9b20eb5
commit ba69a5ad20
13 changed files with 1037 additions and 105 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-worker-raw-transaction-ingest-lib/unit_tests/runtime_resources.rs
// version: 6
// version: 7
fn grpc_endpoint(cluster: &str) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings> {
return grpc_endpoint_with_identity(cluster, "yellowstone-fixture", "fixture-provider");
@@ -62,9 +62,7 @@ fn http_pool(cluster: &str, role_name: &str, request_kind: &str) -> std::option:
};
}
fn transaction_request(
commitment: std::option::Option<ksp_onchain_transport_lib::SolanaCommitment>,
) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneSubscribeRequest> {
fn transaction_request(commitment: std::option::Option<ksp_onchain_transport_lib::SolanaCommitment>) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneSubscribeRequest> {
let name = match ksp_onchain_transport_lib::YellowstoneSubscribeFilterName::new("tx-fixture") {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return std::option::Option::None,
@@ -136,7 +134,10 @@ impl super::RawTransactionIngestYellowstoneBlockView for BlockViewFixture {
return self.transactions.len();
}
fn transaction_identity(&self, position: usize) -> ksp_core_lib::Result<(ksp_onchain_transport_lib::YellowstoneTransactionSignature, u64)> {
fn transaction_identity(
&self,
position: usize,
) -> ksp_core_lib::Result<(ksp_onchain_transport_lib::YellowstoneTransactionSignature, u64)> {
return match self.transactions.get(position) {
std::option::Option::Some(value) => std::result::Result::Ok(*value),
std::option::Option::None => std::result::Result::Err(crate::runtime_error("fixture.block_transaction_missing")),
@@ -218,7 +219,12 @@ const PRE_004_OTHER_TRANSACTION_BASE64: &str = "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
const PRE_004_ZERO_SIGNATURE_TEXT: &str = "1111111111111111111111111111111111111111111111111111111111111111";
const PRE_004_ZERO_TRANSACTION_BASE64: &str = "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
fn http_pool_for_url(url: &str, cluster: &str, endpoint_name: &str, provider: &str) -> std::option::Option<ksp_onchain_transport_lib::HttpTransportPool> {
fn http_pool_for_url(
url: &str,
cluster: &str,
endpoint_name: &str,
provider: &str,
) -> std::option::Option<ksp_onchain_transport_lib::HttpTransportPool> {
let url = match ksp_onchain_transport_lib::HttpEndpointUrl::parse(url) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return std::option::Option::None,
@@ -343,8 +349,11 @@ fn serve_http_once(body: std::string::String) -> std::io::Result<(std::string::S
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
let response =
std::format!("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}", body.len(), body,);
let response = std::format!(
"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",
body.len(),
body,
);
if let std::result::Result::Err(error) = std::io::Write::write_all(&mut stream, response.as_bytes()) {
return std::result::Result::Err(error);
}
@@ -432,7 +441,10 @@ async fn pre_002_source_accepts_matching_confirmed_transaction_and_get_transacti
#[tokio::test(flavor = "current_thread")]
async fn pre_002_source_rejects_processed_and_implicit_commitment() {
for commitment in [std::option::Option::Some(ksp_onchain_transport_lib::SolanaCommitment::Processed), std::option::Option::None] {
for commitment in [
std::option::Option::Some(ksp_onchain_transport_lib::SolanaCommitment::Processed),
std::option::Option::None,
] {
let endpoint = match grpc_endpoint("devnet") {
std::option::Option::Some(value) => value,
std::option::Option::None => return,
@@ -625,8 +637,8 @@ async fn pre_003_transaction_signal_fixture_preserves_exact_source_neutral_ident
assert_eq!(
signal.matched_filter_fingerprint,
[
0x20, 0x83, 0x1d, 0xc8, 0x37, 0x8b, 0x60, 0x70, 0xf9, 0x1d, 0x9d, 0xe6, 0xd3, 0xa1, 0xd2, 0xb3, 0xd7, 0x72, 0x98, 0xe3, 0xad, 0xa7, 0x6c, 0x01,
0xfa, 0xa3, 0x08, 0x26, 0xff, 0xab, 0xcd, 0x84,
0x20, 0x83, 0x1d, 0xc8, 0x37, 0x8b, 0x60, 0x70, 0xf9, 0x1d, 0x9d, 0xe6, 0xd3, 0xa1, 0xd2, 0xb3, 0xd7, 0x72, 0x98,
0xe3, 0xad, 0xa7, 0x6c, 0x01, 0xfa, 0xa3, 0x08, 0x26, 0xff, 0xab, 0xcd, 0x84,
]
);
assert_eq!(signal.created_at, std::option::Option::Some(super::RawTransactionIngestSourceTimestamp { nanos: 456_000_000, seconds: 1_760_000_123 }));
@@ -871,7 +883,10 @@ fn pre_005_slot_status_projection_is_exact_and_source_neutral() {
(ksp_onchain_transport_lib::YellowstoneSlotStatus::Processed, super::RawTransactionIngestContinuityStatus::Processed),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::Confirmed, super::RawTransactionIngestContinuityStatus::Confirmed),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::Finalized, super::RawTransactionIngestContinuityStatus::Finalized),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::FirstShredReceived, super::RawTransactionIngestContinuityStatus::FirstShredReceived),
(
ksp_onchain_transport_lib::YellowstoneSlotStatus::FirstShredReceived,
super::RawTransactionIngestContinuityStatus::FirstShredReceived,
),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::Completed, super::RawTransactionIngestContinuityStatus::Completed),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::CreatedBank, super::RawTransactionIngestContinuityStatus::CreatedBank),
(ksp_onchain_transport_lib::YellowstoneSlotStatus::Dead, super::RawTransactionIngestContinuityStatus::Dead),
@@ -973,7 +988,10 @@ async fn pre_004_observed_get_transaction_closes_signal_to_common_raw_ingress_wi
assert_eq!(acquisition.transaction().reference().network().as_str(), "devnet");
assert_eq!(acquisition.transaction().reference().signature().as_bytes(), &[0_u8; 64]);
assert_eq!(acquisition.transaction().slot(), 42);
assert_eq!(acquisition.transaction().block_time().map(|value| return value.unix_millis()), std::option::Option::Some(1_760_000_120_000),);
assert_eq!(
acquisition.transaction().block_time().map(|value| return value.unix_millis()),
std::option::Option::Some(1_760_000_120_000),
);
assert_eq!(acquisition.observation().provenance().provider().as_str(), "ys.fixture-provider:http.fixture-http-provider");
return;
}
@@ -1211,8 +1229,14 @@ async fn pre_004_status_provenance_and_future_source_timestamp_are_bounded_and_r
std::option::Option::Some(value) => value,
std::option::Option::None => return,
};
let mut signal = match pre_004_signal(&source, super::RawTransactionIngestSourceFamily::TransactionStatus, 42, 7, &["filter-b", "filter-a", "filter-a"], 0)
{
let mut signal = match pre_004_signal(
&source,
super::RawTransactionIngestSourceFamily::TransactionStatus,
42,
7,
&["filter-b", "filter-a", "filter-a"],
0,
) {
std::option::Option::Some(value) => value,
std::option::Option::None => return,
};
@@ -1321,3 +1345,50 @@ fn pre_006_coalescence_key_separates_network_signature_and_commitment() {
assert_eq!(first_key.network.as_str(), "devnet");
return;
}
#[test]
fn pre_007_processing_frontier_never_advances_through_pending_work() {
let mut frontier = super::RawTransactionIngestProcessingFrontier::new();
assert!(frontier.observe_settled(100).is_ok());
let projection = frontier.projection();
assert_eq!(projection.hydration_pending(), 0);
assert_eq!(projection.processing_frontier_slot(), std::option::Option::Some(100));
assert_eq!(projection.oldest_pending_slot(), std::option::Option::None);
assert!(frontier.observe_pending(102).is_ok());
assert!(frontier.observe_settled(105).is_ok());
assert!(frontier.observe_pending(104).is_ok());
let projection = frontier.projection();
assert_eq!(projection.hydration_pending(), 2);
assert_eq!(projection.processing_frontier_slot(), std::option::Option::Some(100));
assert_eq!(projection.oldest_pending_slot(), std::option::Option::Some(102));
assert!(frontier.settle_pending(102).is_ok());
let projection = frontier.projection();
assert_eq!(projection.hydration_pending(), 1);
assert_eq!(projection.processing_frontier_slot(), std::option::Option::Some(102));
assert_eq!(projection.oldest_pending_slot(), std::option::Option::Some(104));
assert!(frontier.settle_pending(104).is_ok());
let projection = frontier.projection();
assert_eq!(projection.hydration_pending(), 0);
assert_eq!(projection.processing_frontier_slot(), std::option::Option::Some(105));
assert_eq!(projection.oldest_pending_slot(), std::option::Option::None);
return;
}
#[test]
fn pre_007_processing_frontier_compacts_settled_slots_to_pending_intervals() {
let mut frontier = super::RawTransactionIngestProcessingFrontier::new();
assert!(frontier.observe_pending(10).is_ok());
assert!(frontier.observe_pending(20).is_ok());
for slot in 0_u64..=1000_u64 {
if slot == 10 || slot == 20 {
continue;
}
assert!(frontier.observe_settled(slot).is_ok());
}
assert!(frontier.slot_state_count() <= 5);
let projection = frontier.projection();
assert_eq!(projection.hydration_pending(), 2);
assert_eq!(projection.oldest_pending_slot(), std::option::Option::Some(10));
assert_eq!(projection.processing_frontier_slot(), std::option::Option::Some(9));
return;
}