Skip to main content

cu_profiler_core/backend/
program_test.rs

1//! `solana-program-test` backend — interface defined, implementation pending.
2//!
3//! The type and its construction surface exist so callers can target it today;
4//! [`ExecutionBackend::run`] returns [`crate::Error::BackendUnimplemented`]
5//! until the `program-test` integration is wired up. Keeping the Solana
6//! dependency out of the default build keeps the core pure Rust and fast to
7//! compile.
8
9use std::path::PathBuf;
10
11use crate::Result;
12use crate::backend::{ExecutionBackend, SimulationOutput};
13use crate::error::Error;
14use crate::metadata::BackendKind;
15use crate::scenario::Scenario;
16
17/// Backend that runs scenarios in-process via `solana-program-test`.
18#[derive(Debug, Clone)]
19pub struct ProgramTestBackend {
20    /// Path to the compiled `.so` program under test.
21    pub program_so: PathBuf,
22    /// The program ID to deploy under.
23    pub program_id: String,
24}
25
26impl ProgramTestBackend {
27    /// Construct a backend targeting a compiled program.
28    #[must_use]
29    pub fn new(program_so: impl Into<PathBuf>, program_id: impl Into<String>) -> Self {
30        Self {
31            program_so: program_so.into(),
32            program_id: program_id.into(),
33        }
34    }
35}
36
37impl ExecutionBackend for ProgramTestBackend {
38    fn kind(&self) -> BackendKind {
39        BackendKind::ProgramTest
40    }
41
42    fn run(&self, _scenario: &Scenario) -> Result<SimulationOutput> {
43        Err(Error::BackendUnimplemented(
44            "program-test (planned for a future release)".to_string(),
45        ))
46    }
47}