Cleanup use (#16327)
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
use {
|
||||
solana_program::{
|
||||
solana_program_test::{processor, ProgramTest},
|
||||
solana_sdk::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
entrypoint::ProgramResult,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
msg,
|
||||
program::invoke,
|
||||
pubkey::Pubkey,
|
||||
signature::Signer,
|
||||
transaction::Transaction,
|
||||
},
|
||||
solana_program_test::{processor, ProgramTest},
|
||||
solana_sdk::{signature::Signer, transaction::Transaction},
|
||||
};
|
||||
|
||||
// Process instruction to invoke into another program
|
||||
@@ -44,20 +45,19 @@ fn invoked_process_instruction(
|
||||
#[tokio::test]
|
||||
async fn cpi() {
|
||||
let invoker_program_id = Pubkey::new_unique();
|
||||
// Initialize and start the test network
|
||||
let mut program_test = ProgramTest::new(
|
||||
"program-test-fuzz-invoker",
|
||||
"invoker",
|
||||
invoker_program_id,
|
||||
processor!(invoker_process_instruction),
|
||||
);
|
||||
let invoked_program_id = Pubkey::new_unique();
|
||||
program_test.add_program(
|
||||
"program-test-fuzz-invoked",
|
||||
"invoked",
|
||||
invoked_program_id,
|
||||
processor!(invoked_process_instruction),
|
||||
);
|
||||
|
||||
let mut test_state = program_test.start_with_context().await;
|
||||
let mut context = program_test.start_with_context().await;
|
||||
let instructions = vec![Instruction::new_with_bincode(
|
||||
invoker_program_id,
|
||||
&[0],
|
||||
@@ -66,12 +66,12 @@ async fn cpi() {
|
||||
|
||||
let transaction = Transaction::new_signed_with_payer(
|
||||
&instructions,
|
||||
Some(&test_state.payer.pubkey()),
|
||||
&[&test_state.payer],
|
||||
test_state.last_blockhash,
|
||||
Some(&context.payer.pubkey()),
|
||||
&[&context.payer],
|
||||
context.last_blockhash,
|
||||
);
|
||||
|
||||
test_state
|
||||
context
|
||||
.banks_client
|
||||
.process_transaction(transaction)
|
||||
.await
|
||||
|
@@ -1,11 +1,11 @@
|
||||
use {
|
||||
solana_banks_client::BanksClient,
|
||||
solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, hash::Hash, instruction::Instruction,
|
||||
msg, pubkey::Pubkey, rent::Rent, system_instruction,
|
||||
},
|
||||
solana_program_test::{processor, ProgramTest},
|
||||
solana_sdk::{signature::Keypair, signature::Signer, transaction::Transaction},
|
||||
solana_sdk::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, hash::Hash, instruction::Instruction,
|
||||
msg, pubkey::Pubkey, rent::Rent, signature::Keypair, signature::Signer, system_instruction,
|
||||
transaction::Transaction,
|
||||
},
|
||||
};
|
||||
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
@@ -57,16 +57,16 @@ fn simulate_fuzz_with_context() {
|
||||
processor!(process_instruction),
|
||||
);
|
||||
|
||||
let mut test_state = rt.block_on(async { program_test.start_with_context().await });
|
||||
let mut context = rt.block_on(async { program_test.start_with_context().await });
|
||||
|
||||
// the honggfuzz `fuzz!` macro does not allow for async closures,
|
||||
// so we have to use the runtime directly to run async functions
|
||||
rt.block_on(async {
|
||||
run_fuzz_instructions(
|
||||
&[1, 2, 3, 4, 5],
|
||||
&mut test_state.banks_client,
|
||||
&test_state.payer,
|
||||
test_state.last_blockhash,
|
||||
&mut context.banks_client,
|
||||
&context.payer,
|
||||
context.last_blockhash,
|
||||
&program_id,
|
||||
)
|
||||
.await
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use {
|
||||
solana_program::{
|
||||
solana_program_test::{processor, ProgramTest, ProgramTestError},
|
||||
solana_sdk::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
clock::Clock,
|
||||
entrypoint::ProgramResult,
|
||||
@@ -8,12 +9,9 @@ use {
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction, system_program,
|
||||
sysvar::{clock, Sysvar},
|
||||
},
|
||||
solana_program_test::{processor, ProgramTest, ProgramTestError},
|
||||
solana_sdk::{
|
||||
signature::{Keypair, Signer},
|
||||
transaction::{Transaction, TransactionError},
|
||||
},
|
||||
solana_stake_program::{
|
||||
|
Reference in New Issue
Block a user