Rust BPF program cleanup (#7990)

This commit is contained in:
Jack May
2020-01-27 18:27:44 -08:00
committed by GitHub
parent fd7d5cbe0d
commit 1596c961d9
12 changed files with 119 additions and 124 deletions

View File

@ -3,10 +3,8 @@
#[macro_use]
extern crate alloc;
extern crate solana_sdk;
use solana_sdk::entrypoint::SUCCESS;
use solana_sdk::info;
use std::alloc::Layout;
use std::mem;
use solana_sdk::{entrypoint::SUCCESS, info};
use std::{alloc::Layout, mem};
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
@ -22,7 +20,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
}
unsafe {
// Test modest allocation and deallocation
// Test modest allocation and de-allocation
let layout = Layout::from_size_align(100, mem::align_of::<u8>()).unwrap();
let ptr = alloc::alloc::alloc(layout);

View File

@ -8,7 +8,7 @@ use solana_sdk::{
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
accounts: &mut [AccountInfo],
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> u32 {
const FAILURE: u32 = 1;

View File

@ -6,7 +6,7 @@ use solana_sdk::{account_info::AccountInfo, entrypoint, entrypoint::SUCCESS, pub
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
accounts: &mut [AccountInfo],
accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> u32 {
// account 0 is the mint and not owned by this program, any debit of its lamports

View File

@ -1,8 +1,7 @@
//! @brief Example Rust-based BPF program tests loop iteration
extern crate solana_sdk;
use solana_sdk::entrypoint::SUCCESS;
use solana_sdk::info;
use solana_sdk::{entrypoint::SUCCESS, info};
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
@ -22,7 +21,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
#[cfg(test)]
mod test {
use super::*;
// Pulls in the stubs requried for `info!()`
// Pulls in the stubs required for `info!()`
solana_sdk_bpf_test::stubs!();
#[test]

View File

@ -2,8 +2,7 @@
mod helper;
extern crate solana_sdk;
use solana_sdk::entrypoint::SUCCESS;
use solana_sdk::info;
use solana_sdk::{entrypoint::SUCCESS, info};
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
@ -30,7 +29,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
#[cfg(test)]
mod test {
use super::*;
// Pulls in the stubs requried for `info!()`
// Pulls in the stubs required for `info!()`
solana_sdk_bpf_test::stubs!();
#[test]

View File

@ -51,7 +51,7 @@ pub fn many_args_sret(
#[cfg(test)]
mod test {
use super::*;
// Pulls in the stubs requried for `info!()`
// Pulls in the stubs required for `info!()`
solana_sdk_bpf_test::stubs!();
#[test]

View File

@ -22,7 +22,7 @@ fn return_sstruct() -> SStruct {
entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &mut [AccountInfo],
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> u32 {
info!("Program identifier:");

View File

@ -2,8 +2,7 @@
extern crate solana_sdk;
use solana_bpf_rust_param_passing_dep::{Data, TestDep};
use solana_sdk::entrypoint::SUCCESS;
use solana_sdk::info;
use solana_sdk::{entrypoint::SUCCESS, info};
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
@ -27,7 +26,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u32 {
#[cfg(test)]
mod test {
use super::*;
// Pulls in the stubs requried for `info!()`
// Pulls in the stubs required for `info!()`
solana_sdk_bpf_test::stubs!();
#[test]

View File

@ -27,7 +27,7 @@ impl<'a> TestDep {
#[cfg(test)]
mod test {
use super::*;
// Pulls in the stubs requried for `info!()`
// Pulls in the stubs required for `info!()`
solana_sdk_bpf_test::stubs!();
#[test]

View File

@ -19,7 +19,7 @@ use solana_sdk::{
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
accounts: &mut [AccountInfo],
accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> u32 {
// Clock