v0.1.1-pre.004

This commit is contained in:
2026-08-14 15:54:52 +02:00
parent 4a86a76ca8
commit b01fb3fa53
5 changed files with 143 additions and 14 deletions

View File

@@ -1,10 +1,15 @@
// file: crates/ksp-core-lib/src/lib.rs
// version: 5
// version: 6
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
//! Core contracts shared by the foundational KSP layers.
//!
//! `ksp-core-lib` owns the common KSP error contract, the Solana [`Pubkey`]
//! primitive used by the project, and the KSP-owned registry of fundamental
//! Solana Program IDs. Higher-level domains extend these contracts without
//! introducing reverse dependencies from Core.
mod error;
mod program_ids;

View File

@@ -1,12 +1,14 @@
// file: crates/ksp-core-lib/tests/public_api.rs
// version: 3
// version: 4
//! Integration tests for the public `ksp-core-lib` contracts.
ksp_core_lib::declare_program_id!(TEST_PRGID_SYSTEM, TEST_PRGIDPK_SYSTEM, "11111111111111111111111111111111");
const TEST_ERROR_CODE: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("consumer", "failed");
fn public_result() -> ksp_core_lib::Result<()> {
let error = ksp_core_lib::Error::new(ksp_core_lib::ErrorCode::new("consumer", "failed"), "consumer failure").with_context("operation", "public_api");
let error = ksp_core_lib::Error::new(TEST_ERROR_CODE, "consumer failure").with_context("operation", "public_api");
return std::result::Result::Err(error);
}
@@ -18,7 +20,7 @@ fn error_contract_is_consumable_from_crate_root() {
std::result::Result::Ok(()) => return,
std::result::Result::Err(error) => error,
};
assert_eq!(error.code(), ksp_core_lib::ErrorCode::new("consumer", "failed"));
assert_eq!(error.code(), TEST_ERROR_CODE);
assert_eq!(error.message(), "consumer failure");
assert_eq!(error.context(), &[ksp_core_lib::ErrorContext::new("operation", "public_api")]);
assert_eq!(std::string::ToString::to_string(&error), "consumer.failed: consumer failure");