// file: crates/ksp-interface-lib/tests/release_completeness.rs // version: 1 //! Release-level completeness canaries for the `0.2.13` Interface foundation. #[test] fn pre_005_exact_crate_root_export_inventory_is_stable() { let crate_root = include_str!("../src/lib.rs"); let mut actual = std::vec::Vec::new(); for line in crate_root.lines() { let trimmed = line.trim(); if trimmed.starts_with("pub use ") { actual.push(trimmed); } } actual.sort_unstable(); let mut expected = std::vec![ "pub use self::error::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED;", "pub use self::program_account_meta::MAX_PROGRAM_INSTRUCTION_ACCOUNTS;", "pub use self::program_account_meta::ProgramAccountMeta;", "pub use self::program_instruction::MAX_PROGRAM_INSTRUCTION_DATA_LEN;", "pub use self::program_instruction::ProgramInstruction;", "pub use ksp_core_lib::Pubkey;", ]; expected.sort_unstable(); assert_eq!(actual, expected); assert!(!crate_root.contains("pub mod ")); return; } #[test] fn pre_005_production_module_inventory_contains_no_second_wire_domain() -> std::io::Result<()> { let source_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); let entries = match std::fs::read_dir(source_root) { std::result::Result::Ok(value) => value, std::result::Result::Err(error) => return std::result::Result::Err(error), }; let mut names = std::vec::Vec::new(); for entry in entries { let entry = match entry { std::result::Result::Ok(value) => value, std::result::Result::Err(error) => return std::result::Result::Err(error), }; let file_type = match entry.file_type() { std::result::Result::Ok(value) => value, std::result::Result::Err(error) => return std::result::Result::Err(error), }; if !file_type.is_file() { continue; } let name = match entry.file_name().into_string() { std::result::Result::Ok(value) => value, std::result::Result::Err(_) => continue, }; if name.ends_with(".rs") { names.push(name); } } names.sort_unstable(); assert_eq!(names, std::vec!["error.rs", "lib.rs", "program_account_meta.rs", "program_instruction.rs"]); return std::result::Result::Ok(()); } #[test] fn pre_005_foundation_has_one_error_code_and_two_bounded_passive_types() { 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 = ksp_interface_lib::ProgramInstruction::try_new(program_id, std::vec![account], std::vec![0xB3_u8]); assert!(instruction.is_ok()); return; }