v0.3.7-pre.003
This commit is contained in:
88
crates/ksp-app-backfill-desk/tests/config_composition.rs
Normal file
88
crates/ksp-app-backfill-desk/tests/config_composition.rs
Normal file
@@ -0,0 +1,88 @@
|
||||
// file: crates/ksp-app-backfill-desk/tests/config_composition.rs
|
||||
// version: 1
|
||||
|
||||
//! Config composite contracts for Backfill Desk pre.003.
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
fn workspace_engine() -> ksp_core_lib::Result<ksp_config_lib::ConfigDocumentEngine> {
|
||||
let workspace = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
let bootstrap = ksp_config_lib::ConfigBootstrapOptions::from_paths(workspace.join("config"), workspace.join("config/schemas"));
|
||||
let bootstrap = match bootstrap {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let registry = ksp_config_lib::ConfigFileRegistry::defaults();
|
||||
return match registry {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(ksp_config_lib::ConfigDocumentEngine::new(bootstrap, value)),
|
||||
std::result::Result::Err(error) => std::result::Result::Err(error),
|
||||
};
|
||||
}
|
||||
|
||||
fn assert_component(composite: &ksp_config_lib::ResolvedConfigComposite, component_id: &str, file_id: &str, profile_id: &str) {
|
||||
let component = composite.component(component_id);
|
||||
assert!(component.is_some(), "missing component {component_id}");
|
||||
if let std::option::Option::Some(component) = component {
|
||||
assert_eq!(component.resolved().file_id().as_str(), file_id);
|
||||
assert_eq!(component.resolved().profile_id(), profile_id);
|
||||
assert_eq!(component.resolved().selection_source(), ksp_config_lib::ConfigProfileSelectionSource::Composite);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_003_default_composite_selects_trace_devnet_logging_transport_and_store() {
|
||||
let engine = workspace_engine();
|
||||
assert!(engine.is_ok(), "workspace Config engine should be constructible: {engine:?}");
|
||||
let engine = match engine {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let file_id = ksp_config_lib::ConfigFileId::new(ksp_config_lib::FILE_ID_COMPOSITE_KSP_APP_BACKFILL_DESK);
|
||||
assert!(file_id.is_ok(), "Backfill Desk composite file_id should be valid: {file_id:?}");
|
||||
let file_id = match file_id {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let composite = engine.load_resolved_composite(&file_id, std::option::Option::None);
|
||||
assert!(composite.is_ok(), "committed Backfill Desk composite should resolve: {composite:?}");
|
||||
if let std::result::Result::Ok(composite) = composite {
|
||||
assert_eq!(composite.profile_id(), "devnet");
|
||||
assert_component(&composite, "logging", ksp_config_lib::FILE_ID_STD_LOGGING, "supertrace");
|
||||
assert_component(&composite, "transport", ksp_config_lib::FILE_ID_STD_TRANSPORT, "devnet_public");
|
||||
assert_component(&composite, "store", ksp_config_lib::FILE_ID_STD_STORE, "devnet");
|
||||
let logging = composite.component("logging");
|
||||
assert!(logging.is_some(), "Backfill Desk composite should expose Logging");
|
||||
if let std::option::Option::Some(logging) = logging {
|
||||
assert_eq!(logging.resolved().profile().get("default_filter").and_then(serde_json::Value::as_str), std::option::Option::Some("trace"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_003_named_profiles_keep_transport_and_store_network_selection_paired() {
|
||||
let engine = workspace_engine();
|
||||
assert!(engine.is_ok(), "workspace Config engine should be constructible: {engine:?}");
|
||||
let engine = match engine {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let file_id = ksp_config_lib::ConfigFileId::new(ksp_config_lib::FILE_ID_COMPOSITE_KSP_APP_BACKFILL_DESK);
|
||||
let file_id = match file_id {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
for (profile_id, logging_profile, transport_profile, store_profile) in
|
||||
[("mainnet", "console_info", "mainnet_public", "mainnet"), ("testnet", "console_info", "publicnode_testnet", "testnet")]
|
||||
{
|
||||
let composite = engine.load_resolved_composite(&file_id, std::option::Option::Some(profile_id));
|
||||
assert!(composite.is_ok(), "Backfill Desk composite profile {profile_id} should resolve: {composite:?}");
|
||||
if let std::result::Result::Ok(composite) = composite {
|
||||
assert_eq!(composite.profile_id(), profile_id);
|
||||
assert_component(&composite, "logging", ksp_config_lib::FILE_ID_STD_LOGGING, logging_profile);
|
||||
assert_component(&composite, "transport", ksp_config_lib::FILE_ID_STD_TRANSPORT, transport_profile);
|
||||
assert_component(&composite, "store", ksp_config_lib::FILE_ID_STD_STORE, store_profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-backfill-desk/tests/desktop_contract.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Structural desktop contract checks for the Backfill Desk scaffold.
|
||||
|
||||
@@ -24,6 +24,16 @@ fn read_text(path: &std::path::Path) -> String {
|
||||
};
|
||||
}
|
||||
|
||||
fn read_json(path: &std::path::Path) -> serde_json::Value {
|
||||
let source = read_text(path);
|
||||
let parsed = serde_json::from_str(source.as_str());
|
||||
assert!(parsed.is_ok(), "unable to parse {}", path.display());
|
||||
return match parsed {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => serde_json::Value::Null,
|
||||
};
|
||||
}
|
||||
|
||||
fn read_bytes(path: &std::path::Path) -> std::vec::Vec<u8> {
|
||||
let source = std::fs::read(path);
|
||||
assert!(source.is_ok(), "unable to read {}", path.display());
|
||||
@@ -119,3 +129,52 @@ fn pre_002_shell_and_splash_use_shared_frontend_tooling() {
|
||||
assert!(splash.contains("Splash opacity animation started"));
|
||||
assert!(splash.contains("Backfill Desk splash frontend loaded"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_003_composite_packaging_follows_atomic_config_registry_contract() {
|
||||
let root = app_root();
|
||||
let config = read_json(root.join("tauri.conf.json").as_path());
|
||||
let resources = config.get("bundle").and_then(|value| value.get("resources")).and_then(serde_json::Value::as_object);
|
||||
assert!(resources.is_some());
|
||||
let resources = match resources {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
assert_eq!(resources.len(), 14);
|
||||
for required in [
|
||||
"../../config/composite.ksp-app-backfill-desk.json",
|
||||
"../../config/composite.ksp-app-solprices-desk.json",
|
||||
"../../config/composite.ksp-app-wallet-desk.json",
|
||||
"../../config/std.logging.json",
|
||||
"../../config/std.offchain_transport.json",
|
||||
"../../config/std.store.json",
|
||||
"../../config/std.transport.json",
|
||||
"../../config/std.wallet.json",
|
||||
"../../config/schemas/composite.schema.json",
|
||||
"../../config/schemas/std.logging.schema.json",
|
||||
"../../config/schemas/std.offchain_transport.schema.json",
|
||||
"../../config/schemas/std.store.schema.json",
|
||||
"../../config/schemas/std.transport.schema.json",
|
||||
"../../config/schemas/std.wallet.schema.json",
|
||||
] {
|
||||
assert!(resources.contains_key(required), "missing packaged Config resource {required}");
|
||||
}
|
||||
let tauri = read_text(root.join("src/tauri.rs").as_path());
|
||||
assert!(tauri.contains("prepare_packaged_runtime"));
|
||||
assert!(tauri.contains("resource_dir"));
|
||||
assert!(tauri.contains("set_current_dir"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_003_bootstrap_uses_composite_logging_without_opening_transport_or_store() {
|
||||
let root = app_root();
|
||||
let bootstrap = read_text(root.join("src/bootstrap.rs").as_path());
|
||||
assert!(bootstrap.contains("FILE_ID_COMPOSITE_KSP_APP_BACKFILL_DESK"));
|
||||
assert!(bootstrap.contains("COMPOSITE_COMPONENT_ID_LOGGING"));
|
||||
assert!(bootstrap.contains("COMPOSITE_COMPONENT_ID_TRANSPORT"));
|
||||
assert!(bootstrap.contains("COMPOSITE_COMPONENT_ID_STORE"));
|
||||
assert!(bootstrap.contains("LogFilterLevel::Trace"));
|
||||
for forbidden in ["HttpTransportPool", "Store::open", "BackfillJobRuntime", "BackfillRequest"] {
|
||||
assert!(!bootstrap.contains(forbidden), "pre.003 opens later runtime surface {forbidden}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-backfill-desk/tests/desktop_security.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Security and dependency-boundary checks for the Backfill Desk scaffold.
|
||||
|
||||
@@ -113,3 +113,17 @@ fn pre_002_frontend_instrumentation_avoids_business_or_secret_payloads() {
|
||||
assert!(!main.contains(forbidden));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_003_keeps_config_only_composition_boundary() {
|
||||
let root = app_root();
|
||||
let manifest = read_text(root.join("Cargo.toml").as_path());
|
||||
assert!(manifest.contains("ksp-config-lib.workspace = true"));
|
||||
for forbidden in ["ksp-job-backfill-lib", "ksp-onchain-transport-lib", "ksp-store-lib", "ksp-store-api", "ksp-store-postgres-lib"] {
|
||||
assert!(!manifest.contains(forbidden), "pre.003 opens a later-layer dependency: {forbidden}");
|
||||
}
|
||||
let bootstrap = read_text(root.join("src/bootstrap.rs").as_path());
|
||||
assert!(bootstrap.contains("LogFilterLevel::Trace"));
|
||||
assert!(!bootstrap.contains("HttpTransportPool"));
|
||||
assert!(!bootstrap.contains("Store::open"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user