v0.2.14-pre.003
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-program-api/tests/dependency_boundary.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Dependency and declarative-surface canaries for the Program API scaffold.
|
||||
//! Dependency and declarative-surface canaries for the Program API foundation.
|
||||
|
||||
#[test]
|
||||
fn pre_002_manifest_has_exact_core_and_interface_runtime_dependencies() {
|
||||
@@ -46,23 +46,27 @@ fn pre_002_manifest_has_exact_core_and_interface_runtime_dependencies() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_002_crate_root_is_facade_only_without_decoder_runtime_surface() {
|
||||
fn pre_003_crate_root_adds_only_recognition_and_decode_outcome() {
|
||||
let crate_root = include_str!("../src/lib.rs");
|
||||
for required in ["Error", "ErrorCode", "ErrorContext", "Pubkey", "Result", "ProgramAccountMeta", "ProgramInstruction"] {
|
||||
for required in [
|
||||
"ProgramInstructionDecodeOutcome",
|
||||
"ProgramInstructionRecognition",
|
||||
"Error",
|
||||
"ErrorCode",
|
||||
"ErrorContext",
|
||||
"Pubkey",
|
||||
"Result",
|
||||
"ProgramAccountMeta",
|
||||
"ProgramInstruction",
|
||||
] {
|
||||
assert!(crate_root.contains(required), "required Program API facade export missing: {required}");
|
||||
}
|
||||
for forbidden in [
|
||||
"pub mod ",
|
||||
"ProgramInstructionRecognition",
|
||||
"ProgramInstructionDecodeOutcome",
|
||||
"ProgramInstructionDecoder",
|
||||
"ProgramExecutionPreparer",
|
||||
"TRACING_TARGET",
|
||||
"ksp_logging_lib",
|
||||
"serde",
|
||||
"Any",
|
||||
] {
|
||||
assert!(!crate_root.contains(forbidden), "forbidden pre.002 Program API surface detected: {forbidden}");
|
||||
for forbidden in ["pub mod ", "ProgramInstructionDecoder", "ProgramExecutionPreparer", "TRACING_TARGET", "ksp_logging_lib", "serde", "Any"] {
|
||||
assert!(!crate_root.contains(forbidden), "forbidden pre.003 Program API surface detected: {forbidden}");
|
||||
}
|
||||
let outcome_source = include_str!("../src/program_instruction_decode.rs");
|
||||
for forbidden in ["Ignored", "Failed", "serde", "Any"] {
|
||||
assert!(!outcome_source.contains(forbidden), "forbidden recognition/outcome concept detected: {forbidden}");
|
||||
}
|
||||
assert!(!std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/constants.rs").exists());
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-program-api/tests/public_api.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Integration canaries for the public `ksp-program-api` scaffold.
|
||||
//! Integration canaries for the public `ksp-program-api` foundation.
|
||||
|
||||
fn consume_result(value: ksp_program_api::Result<ksp_program_api::Pubkey>) -> ksp_program_api::Result<ksp_program_api::Pubkey> {
|
||||
return value;
|
||||
@@ -31,3 +31,19 @@ fn public_pre_002_scaffold_does_not_require_private_modules() {
|
||||
assert!(!source.contains("pub mod "));
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_pre_003_recognition_and_decode_outcome_are_available_from_crate_root() {
|
||||
let recognition = ksp_program_api::ProgramInstructionRecognition::ProgramMatch;
|
||||
assert_eq!(std::format!("{recognition:?}"), "ProgramMatch");
|
||||
let decoded = ksp_program_api::ProgramInstructionDecodeOutcome::Decoded(31_u16);
|
||||
assert_eq!(std::format!("{decoded:?}"), "Decoded");
|
||||
let decoded_value = match decoded {
|
||||
ksp_program_api::ProgramInstructionDecodeOutcome::Decoded(value) => value,
|
||||
_ => 0_u16,
|
||||
};
|
||||
assert_eq!(decoded_value, 31_u16);
|
||||
let unsupported = ksp_program_api::ProgramInstructionDecodeOutcome::<u16>::Unsupported;
|
||||
assert_eq!(std::format!("{unsupported:?}"), "Unsupported");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user