v0.3.5-pre.002-fix.001
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// file: crates/ksp-interface-lib/tests/release_completeness.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Release-completeness canaries for the public `ksp-interface-lib` surface.
|
||||
|
||||
fn crate_root_source() -> std::result::Result<std::string::String, std::io::Error> {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/lib.rs");
|
||||
@@ -12,12 +14,10 @@ fn v0_3_5_pre_002_foundation_keeps_one_error_code_and_adds_one_passive_acquisiti
|
||||
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);
|
||||
@@ -25,9 +25,11 @@ fn v0_3_5_pre_002_foundation_keeps_one_error_code_and_adds_one_passive_acquisiti
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_002_exact_crate_root_export_inventory_includes_slot_lifecycle() -> std::result::Result<(), std::io::Error> {
|
||||
let source = crate_root_source()?;
|
||||
let public_use_count = source.lines().filter(|line| line.starts_with("pub use ")).count();
|
||||
|
||||
let source = match crate_root_source() {
|
||||
Ok(source) => source,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let public_use_count = source.lines().filter(|line| return line.starts_with("pub use ")).count();
|
||||
assert_eq!(public_use_count, 8);
|
||||
assert!(source.contains("pub use self::error::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED;"));
|
||||
assert!(source.contains("pub use self::program_account_meta::MAX_PROGRAM_INSTRUCTION_ACCOUNTS;"));
|
||||
@@ -37,20 +39,23 @@ fn v0_3_5_pre_002_exact_crate_root_export_inventory_includes_slot_lifecycle() ->
|
||||
assert!(source.contains("pub use self::slot_lifecycle::SlotLifecycleEvent;"));
|
||||
assert!(source.contains("pub use self::slot_lifecycle::SlotLifecycleStage;"));
|
||||
assert!(source.contains("pub use ksp_core_lib::Pubkey;"));
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_5_pre_002_production_module_inventory_adds_only_slot_lifecycle() -> std::result::Result<(), std::io::Error> {
|
||||
let source = crate_root_source()?;
|
||||
let modules = source.lines().filter_map(|line| line.strip_prefix("mod ").and_then(|module| module.strip_suffix(';'))).collect::<std::vec::Vec<_>>();
|
||||
|
||||
let source = match crate_root_source() {
|
||||
Ok(source) => source,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let modules = source
|
||||
.lines()
|
||||
.filter_map(|line| return line.strip_prefix("mod ").and_then(|module| return module.strip_suffix(';')))
|
||||
.collect::<std::vec::Vec<_>>();
|
||||
assert_eq!(modules, std::vec!["error", "program_account_meta", "program_instruction", "slot_lifecycle"]);
|
||||
assert!(!source.contains("serde"));
|
||||
assert!(!source.contains("tracing"));
|
||||
assert!(!source.contains("ksp_onchain_transport"));
|
||||
assert!(!source.contains("ksp_store"));
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// file: crates/ksp-interface-lib/tests/slot_lifecycle_public_api.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Public API canaries for the shared slot lifecycle event contract.
|
||||
|
||||
#[test]
|
||||
fn public_v0_3_5_pre_002_slot_lifecycle_contract_is_available_from_crate_root() {
|
||||
let event = ksp_interface_lib::SlotLifecycleEvent::new(u64::MAX, ksp_interface_lib::SlotLifecycleStage::Rooted);
|
||||
|
||||
assert_eq!(event.slot(), u64::MAX);
|
||||
assert_eq!(event.stage(), ksp_interface_lib::SlotLifecycleStage::Rooted);
|
||||
}
|
||||
@@ -23,7 +24,6 @@ fn public_v0_3_5_pre_002_slot_lifecycle_stage_remains_downstream_evolvable() {
|
||||
_ => "future",
|
||||
};
|
||||
}
|
||||
|
||||
assert_eq!(stage_label(ksp_interface_lib::SlotLifecycleStage::Processed), "processed");
|
||||
assert_eq!(stage_label(ksp_interface_lib::SlotLifecycleStage::Rooted), "rooted");
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
// file: crates/ksp-interface-lib/unit_tests/slot_lifecycle.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
#[test]
|
||||
fn slot_lifecycle_stages_are_distinct_copy_and_complete_for_the_admitted_family() {
|
||||
fn assert_copy<T: Copy>() {}
|
||||
|
||||
assert_copy::<crate::SlotLifecycleStage>();
|
||||
|
||||
let stages = [
|
||||
crate::SlotLifecycleStage::Processed,
|
||||
crate::SlotLifecycleStage::FirstShredReceived,
|
||||
@@ -16,7 +14,6 @@ fn slot_lifecycle_stages_are_distinct_copy_and_complete_for_the_admitted_family(
|
||||
crate::SlotLifecycleStage::OptimisticallyConfirmed,
|
||||
crate::SlotLifecycleStage::Rooted,
|
||||
];
|
||||
|
||||
for (index, stage) in stages.iter().enumerate() {
|
||||
for other in stages.iter().skip(index + 1) {
|
||||
assert_ne!(stage, other);
|
||||
@@ -27,11 +24,8 @@ fn slot_lifecycle_stages_are_distinct_copy_and_complete_for_the_admitted_family(
|
||||
#[test]
|
||||
fn slot_lifecycle_event_preserves_full_u64_slot_and_stage() {
|
||||
fn assert_copy<T: Copy>() {}
|
||||
|
||||
assert_copy::<crate::SlotLifecycleEvent>();
|
||||
|
||||
let event = crate::SlotLifecycleEvent::new(u64::MAX, crate::SlotLifecycleStage::Rooted);
|
||||
|
||||
assert_eq!(event.slot(), u64::MAX);
|
||||
assert_eq!(event.stage(), crate::SlotLifecycleStage::Rooted);
|
||||
let copied = event;
|
||||
@@ -42,7 +36,6 @@ fn slot_lifecycle_event_preserves_full_u64_slot_and_stage() {
|
||||
fn slot_lifecycle_debug_is_bounded_and_contains_only_shared_fields() {
|
||||
let event = crate::SlotLifecycleEvent::new(42, crate::SlotLifecycleStage::OptimisticallyConfirmed);
|
||||
let debug = std::format!("{event:?}");
|
||||
|
||||
assert!(debug.len() <= 128);
|
||||
assert!(debug.contains("slot: 42"));
|
||||
assert!(debug.contains("OptimisticallyConfirmed"));
|
||||
|
||||
Reference in New Issue
Block a user