use super::MockProver;
use sp1_core_executor::SP1CoreOpts;
use sp1_core_machine::riscv::RiscvAir;
use sp1_hypercube::Machine;
use sp1_primitives::SP1Field;
use sp1_prover::worker::SP1LightNode;
use crate::blocking::block_on;
pub struct MockProverBuilder {
core_opts: Option<SP1CoreOpts>,
machine: Machine<SP1Field, RiscvAir<SP1Field>>,
}
impl Default for MockProverBuilder {
fn default() -> Self {
Self::new()
}
}
impl MockProverBuilder {
#[must_use]
pub fn new() -> Self {
Self::new_with_machine(RiscvAir::machine())
}
#[must_use]
pub const fn new_with_machine(machine: Machine<SP1Field, RiscvAir<SP1Field>>) -> Self {
Self { core_opts: None, machine }
}
#[must_use]
pub fn core_opts(mut self, opts: SP1CoreOpts) -> Self {
self.core_opts = Some(opts);
self
}
#[must_use]
pub fn with_opts(self, opts: SP1CoreOpts) -> Self {
self.core_opts(opts)
}
#[must_use]
pub fn build(self) -> MockProver {
tracing::info!("initializing mock prover");
let node = match self.core_opts {
Some(opts) => block_on(SP1LightNode::with_opts_and_machine(self.machine, opts)),
None => block_on(SP1LightNode::new_with_machine(self.machine)),
};
MockProver::from_node(node)
}
}