v0.2.13-pre.002
This commit is contained in:
79
crates/ksp-interface-lib/tests/dependency_boundary.rs
Normal file
79
crates/ksp-interface-lib/tests/dependency_boundary.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
// file: crates/ksp-interface-lib/tests/dependency_boundary.rs
|
||||
// version: 1
|
||||
|
||||
//! Dependency and passive-surface canaries for the Interface scaffold.
|
||||
|
||||
#[test]
|
||||
fn pre_002_manifest_has_exact_core_only_runtime_dependency() {
|
||||
let manifest = include_str!("../Cargo.toml");
|
||||
let dependencies_tail = manifest.split("[dependencies]").nth(1);
|
||||
assert!(dependencies_tail.is_some(), "Interface dependencies section must exist");
|
||||
let dependencies_tail = match dependencies_tail {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
let dependencies = match dependencies_tail.split("[lints]").next() {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
assert_eq!(manifest_dependency_names(dependencies), std::vec!["ksp-core-lib"]);
|
||||
for forbidden in [
|
||||
"ksp-config-lib",
|
||||
"ksp-logging-lib",
|
||||
"ksp-offchain-transport-lib",
|
||||
"ksp-onchain-transport-lib",
|
||||
"ksp-program-api",
|
||||
"ksp-program-lib",
|
||||
"ksp-store-api",
|
||||
"ksp-store-lib",
|
||||
"ksp-wallet-lib",
|
||||
"borsh",
|
||||
"bincode",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"solana-instruction",
|
||||
"tauri",
|
||||
"tokio",
|
||||
"tonic",
|
||||
"tracing",
|
||||
"wincode",
|
||||
] {
|
||||
assert!(!dependencies.contains(forbidden), "forbidden Interface dependency detected: {forbidden}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_002_scaffold_remains_passive_without_runtime_logging_surface() {
|
||||
let crate_root = include_str!("../src/lib.rs");
|
||||
assert!(crate_root.contains("pub use ksp_core_lib::Pubkey;"));
|
||||
assert!(!crate_root.contains("ProgramAccountMeta"));
|
||||
assert!(!crate_root.contains("ProgramInstruction"));
|
||||
assert!(!crate_root.contains("TRACING_TARGET"));
|
||||
assert!(!crate_root.contains("ksp_logging_lib"));
|
||||
assert!(!std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/constants.rs").exists());
|
||||
return;
|
||||
}
|
||||
|
||||
fn manifest_dependency_names(section: &str) -> std::vec::Vec<&str> {
|
||||
let mut names = std::vec::Vec::new();
|
||||
for line in section.lines() {
|
||||
let content = match line.split('#').next() {
|
||||
std::option::Option::Some(value) => value.trim(),
|
||||
std::option::Option::None => continue,
|
||||
};
|
||||
if content.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let name = match content.split('=').next() {
|
||||
std::option::Option::Some(value) => value.trim().trim_end_matches(".workspace"),
|
||||
std::option::Option::None => continue,
|
||||
};
|
||||
if !name.is_empty() {
|
||||
names.push(name);
|
||||
}
|
||||
}
|
||||
names.sort_unstable();
|
||||
return names;
|
||||
}
|
||||
15
crates/ksp-interface-lib/tests/public_api.rs
Normal file
15
crates/ksp-interface-lib/tests/public_api.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
// file: crates/ksp-interface-lib/tests/public_api.rs
|
||||
// version: 1
|
||||
|
||||
//! Integration canaries for the public `ksp-interface-lib` scaffold.
|
||||
|
||||
fn consume_pubkey(pubkey: ksp_interface_lib::Pubkey) -> [u8; 32] {
|
||||
return pubkey.to_bytes();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_pre_002_pubkey_contract_is_available_from_crate_root() {
|
||||
let pubkey = ksp_interface_lib::Pubkey::default();
|
||||
assert_eq!(consume_pubkey(pubkey), [0_u8; 32]);
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user