v0.3.5-pre.004
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-interface-lib/tests/dependency_boundary.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Dependency and passive-surface canaries for the Interface foundation.
|
||||
|
||||
@@ -91,6 +91,8 @@ fn pre_005_all_production_sources_preserve_the_dependency_firewall() {
|
||||
include_str!("../src/lib.rs"),
|
||||
include_str!("../src/program_account_meta.rs"),
|
||||
include_str!("../src/program_instruction.rs"),
|
||||
include_str!("../src/slot_lifecycle.rs"),
|
||||
include_str!("../src/transaction_execution.rs"),
|
||||
];
|
||||
for source in production_sources {
|
||||
for forbidden in [
|
||||
@@ -129,3 +131,31 @@ fn pre_005_instruction_source_has_no_narrowing_cast_or_hidden_codec_entry_point(
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_004_acquisition_sources_remain_provider_neutral_and_runtime_free() {
|
||||
let acquisition_sources = [include_str!("../src/slot_lifecycle.rs"), include_str!("../src/transaction_execution.rs")];
|
||||
for source in acquisition_sources {
|
||||
for forbidden in [
|
||||
"borsh::",
|
||||
"bincode::",
|
||||
"ksp_config_lib::",
|
||||
"ksp_logging_lib::",
|
||||
"ksp_onchain_transport_lib::",
|
||||
"ksp_store_api::",
|
||||
"ksp_store_lib::",
|
||||
"reqwest::",
|
||||
"serde::",
|
||||
"serde_json::",
|
||||
"solana_instruction::",
|
||||
"tauri::",
|
||||
"tokio::",
|
||||
"tonic::",
|
||||
concat!("tracing", "::"),
|
||||
"wincode::",
|
||||
] {
|
||||
assert!(!source.contains(forbidden), "forbidden acquisition dependency path detected: {forbidden}");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
// file: crates/ksp-interface-lib/tests/external_consumer.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Downstream-style consumer canary for the public Interface facade.
|
||||
//! Downstream-style consumer canaries for the public Interface facade.
|
||||
|
||||
fn consume_instruction(instruction: ksp_interface_lib::ProgramInstruction) -> (ksp_interface_lib::Pubkey, usize, usize) {
|
||||
return (*instruction.program_id(), instruction.accounts().len(), instruction.data().len());
|
||||
}
|
||||
|
||||
fn consume_slot_lifecycle(event: ksp_interface_lib::SlotLifecycleEvent) -> (u64, ksp_interface_lib::SlotLifecycleStage) {
|
||||
return (event.slot(), event.stage());
|
||||
}
|
||||
|
||||
fn consume_transaction_execution(
|
||||
event: ksp_interface_lib::TransactionExecutionEvent,
|
||||
) -> (u64, ksp_interface_lib::TransactionSignature, ksp_interface_lib::TransactionExecutionOutcome) {
|
||||
return (event.slot(), event.signature(), event.outcome());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_005_external_consumer_uses_only_the_crate_root_facade() {
|
||||
let program_id = ksp_interface_lib::Pubkey::new_from_array([0xA1_u8; 32]);
|
||||
@@ -25,3 +35,13 @@ fn pre_005_external_consumer_uses_only_the_crate_root_facade() {
|
||||
assert_eq!(ksp_interface_lib::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED.domain(), "interface");
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_004_external_consumer_uses_only_crate_root_for_both_acquisition_families() {
|
||||
let lifecycle = ksp_interface_lib::SlotLifecycleEvent::new(u64::MAX, ksp_interface_lib::SlotLifecycleStage::OptimisticallyConfirmed);
|
||||
assert_eq!(consume_slot_lifecycle(lifecycle), (u64::MAX, ksp_interface_lib::SlotLifecycleStage::OptimisticallyConfirmed));
|
||||
let signature = ksp_interface_lib::TransactionSignature::new([0xA3_u8; 64]);
|
||||
let execution = ksp_interface_lib::TransactionExecutionEvent::new(u64::MAX - 1, signature, ksp_interface_lib::TransactionExecutionOutcome::Failed);
|
||||
assert_eq!(consume_transaction_execution(execution), (u64::MAX - 1, signature, ksp_interface_lib::TransactionExecutionOutcome::Failed));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-interface-lib/tests/release_completeness.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
//! Release-completeness canaries for the public `ksp-interface-lib` surface.
|
||||
|
||||
@@ -9,15 +9,11 @@ fn crate_root_source() -> std::result::Result<std::string::String, std::io::Erro
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_003_foundation_keeps_one_error_code_and_two_passive_acquisition_families() {
|
||||
fn v0_3_5_pre_004_foundation_keeps_exactly_two_passive_acquisition_families() {
|
||||
assert_eq!(ksp_interface_lib::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED.domain(), "interface");
|
||||
assert_eq!(ksp_interface_lib::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED.code(), "program_instruction_limit_exceeded");
|
||||
assert_eq!(ksp_interface_lib::MAX_PROGRAM_INSTRUCTION_ACCOUNTS, 255);
|
||||
assert_eq!(ksp_interface_lib::MAX_PROGRAM_INSTRUCTION_DATA_LEN, 10_240);
|
||||
let program_id = ksp_interface_lib::Pubkey::new_from_array([0xB1_u8; 32]);
|
||||
let account = ksp_interface_lib::ProgramAccountMeta::readonly(ksp_interface_lib::Pubkey::new_from_array([0xB2_u8; 32]), false);
|
||||
let instruction_result = ksp_interface_lib::ProgramInstruction::try_new(program_id, std::vec![account], std::vec![0xB3_u8]);
|
||||
assert!(instruction_result.is_ok());
|
||||
let lifecycle = ksp_interface_lib::SlotLifecycleEvent::new(u64::MAX, ksp_interface_lib::SlotLifecycleStage::Rooted);
|
||||
assert_eq!(lifecycle.slot(), u64::MAX);
|
||||
assert_eq!(lifecycle.stage(), ksp_interface_lib::SlotLifecycleStage::Rooted);
|
||||
@@ -26,10 +22,11 @@ fn v0_3_5_pre_003_foundation_keeps_one_error_code_and_two_passive_acquisition_fa
|
||||
assert_eq!(execution.slot(), u64::MAX);
|
||||
assert_eq!(execution.signature(), signature);
|
||||
assert_eq!(execution.outcome(), ksp_interface_lib::TransactionExecutionOutcome::Succeeded);
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_003_exact_crate_root_export_inventory_includes_both_acquisition_families() -> std::result::Result<(), std::io::Error> {
|
||||
fn v0_3_5_pre_004_exact_crate_root_export_inventory_is_stable() -> std::result::Result<(), std::io::Error> {
|
||||
let source = match crate_root_source() {
|
||||
Ok(source) => source,
|
||||
Err(error) => return Err(error),
|
||||
@@ -51,7 +48,7 @@ fn v0_3_5_pre_003_exact_crate_root_export_inventory_includes_both_acquisition_fa
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_003_production_module_inventory_adds_only_transaction_execution() -> std::result::Result<(), std::io::Error> {
|
||||
fn v0_3_5_pre_004_production_module_inventory_is_exact() -> std::result::Result<(), std::io::Error> {
|
||||
let source = match crate_root_source() {
|
||||
Ok(source) => source,
|
||||
Err(error) => return Err(error),
|
||||
@@ -67,3 +64,12 @@ fn v0_3_5_pre_003_production_module_inventory_adds_only_transaction_execution()
|
||||
assert!(!source.contains("ksp_store"));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_004_evolutive_acquisition_enums_remain_non_exhaustive() {
|
||||
let lifecycle_source = include_str!("../src/slot_lifecycle.rs");
|
||||
let execution_source = include_str!("../src/transaction_execution.rs");
|
||||
assert!(lifecycle_source.contains("#[non_exhaustive]\npub enum SlotLifecycleStage"));
|
||||
assert!(execution_source.contains("#[non_exhaustive]\npub enum TransactionExecutionOutcome"));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user