v0.2.6-pre.003-fix.002

This commit is contained in:
2026-08-20 21:33:46 +02:00
parent 0e72914237
commit 3fa4ab251a
13 changed files with 652 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-app-wallet-desk/tests/config_composition.rs
// version: 2
// version: 3
//! Config composition contracts introduced for Wallet Desk pre.003.
@@ -29,8 +29,8 @@ fn wallet_desk_composite_selects_logging_transport_and_wallet_by_file_id() {
assert!(composite.is_ok(), "committed Wallet 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, "wallet_desk_dev");
assert_wallet_desk_logging_trace_profile(&composite);
assert_component(&composite, "logging", ksp_config_lib::FILE_ID_STD_LOGGING, "supertrace");
assert_wallet_desk_supertrace_profile(&composite);
assert_component(&composite, "transport", ksp_config_lib::FILE_ID_STD_TRANSPORT, "devnet_public");
assert_component(&composite, "wallet", ksp_config_lib::FILE_ID_STD_WALLET, "default");
}
@@ -38,12 +38,12 @@ fn wallet_desk_composite_selects_logging_transport_and_wallet_by_file_id() {
}
}
fn assert_wallet_desk_logging_trace_profile(composite: &ksp_config_lib::ResolvedConfigComposite) {
fn assert_wallet_desk_supertrace_profile(composite: &ksp_config_lib::ResolvedConfigComposite) {
let component = composite.component("logging");
assert!(component.is_some(), "missing logging component");
if let std::option::Option::Some(component) = component {
let profile = component.resolved().profile();
assert_eq!(profile.get("default_filter").and_then(serde_json::Value::as_str), std::option::Option::Some("info"));
assert_eq!(profile.get("default_filter").and_then(serde_json::Value::as_str), std::option::Option::Some("trace"));
let console = profile.get("console").and_then(serde_json::Value::as_object);
let console_filter = console
.and_then(|value| {
@@ -55,26 +55,39 @@ fn assert_wallet_desk_logging_trace_profile(composite: &ksp_config_lib::Resolved
return value.get("level");
})
.and_then(serde_json::Value::as_str);
assert_eq!(console_level, std::option::Option::Some("trace"));
let targets = console_filter
assert_eq!(console_level, std::option::Option::Some("debug"));
let console_targets = console_filter
.and_then(|value| {
return value.get("targets");
})
.and_then(serde_json::Value::as_array);
assert!(targets.is_some(), "Wallet Desk console targets should exist");
if let std::option::Option::Some(targets) = targets {
assert!(targets.iter().any(|target| -> bool {
return target.as_str() == std::option::Option::Some("ksp-app-wallet-desk");
}));
assert_eq!(console_targets.and_then(|value| value.first()).and_then(serde_json::Value::as_str), std::option::Option::Some("*"));
let files = profile.get("files").and_then(serde_json::Value::as_array);
assert_eq!(files.map(std::vec::Vec::len), std::option::Option::Some(7));
if let std::option::Option::Some(files) = files {
for target in [
"ksp-app-config-desk",
"ksp-app-wallet-desk",
"ksp-config-lib",
"ksp-core-lib",
"ksp-logging-lib",
"ksp-onchain-transport-lib",
"ksp-wallet-lib",
] {
assert!(
files.iter().any(|file| -> bool {
let filter = file.get("filter");
let level = filter.and_then(|value| value.get("level")).and_then(serde_json::Value::as_str);
let targets = filter.and_then(|value| value.get("targets")).and_then(serde_json::Value::as_array);
return level == std::option::Option::Some("trace")
&& targets.is_some_and(|targets| targets.iter().any(|value| value.as_str() == std::option::Option::Some(target)));
}),
"supertrace should contain one trace file sink for target {target}"
);
}
}
let target_filters = profile.get("target_filters").and_then(serde_json::Value::as_array);
assert!(target_filters.is_some(), "Wallet Desk target filters should exist");
if let std::option::Option::Some(target_filters) = target_filters {
assert!(target_filters.iter().any(|filter| -> bool {
return filter.get("target_prefix").and_then(serde_json::Value::as_str) == std::option::Option::Some("ksp-app-wallet-desk")
&& filter.get("level").and_then(serde_json::Value::as_str) == std::option::Option::Some("trace");
}));
}
assert!(target_filters.is_some_and(std::vec::Vec::is_empty), "supertrace should rely on the global trace takeover instead of per-target overrides");
}
}