Skip to content

Commit

Permalink
Plumb through tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Apr 12, 2024
1 parent 51e49c6 commit fd03ab9
Show file tree
Hide file tree
Showing 23 changed files with 183 additions and 79 deletions.
2 changes: 2 additions & 0 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ mod tests {
nonce_account::verify_nonce_account,
poh_config::PohConfig,
pubkey::Pubkey,
reserved_account_keys::ReservedAccountKeys,
signature::Keypair,
signer::Signer,
system_instruction, system_program, system_transaction,
Expand Down Expand Up @@ -2026,6 +2027,7 @@ mod tests {
MessageHash::Compute,
Some(false),
bank.as_ref(),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions core/src/banking_stage/read_write_account_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ mod tests {
MessageHash::Compute,
Some(false),
bank,
bank.get_reserved_account_keys(),
)
.unwrap()
}
Expand Down
7 changes: 7 additions & 0 deletions core/src/banking_stage/unprocessed_packet_batches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ mod tests {
solana_sdk::{
compute_budget::ComputeBudgetInstruction,
message::Message,
reserved_account_keys::ReservedAccountKeys,
signature::{Keypair, Signer},
system_instruction, system_transaction,
transaction::{SimpleAddressLoader, Transaction},
Expand Down Expand Up @@ -490,6 +491,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(2, txs.count());
Expand All @@ -500,6 +502,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(0, txs.count());
Expand All @@ -519,6 +522,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(3, txs.count());
Expand All @@ -529,6 +533,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(2, txs.count());
Expand All @@ -548,6 +553,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(3, txs.count());
Expand All @@ -558,6 +564,7 @@ mod tests {
&Arc::new(FeatureSet::default()),
votes_only,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
});
assert_eq!(3, txs.count());
Expand Down
2 changes: 2 additions & 0 deletions cost-model/src/cost_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ mod tests {
crate::transaction_cost::*,
solana_sdk::{
hash::Hash,
reserved_account_keys::ReservedAccountKeys,
signature::{Keypair, Signer},
system_transaction,
transaction::{
Expand Down Expand Up @@ -401,6 +402,7 @@ mod tests {
MessageHash::Compute,
Some(true),
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();

Expand Down
3 changes: 3 additions & 0 deletions cost-model/src/transaction_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ mod tests {
feature_set::FeatureSet,
hash::Hash,
message::SimpleAddressLoader,
reserved_account_keys::ReservedAccountKeys,
signer::keypair::Keypair,
transaction::{MessageHash, SanitizedTransaction, VersionedTransaction},
},
Expand Down Expand Up @@ -231,6 +232,7 @@ mod tests {
MessageHash::Compute,
Some(true),
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();

Expand All @@ -240,6 +242,7 @@ mod tests {
MessageHash::Compute,
Some(false),
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();

Expand Down
3 changes: 3 additions & 0 deletions entry/benches/entry_sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use {
solana_perf::test_tx::test_tx,
solana_sdk::{
hash::Hash,
reserved_account_keys::ReservedAccountKeys,
transaction::{
Result, SanitizedTransaction, SimpleAddressLoader, TransactionVerificationMode,
VersionedTransaction,
Expand Down Expand Up @@ -41,6 +42,7 @@ fn bench_gpusigverify(bencher: &mut Bencher) {
message_hash,
None,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
}?;

Expand Down Expand Up @@ -84,6 +86,7 @@ fn bench_cpusigverify(bencher: &mut Bencher) {
message_hash,
None,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
}?;

Expand Down
2 changes: 2 additions & 0 deletions entry/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ mod tests {
solana_sdk::{
hash::{hash, Hash},
pubkey::Pubkey,
reserved_account_keys::ReservedAccountKeys,
signature::{Keypair, Signer},
system_transaction,
transaction::{
Expand Down Expand Up @@ -1084,6 +1085,7 @@ mod tests {
message_hash,
None,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
}?;

Expand Down
19 changes: 16 additions & 3 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use {
message::Message,
pubkey::Pubkey,
rent::Rent,
reserved_account_keys::ReservedAccountKeys,
signature::{Keypair, Signer},
system_program,
transaction::{SanitizedTransaction, Transaction, TransactionError},
Expand Down Expand Up @@ -201,7 +202,11 @@ fn execute_transactions(
}
.expect("lamports_per_signature must be available");
let fee = bank.get_fee_for_message_with_lamports_per_signature(
&SanitizedMessage::try_from_legacy_message(tx.message().clone()).unwrap(),
&SanitizedMessage::try_from_legacy_message(
tx.message().clone(),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap(),
lamports_per_signature,
);

Expand Down Expand Up @@ -3706,7 +3711,11 @@ fn test_program_fees() {
Some(&mint_keypair.pubkey()),
);

let sanitized_message = SanitizedMessage::try_from_legacy_message(message.clone()).unwrap();
let sanitized_message = SanitizedMessage::try_from_legacy_message(
message.clone(),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();
let expected_normal_fee = fee_structure.calculate_fee(
&sanitized_message,
congestion_multiplier,
Expand All @@ -3730,7 +3739,11 @@ fn test_program_fees() {
],
Some(&mint_keypair.pubkey()),
);
let sanitized_message = SanitizedMessage::try_from_legacy_message(message.clone()).unwrap();
let sanitized_message = SanitizedMessage::try_from_legacy_message(
message.clone(),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();
let expected_prioritized_fee = fee_structure.calculate_fee(
&sanitized_message,
congestion_multiplier,
Expand Down
16 changes: 13 additions & 3 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4785,6 +4785,7 @@ pub mod tests {
Message, MessageHeader, VersionedMessage,
},
nonce::{self, state::DurableNonce},
reserved_account_keys::ReservedAccountKeys,
rpc_port,
signature::{Keypair, Signer},
slot_hashes::SlotHashes,
Expand Down Expand Up @@ -9063,8 +9064,12 @@ pub mod tests {
.to_string(),
);
assert_eq!(
sanitize_transaction(unsanitary_versioned_tx, SimpleAddressLoader::Disabled)
.unwrap_err(),
sanitize_transaction(
unsanitary_versioned_tx,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set()
)
.unwrap_err(),
expect58
);
}
Expand All @@ -9084,7 +9089,12 @@ pub mod tests {
};

assert_eq!(
sanitize_transaction(versioned_tx, SimpleAddressLoader::Disabled).unwrap_err(),
sanitize_transaction(
versioned_tx,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set()
)
.unwrap_err(),
Error::invalid_params(
"invalid transaction: Transaction version is unsupported".to_string(),
)
Expand Down
7 changes: 6 additions & 1 deletion rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pub(crate) mod tests {
nonce_info::{NonceFull, NoncePartial},
pubkey::Pubkey,
rent_debits::RentDebits,
reserved_account_keys::ReservedAccountKeys,
signature::{Keypair, Signature, Signer},
system_transaction,
transaction::{
Expand Down Expand Up @@ -335,6 +336,7 @@ pub(crate) mod tests {
MessageHash::Compute,
None,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();

Expand Down Expand Up @@ -364,7 +366,10 @@ pub(crate) mod tests {
durable_nonce_fee: Some(DurableNonceFee::from(
&NonceFull::from_partial(
&rollback_partial,
&SanitizedMessage::Legacy(LegacyMessage::new(message)),
&SanitizedMessage::Legacy(LegacyMessage::new(
message,
&ReservedAccountKeys::empty_key_set(),
)),
&[(pubkey, nonce_account)],
&rent_debits,
)
Expand Down
2 changes: 2 additions & 0 deletions runtime-transaction/src/runtime_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ mod tests {
compute_budget::ComputeBudgetInstruction,
instruction::Instruction,
message::Message,
reserved_account_keys::ReservedAccountKeys,
signer::{keypair::Keypair, Signer},
transaction::{SimpleAddressLoader, Transaction, VersionedTransaction},
},
Expand Down Expand Up @@ -260,6 +261,7 @@ mod tests {
let dynamically_loaded_transaction = RuntimeTransaction::<SanitizedMessage>::try_from(
statically_loaded_transaction,
SimpleAddressLoader::Disabled,
&ReservedAccountKeys::empty_key_set(),
);
let dynamically_loaded_transaction =
dynamically_loaded_transaction.expect("created from statically loaded tx");
Expand Down
25 changes: 13 additions & 12 deletions sdk/benches/serialize_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
instruction::{AccountMeta, Instruction},
message::{Message, SanitizedMessage},
pubkey::{self, Pubkey},
reserved_account_keys::ReservedAccountKeys,
sysvar::instructions::{self, construct_instructions_data},
},
test::Bencher,
Expand All @@ -29,10 +30,10 @@ fn bench_bincode_instruction_serialize(b: &mut Bencher) {
#[bench]
fn bench_construct_instructions_data(b: &mut Bencher) {
let instructions = make_instructions();
let message = SanitizedMessage::try_from_legacy_message(Message::new(
&instructions,
Some(&Pubkey::new_unique()),
))
let message = SanitizedMessage::try_from_legacy_message(
Message::new(&instructions, Some(&Pubkey::new_unique())),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();
b.iter(|| {
let instructions = message.decompile_instructions();
Expand All @@ -52,10 +53,10 @@ fn bench_bincode_instruction_deserialize(b: &mut Bencher) {
#[bench]
fn bench_manual_instruction_deserialize(b: &mut Bencher) {
let instructions = make_instructions();
let message = SanitizedMessage::try_from_legacy_message(Message::new(
&instructions,
Some(&Pubkey::new_unique()),
))
let message = SanitizedMessage::try_from_legacy_message(
Message::new(&instructions, Some(&Pubkey::new_unique())),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();
let serialized = construct_instructions_data(&message.decompile_instructions());
b.iter(|| {
Expand All @@ -69,10 +70,10 @@ fn bench_manual_instruction_deserialize(b: &mut Bencher) {
#[bench]
fn bench_manual_instruction_deserialize_single(b: &mut Bencher) {
let instructions = make_instructions();
let message = SanitizedMessage::try_from_legacy_message(Message::new(
&instructions,
Some(&Pubkey::new_unique()),
))
let message = SanitizedMessage::try_from_legacy_message(
Message::new(&instructions, Some(&Pubkey::new_unique())),
&ReservedAccountKeys::empty_key_set(),
)
.unwrap();
let serialized = construct_instructions_data(&message.decompile_instructions());
b.iter(|| {
Expand Down
Loading

0 comments on commit fd03ab9

Please sign in to comment.