Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Aug 27, 2024
1 parent dc714e3 commit 1084cfa
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions programs/ed25519-tests/tests/process_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use {
solana_program_test::*,
solana_sdk::{
ed25519_instruction::new_ed25519_instruction,
feature_set,
instruction::InstructionError,
precompiles::PrecompileError,
signature::Signer,
Expand Down Expand Up @@ -46,6 +47,37 @@ async fn test_success() {
assert_matches!(client.process_transaction(transaction).await, Ok(()));
}

#[tokio::test]
async fn test_failure_without_move_precompiles_feature() {
let mut program_test = ProgramTest::default();
program_test.deactivate_feature(feature_set::move_precompile_verification_to_svm::id());
let mut context = program_test.start_with_context().await;

let client = &mut context.banks_client;
let payer = &context.payer;
let recent_blockhash = context.last_blockhash;

let privkey = generate_keypair();
let message_arr = b"hello";
let mut instruction = new_ed25519_instruction(&privkey, message_arr);

instruction.data[0] += 1;

let transaction = Transaction::new_signed_with_payer(
&[instruction],
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
);

assert_matches!(
client.process_transaction(transaction).await,
Err(BanksClientError::TransactionError(
TransactionError::InvalidAccountIndex
))
);
}

#[tokio::test]
async fn test_failure() {
let mut context = ProgramTest::default().start_with_context().await;
Expand Down

0 comments on commit 1084cfa

Please sign in to comment.