banks-server: Support versioned transactions (#33005)

This commit is contained in:
Jon Cinque 2023-08-28 23:08:41 +02:00 committed by GitHub
parent 97d6e6f738
commit dcad8f01bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View File

@ -93,7 +93,7 @@ impl BanksServer {
// has been processed
let lock = bank.freeze_lock();
if *lock == Hash::default() {
let _ = bank.try_process_transactions(transactions.iter());
let _ = bank.try_process_entry_transactions(transactions);
// break out of inner loop and release bank freeze lock
break;
}

View File

@ -2,8 +2,11 @@ use {
solana_program_test::ProgramTest,
solana_sdk::{
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
message::{v0::Message, VersionedMessage},
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
system_instruction,
transaction::{Transaction, VersionedTransaction},
},
};
@ -43,3 +46,39 @@ async fn test_bpf_loader_upgradeable_present() {
assert_eq!(buffer_account.owner, bpf_loader_upgradeable::id());
}
#[tokio::test]
async fn versioned_transaction() {
let program_test = ProgramTest::default();
let mut context = program_test.start_with_context().await;
let program_id = Pubkey::new_unique();
let account = Keypair::new();
let rent = context.banks_client.get_rent().await.unwrap();
let space = 82;
let transaction = VersionedTransaction::try_new(
VersionedMessage::V0(
Message::try_compile(
&context.payer.pubkey(),
&[system_instruction::create_account(
&context.payer.pubkey(),
&account.pubkey(),
rent.minimum_balance(space),
space as u64,
&program_id,
)],
&[],
context.last_blockhash,
)
.unwrap(),
),
&[&context.payer, &account],
)
.unwrap();
context
.banks_client
.process_transaction(transaction)
.await
.unwrap();
}