Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Nov 22, 2024
1 parent 0baa1f7 commit 83d2e3b
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 20 deletions.
7 changes: 7 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/sbf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ members = [
"rust/custom_heap",
"rust/dep_crate",
"rust/deprecated_loader",
"rust/divide_by_zero",
"rust/dup_accounts",
"rust/error_handling",
"rust/external_spend",
Expand Down
15 changes: 15 additions & 0 deletions programs/sbf/rust/divide_by_zero/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "solana-sbf-rust-divide-by-zero"
version = { workspace = true }
description = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
solana-program = { workspace = true }

[lib]
crate-type = ["cdylib"]
27 changes: 27 additions & 0 deletions programs/sbf/rust/divide_by_zero/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Example/test program to trigger vm error by dividing by zero
#![feature(asm_experimental_arch)]

extern crate solana_program;
use {
solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey},
std::arch::asm,
};

solana_program::entrypoint_no_alloc!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> ProgramResult {
unsafe {
asm!(
"
mov64 r0, 0
mov64 r1, 0
div64 r0, r1
"
);
}
Ok(())
}
Loading

0 comments on commit 83d2e3b

Please sign in to comment.