Add program id spoof tests (#13866)
This commit is contained in:
3407
programs/bpf/rust/spoof1_system/Cargo.lock
generated
Normal file
3407
programs/bpf/rust/spoof1_system/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
programs/bpf/rust/spoof1_system/Cargo.toml
Normal file
18
programs/bpf/rust/spoof1_system/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "solana-bpf-rust-spoof1-system"
|
||||
version = "1.5.0"
|
||||
description = "Solana BPF test program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-program = { path = "../../../../sdk/program", version = "1.5.0" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
2
programs/bpf/rust/spoof1_system/Xargo.toml
Normal file
2
programs/bpf/rust/spoof1_system/Xargo.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
19
programs/bpf/rust/spoof1_system/src/lib.rs
Normal file
19
programs/bpf/rust/spoof1_system/src/lib.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
entrypoint!(process_instruction);
|
||||
fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
_instruction_data: &[u8],
|
||||
) -> ProgramResult {
|
||||
let from = &accounts[0];
|
||||
let to = &accounts[1];
|
||||
|
||||
let to_balance = to.lamports();
|
||||
**to.lamports.borrow_mut() = to_balance + from.lamports();
|
||||
**from.lamports.borrow_mut() = 0u64;
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user