Skip to content

Commit

Permalink
more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Dec 19, 2023
1 parent 0919192 commit 3d1ec85
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
4 changes: 4 additions & 0 deletions programs/sbf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ fn bench_program_execute_noop(bencher: &mut Bencher) {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let bank = Bank::new_for_benches(&genesis_config);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down
110 changes: 110 additions & 0 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ fn test_program_sbf_sanity() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);

Expand Down Expand Up @@ -420,6 +424,10 @@ fn test_sol_alloc_free_no_longer_deployable() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

// Populate loader account with elf that depends on _sol_alloc_free syscall
Expand Down Expand Up @@ -540,6 +548,10 @@ fn test_program_sbf_duplicate_accounts() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());
let (bank, program_id) = load_program_and_advance_slot(
Expand Down Expand Up @@ -651,6 +663,10 @@ fn test_program_sbf_error_handling() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
let (_, program_id) = load_program_and_advance_slot(
Expand Down Expand Up @@ -764,6 +780,10 @@ fn test_return_data_and_log_data_syscall() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());

Expand Down Expand Up @@ -839,6 +859,10 @@ fn test_program_sbf_invoke_sanity() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());

Expand Down Expand Up @@ -1242,6 +1266,9 @@ fn test_program_sbf_program_id_spoofing() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down Expand Up @@ -1300,6 +1327,9 @@ fn test_program_sbf_caller_has_access_to_cpi_program() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down Expand Up @@ -1345,6 +1375,9 @@ fn test_program_sbf_ro_modify() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down Expand Up @@ -1407,6 +1440,9 @@ fn test_program_sbf_call_depth() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -1448,6 +1484,9 @@ fn test_program_sbf_compute_budget() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -1583,6 +1622,9 @@ fn test_program_sbf_instruction_introspection() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down Expand Up @@ -1648,6 +1690,9 @@ fn test_program_sbf_test_use_latest_executor() {
genesis_config
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());
genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -2348,6 +2393,10 @@ fn test_program_sbf_invoke_upgradeable_via_cpi() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
let invoke_and_return = load_program(
Expand Down Expand Up @@ -2483,6 +2532,7 @@ fn test_program_sbf_disguised_as_sbf_loader() {
&solana_sdk::feature_set::remove_bpf_loader_incorrect_program_id::id(),
);
bank.deactivate_feature(&feature_set::disable_bpf_loader_instructions::id());
bank.deactivate_feature(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());
let bank = bank.wrap_with_bank_forks_for_tests().0;
let bank_client = BankClient::new_shared(bank);

Expand Down Expand Up @@ -2514,6 +2564,10 @@ fn test_program_reads_from_program_account() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);

Expand Down Expand Up @@ -2548,6 +2602,10 @@ fn test_program_sbf_c_dup() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

let account_address = Pubkey::new_unique();
Expand Down Expand Up @@ -2590,6 +2648,10 @@ fn test_program_sbf_upgrade_via_cpi() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);
let invoke_and_return = load_program(
Expand Down Expand Up @@ -2707,6 +2769,10 @@ fn test_program_sbf_set_upgrade_authority_via_cpi() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank);

Expand Down Expand Up @@ -2929,6 +2995,10 @@ fn test_program_sbf_finalize() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());

Expand Down Expand Up @@ -2984,6 +3054,10 @@ fn test_program_sbf_ro_account_modify() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());

Expand Down Expand Up @@ -3053,6 +3127,10 @@ fn test_program_sbf_realloc() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let mint_pubkey = mint_keypair.pubkey();
let signer = &[&mint_keypair];
for direct_mapping in [false, true] {
Expand Down Expand Up @@ -3395,6 +3473,10 @@ fn test_program_sbf_realloc_invoke() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let mint_pubkey = mint_keypair.pubkey();
let signer = &[&mint_keypair];

Expand Down Expand Up @@ -3921,6 +4003,10 @@ fn test_program_sbf_processed_inner_instruction() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
let mut bank_client = BankClient::new_shared(bank.clone());

Expand Down Expand Up @@ -4004,6 +4090,10 @@ fn test_program_fees() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

genesis_config.fee_rate_governor = FeeRateGovernor::new(congestion_multiplier, 0);
let mut bank = Bank::new_for_tests(&genesis_config);
let fee_structure =
Expand Down Expand Up @@ -4084,6 +4174,10 @@ fn test_get_minimum_delegation() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let bank = Bank::new_for_tests(&genesis_config);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
let mut bank_client = BankClient::new_shared(bank.clone());
Expand Down Expand Up @@ -4160,6 +4254,7 @@ fn test_cpi_account_ownership_writability() {
// deactivate `disable_bpf_loader_instructions` feature so that the program
// can be loaded, finalized and tested.
feature_set.deactivate(&feature_set::disable_bpf_loader_instructions::id());
feature_set.deactivate(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());
bank.feature_set = Arc::new(feature_set);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -4345,6 +4440,8 @@ fn test_cpi_account_data_updates() {
// deactivate `disable_bpf_loader_instructions` feature so that the program
// can be loaded, finalized and tested.
feature_set.deactivate(&feature_set::disable_bpf_loader_instructions::id());
feature_set.deactivate(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

bank.feature_set = Arc::new(feature_set);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -4498,6 +4595,7 @@ fn test_cpi_deprecated_loader_realloc() {
// deactivate `disable_bpf_loader_instructions` feature so that the program
// can be loaded, finalized and tested.
feature_set.deactivate(&feature_set::disable_bpf_loader_instructions::id());
feature_set.deactivate(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

bank.feature_set = Arc::new(feature_set);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
Expand Down Expand Up @@ -4614,6 +4712,10 @@ fn test_cpi_change_account_data_memory_allocation() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let mut bank = Bank::new_for_tests(&genesis_config);

declare_process_instruction!(MockBuiltin, 42, |invoke_context| {
Expand Down Expand Up @@ -4705,6 +4807,10 @@ fn test_cpi_invalid_account_info_pointers() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

let bank = Bank::new_for_tests(&genesis_config);
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
let mut bank_client = BankClient::new_shared(bank);
Expand Down Expand Up @@ -4773,6 +4879,10 @@ fn test_deny_executable_write() {
.accounts
.remove(&feature_set::disable_bpf_loader_instructions::id());

genesis_config
.accounts
.remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id());

for direct_mapping in [false, true] {
let mut bank = Bank::new_for_tests(&genesis_config);
let feature_set = Arc::make_mut(&mut bank.feature_set);
Expand Down

0 comments on commit 3d1ec85

Please sign in to comment.