solana_ed25519_program/
lib.rs1use safecoin_sdk::{
2 instruction::InstructionError, process_instruction::InvokeContext, pubkey::Pubkey,
3};
4
5pub fn process_instruction(
6 _program_id: &Pubkey,
7 _data: &[u8],
8 _invoke_context: &mut dyn InvokeContext,
9) -> Result<(), InstructionError> {
10 Ok(())
12}
13
14#[cfg(test)]
15pub mod test {
16 use {
17 rand::{thread_rng, Rng},
18 safecoin_sdk::{
19 ed25519_instruction::new_ed25519_instruction,
20 feature_set::FeatureSet,
21 hash::Hash,
22 signature::{Keypair, Signer},
23 transaction::Transaction,
24 },
25 std::sync::Arc,
26 };
27
28 #[test]
29 fn test_ed25519() {
30 solana_logger::setup();
31
32 let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
33 let message_arr = b"hello";
34 let mut instruction = new_ed25519_instruction(&privkey, message_arr);
35 let mint_keypair = Keypair::new();
36 let feature_set = Arc::new(FeatureSet::all_enabled());
37
38 let tx = Transaction::new_signed_with_payer(
39 &[instruction.clone()],
40 Some(&mint_keypair.pubkey()),
41 &[&mint_keypair],
42 Hash::default(),
43 );
44
45 assert!(tx.verify_precompiles(&feature_set).is_ok());
46
47 let index = thread_rng().gen_range(0, instruction.data.len());
48 instruction.data[index] = instruction.data[index].wrapping_add(12);
49 let tx = Transaction::new_signed_with_payer(
50 &[instruction],
51 Some(&mint_keypair.pubkey()),
52 &[&mint_keypair],
53 Hash::default(),
54 );
55 assert!(tx.verify_precompiles(&feature_set).is_err());
56 }
57}