Dont call precompiled programs (#19930)
This commit is contained in:
@@ -170,6 +170,15 @@ fn get_data_slice<'a>(
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use super::*;
|
||||
use crate::{
|
||||
ed25519_instruction::new_ed25519_instruction,
|
||||
feature_set::FeatureSet,
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
};
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::sync::Arc;
|
||||
|
||||
fn test_case(
|
||||
num_signatures: u16,
|
||||
@@ -322,4 +331,34 @@ pub mod test {
|
||||
Err(PrecompileError::InvalidDataOffsets)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ed25519() {
|
||||
solana_logger::setup();
|
||||
|
||||
let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
|
||||
let message_arr = b"hello";
|
||||
let mut instruction = new_ed25519_instruction(&privkey, message_arr);
|
||||
let mint_keypair = Keypair::new();
|
||||
let feature_set = Arc::new(FeatureSet::all_enabled());
|
||||
|
||||
let tx = Transaction::new_signed_with_payer(
|
||||
&[instruction.clone()],
|
||||
Some(&mint_keypair.pubkey()),
|
||||
&[&mint_keypair],
|
||||
Hash::default(),
|
||||
);
|
||||
|
||||
assert!(tx.verify_precompiles(&feature_set).is_ok());
|
||||
|
||||
let index = thread_rng().gen_range(0, instruction.data.len());
|
||||
instruction.data[index] = instruction.data[index].wrapping_add(12);
|
||||
let tx = Transaction::new_signed_with_payer(
|
||||
&[instruction],
|
||||
Some(&mint_keypair.pubkey()),
|
||||
&[&mint_keypair],
|
||||
Hash::default(),
|
||||
);
|
||||
assert!(tx.verify_precompiles(&feature_set).is_err());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user