mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-25 23:23:11 +00:00
test: verify malicious self_program_id is rejected in public execution
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
use nssa_core::program::{
|
||||
AccountPostState, DEFAULT_PROGRAM_ID, ProgramInput, ProgramOutput, read_nssa_inputs,
|
||||
};
|
||||
|
||||
type Instruction = ();
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
ProgramInput {
|
||||
self_program_id: _, // ignore the correct ID
|
||||
caller_program_id: _,
|
||||
pre_states,
|
||||
instruction: (),
|
||||
},
|
||||
instruction_words,
|
||||
) = read_nssa_inputs::<Instruction>();
|
||||
|
||||
let post_states = pre_states
|
||||
.iter()
|
||||
.map(|a| AccountPostState::new(a.account.clone()))
|
||||
.collect();
|
||||
|
||||
// Deliberately output wrong self_program_id
|
||||
ProgramOutput::new(
|
||||
DEFAULT_PROGRAM_ID, // WRONG: should be self_program_id
|
||||
instruction_words,
|
||||
pre_states,
|
||||
post_states,
|
||||
)
|
||||
.write();
|
||||
}
|
||||
Reference in New Issue
Block a user