refactor(sequencer): add test for mempool and bring back standalone feature

This commit is contained in:
Daniil Polyakov
2026-08-12 22:50:50 +03:00
parent ea1b454672
commit f91d0da8e1
13 changed files with 235 additions and 42 deletions
@@ -0,0 +1,57 @@
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = u128;
fn main() {
let (
ProgramInput {
self_program_id,
caller_program_id,
pre_states,
instruction: balance,
},
instruction_words,
) = read_lee_inputs::<Instruction>();
if let Ok([account_pre]) = <[_; 1]>::try_from(pre_states.clone()) {
let account_post =
AccountPostState::new_claimed_if_default(account_pre.account, Claim::Authorized);
ProgramOutput::new(
self_program_id,
caller_program_id,
instruction_words,
pre_states,
vec![account_post],
)
.write();
return;
}
let Ok([sender_pre, receiver_pre]) = <[_; 2]>::try_from(pre_states) else {
return;
};
let mut sender_post = sender_pre.account.clone();
let mut receiver_post = receiver_pre.account.clone();
sender_post.balance = sender_post
.balance
.checked_sub(balance)
.expect("Not enough balance to transfer");
receiver_post.balance = receiver_post
.balance
.checked_add(balance)
.expect("Overflow when adding balance");
ProgramOutput::new(
self_program_id,
caller_program_id,
instruction_words,
vec![sender_pre, receiver_pre],
vec![
AccountPostState::new_claimed_if_default(sender_post, Claim::Authorized),
AccountPostState::new_claimed_if_default(receiver_post, Claim::Authorized),
],
)
.write();
}
+15
View File
@@ -11,6 +11,21 @@ mod guests {
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
}
#[must_use]
#[inline]
pub const fn simple_balance_transfer() -> Program {
use guests::{
SIMPLE_BALANCE_TRANSFER_ELF, SIMPLE_BALANCE_TRANSFER_ID, SIMPLE_BALANCE_TRANSFER_PATH,
};
let _unused = SIMPLE_BALANCE_TRANSFER_PATH;
Program::new_unchecked(
SIMPLE_BALANCE_TRANSFER_ID,
Cow::Borrowed(SIMPLE_BALANCE_TRANSFER_ELF),
)
}
#[must_use]
#[inline]
pub const fn chain_caller() -> Program {