v0.1.0-pre.016

This commit is contained in:
2026-07-24 18:19:27 +02:00
parent a818c4a60e
commit 252fe51e34
17 changed files with 1830 additions and 67 deletions

View File

@@ -1,5 +1,5 @@
// file: kb-lib/tests/external_executor_api.rs
// version: 3
// version: 4
//! Downstream-style compilation contract for externally implemented executors.
@@ -117,4 +117,49 @@ fn external_executor_uses_only_the_public_kb_lib_contract() {
solana_core_plan.operation_code,
kb_lib::EX_SOLANA_CORE_COMPUTE_BUDGET_SET_UNIT_LIMIT_OPERATION
);
let memo_executor = kb_lib::ExSplMemoExecutor;
let memo_program_id = kb_lib::MdProgramId(kb_program_ids::SPL_MEMO_V4_PROGRAM_ID.to_string());
let memo_capability = kb_lib::ExApiTypedInstructionExecutor::capability(
&memo_executor,
&memo_program_id,
kb_lib::EX_SPL_MEMO_ADD_MEMO_OPERATION,
);
assert!(memo_capability.is_supported());
let memo_intent = kb_lib::ExSplMemoExecutionIntent {
intent_id: "external-spl-memo".to_string(),
fee_payer: kb_lib::MdPubkey(kb_program_ids::SYSTEM_PROGRAM_ID.to_string()),
policy: kb_lib::ExApiExecutionPolicy {
cost_limit: kb_lib::ExApiExecutionCostLimit {
max_spend_lamports: std::option::Option::Some(0),
max_fee_lamports: std::option::Option::Some(10_000),
max_compute_unit_price_micro_lamports: std::option::Option::None,
},
authorized_signers: vec![kb_lib::MdPubkey(
kb_program_ids::SYSTEM_PROGRAM_ID.to_string(),
)],
post_execution_validation: kb_lib::ExApiPostExecutionValidationPolicy {
canonical_insert_required: true,
core_extraction_required: true,
decode_replay_required: true,
materialization_required: true,
},
..kb_lib::ExApiExecutionPolicy::default()
},
operation: kb_lib::ExSplMemoOperation::AddMemo {
generation: kb_lib::ExSplMemoGeneration::V4,
message: "external memo".to_string(),
signers: std::vec::Vec::new(),
},
};
let memo_plan =
kb_lib::ExApiTypedInstructionExecutor::build_prepared_plan(&memo_executor, &memo_intent)
.unwrap_or_else(|error| panic!("SPL Memo executor failed: {error}"));
assert_eq!(memo_plan.instructions.len(), 1);
assert_eq!(
kb_lib::ExSafetyChecker
.evaluate_prepared_plan(&memo_plan)
.unwrap_or_else(|error| panic!("safety evaluation failed: {error}"))
.decision,
kb_lib::ExSafetyDecision::Allow
);
}