v0.3.8-pre.005

This commit is contained in:
2026-09-03 13:09:25 +02:00
parent 3bb73e81e4
commit bf73481180
17 changed files with 891 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-store-postgres-lib/tests/hardening_completeness.rs
// version: 19
// version: 20
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -250,6 +250,9 @@ fn pre_009_live_raw_account_proof_is_opt_in_isolated_secret_safe_and_cross_famil
"prove_additional_observations",
"ReferenceNotFound",
"prove_pagination_and_cursors",
"prove_account_inspection",
"inspect_raw_account_states",
"RawAccountStateInspectionQuery",
"KSPT",
"prove_cross_family_coexistence",
"persist_raw_transaction_acquisition",
@@ -299,11 +302,12 @@ fn pre_009_live_raw_transaction_proof_is_opt_in_isolated_and_secret_safe() {
}
#[test]
fn v0_3_8_pre_004_raw_capability_implementation_inventory_is_exactly_eleven() {
fn v0_3_8_pre_005_raw_capability_implementation_inventory_is_exactly_twelve() {
let runtime = include_str!("../src/runtime.rs");
let capability_impls = [
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawTransactionInspectionRead for PostgresBackend",
@@ -317,7 +321,7 @@ fn v0_3_8_pre_004_raw_capability_implementation_inventory_is_exactly_eleven() {
for implementation in capability_impls {
assert_eq!(runtime.matches(implementation).count(), 1, "unexpected PostgreSQL capability implementation inventory: {implementation}");
}
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 11);
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 12);
let migration = include_str!("../src/migration.rs");
assert!(migration.contains("raw_account_state"));
assert!(migration.contains("crate::V002_RESOURCES"));
@@ -466,3 +470,38 @@ fn pre_010_v002_schema_inventory_is_exact_family_local_and_query_justified() {
}
return;
}
#[test]
fn v0_3_8_pre_005_raw_account_keyset_sql_remains_offset_free_while_inspection_is_random_access() {
let source = include_str!("../src/raw_account.rs");
for name in [
"const LIST_ACCOUNT_STATES_ASC_SQL",
"const LIST_ACCOUNT_STATES_DESC_SQL",
"const LIST_ACCOUNT_STATES_BY_PUBKEY_ASC_SQL",
"const LIST_ACCOUNT_STATES_BY_PUBKEY_DESC_SQL",
] {
let statement = source.lines().find(|line| return line.starts_with(name));
let statement = match statement {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing canonical account keyset SQL: {name}"),
};
assert!(!statement.contains(" OFFSET "));
}
for name in ["const INSPECT_ACCOUNT_STATES_ASC_SQL", "const INSPECT_ACCOUNT_STATES_DESC_SQL"] {
let statement = source.lines().find(|line| return line.starts_with(name));
let statement = match statement {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing account inspection SQL: {name}"),
};
for required in ["COUNT(*)", "LEFT JOIN LATERAL", "OCTET_LENGTH(account_row.data)", "LIMIT $4 OFFSET $5"] {
assert!(statement.contains(required), "missing account inspection SQL contract: {required}");
}
assert!(!statement.contains("account_row.data,"));
assert!(!statement.contains("SELECT account_row.data"));
assert!(statement.contains("ORDER BY account_row.slot"));
assert!(statement.contains("account_row.pubkey"));
assert!(statement.contains("account_row.state_hash"));
}
assert_eq!(source.matches(" OFFSET ").count(), 2);
return;
}