forked from anza-xyz/agave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement concurrent test for the SVM (anza-xyz#2610)
* Implement concurrent test for the SVM * Remove debug print and optimize lock
- Loading branch information
Showing
6 changed files
with
394 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
svm/tests/example-programs/transfer-from-account/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "transfer-from-account" | ||
version = "2.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
solana-program = { path = "../../../../sdk/program", version = "=2.1.0" } | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[workspace] |
28 changes: 28 additions & 0 deletions
28
svm/tests/example-programs/transfer-from-account/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use solana_program::{ | ||
account_info::{AccountInfo, next_account_info}, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey, | ||
program::invoke, system_instruction, | ||
}; | ||
|
||
entrypoint!(process_instruction); | ||
|
||
|
||
fn process_instruction( | ||
_program_id: &Pubkey, | ||
accounts: &[AccountInfo], | ||
_data: &[u8] | ||
) -> ProgramResult { | ||
let accounts_iter = &mut accounts.iter(); | ||
let payer = next_account_info(accounts_iter)?; | ||
let recipient = next_account_info(accounts_iter)?; | ||
let data_account = next_account_info(accounts_iter)?; | ||
let system_program = next_account_info(accounts_iter)?; | ||
|
||
let amount = u64::from_le_bytes(data_account.data.borrow()[0..8].try_into().unwrap()); | ||
|
||
invoke( | ||
&system_instruction::transfer(payer.key, recipient.key, amount), | ||
&[payer.clone(), recipient.clone(), system_program.clone()], | ||
)?; | ||
|
||
Ok(()) | ||
} |
Binary file added
BIN
+66.3 KB
svm/tests/example-programs/transfer-from-account/transfer_from_account_program.so
Binary file not shown.
Oops, something went wrong.