Skip to content

Commit 1cb4d44

Browse files
committed
Adjusts tests.
1 parent 39aadea commit 1cb4d44

File tree

6 files changed

+359
-295
lines changed

6 files changed

+359
-295
lines changed

cli/tests/program.rs

Lines changed: 137 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use {
2323
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
2424
commitment_config::CommitmentConfig,
2525
compute_budget::{self, ComputeBudgetInstruction},
26-
feature_set::enable_alt_bn128_syscall,
26+
feature_set::{enable_alt_bn128_syscall, enable_loader_v4},
2727
fee_calculator::FeeRateGovernor,
2828
pubkey::Pubkey,
2929
rent::Rent,
@@ -32,7 +32,7 @@ use {
3232
transaction::Transaction,
3333
},
3434
solana_streamer::socket::SocketAddrSpace,
35-
solana_test_validator::{TestValidator, TestValidatorGenesis},
35+
solana_test_validator::TestValidatorGenesis,
3636
solana_transaction_status::UiTransactionEncoding,
3737
std::{
3838
env,
@@ -81,8 +81,17 @@ fn test_cli_program_deploy_non_upgradeable() {
8181
let mint_keypair = Keypair::new();
8282
let mint_pubkey = mint_keypair.pubkey();
8383
let faucet_addr = run_local_faucet(mint_keypair, None);
84-
let test_validator =
85-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
84+
let test_validator = TestValidatorGenesis::default()
85+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
86+
.rent(Rent {
87+
lamports_per_byte_year: 1,
88+
exemption_threshold: 1.0,
89+
..Rent::default()
90+
})
91+
.faucet_addr(Some(faucet_addr))
92+
.deactivate_features(&[enable_loader_v4::id()])
93+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
94+
.expect("validator start failed");
8695

8796
let rpc_client =
8897
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -286,8 +295,17 @@ fn test_cli_program_deploy_no_authority() {
286295
let mint_keypair = Keypair::new();
287296
let mint_pubkey = mint_keypair.pubkey();
288297
let faucet_addr = run_local_faucet(mint_keypair, None);
289-
let test_validator =
290-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
298+
let test_validator = TestValidatorGenesis::default()
299+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
300+
.rent(Rent {
301+
lamports_per_byte_year: 1,
302+
exemption_threshold: 1.0,
303+
..Rent::default()
304+
})
305+
.faucet_addr(Some(faucet_addr))
306+
.deactivate_features(&[enable_loader_v4::id()])
307+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
308+
.expect("validator start failed");
291309

292310
let rpc_client =
293311
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -403,6 +421,7 @@ fn test_cli_program_deploy_feature(enable_feature: bool) {
403421
test_validator_builder.deactivate_features(&[enable_alt_bn128_syscall::id()]);
404422
}
405423

424+
test_validator_builder = test_validator_builder.deactivate_features(&[enable_loader_v4::id()]);
406425
let test_validator = test_validator_builder
407426
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
408427
.expect("validator start failed");
@@ -530,6 +549,7 @@ fn test_cli_program_upgrade_with_feature(enable_feature: bool) {
530549
test_validator_builder.deactivate_features(&[enable_alt_bn128_syscall::id()]);
531550
}
532551

552+
test_validator_builder = test_validator_builder.deactivate_features(&[enable_loader_v4::id()]);
533553
let test_validator = test_validator_builder
534554
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
535555
.expect("validator start failed");
@@ -678,8 +698,17 @@ fn test_cli_program_deploy_with_authority() {
678698
let mint_keypair = Keypair::new();
679699
let mint_pubkey = mint_keypair.pubkey();
680700
let faucet_addr = run_local_faucet(mint_keypair, None);
681-
let test_validator =
682-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
701+
let test_validator = TestValidatorGenesis::default()
702+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
703+
.rent(Rent {
704+
lamports_per_byte_year: 1,
705+
exemption_threshold: 1.0,
706+
..Rent::default()
707+
})
708+
.faucet_addr(Some(faucet_addr))
709+
.deactivate_features(&[enable_loader_v4::id()])
710+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
711+
.expect("validator start failed");
683712

684713
let rpc_client =
685714
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -1079,8 +1108,17 @@ fn test_cli_program_upgrade_auto_extend() {
10791108
let mint_keypair = Keypair::new();
10801109
let mint_pubkey = mint_keypair.pubkey();
10811110
let faucet_addr = run_local_faucet(mint_keypair, None);
1082-
let test_validator =
1083-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
1111+
let test_validator = TestValidatorGenesis::default()
1112+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
1113+
.rent(Rent {
1114+
lamports_per_byte_year: 1,
1115+
exemption_threshold: 1.0,
1116+
..Rent::default()
1117+
})
1118+
.faucet_addr(Some(faucet_addr))
1119+
.deactivate_features(&[enable_loader_v4::id()])
1120+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
1121+
.expect("validator start failed");
10841122

10851123
let rpc_client =
10861124
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -1232,8 +1270,17 @@ fn test_cli_program_close_program() {
12321270
let mint_keypair = Keypair::new();
12331271
let mint_pubkey = mint_keypair.pubkey();
12341272
let faucet_addr = run_local_faucet(mint_keypair, None);
1235-
let test_validator =
1236-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
1273+
let test_validator = TestValidatorGenesis::default()
1274+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
1275+
.rent(Rent {
1276+
lamports_per_byte_year: 1,
1277+
exemption_threshold: 1.0,
1278+
..Rent::default()
1279+
})
1280+
.faucet_addr(Some(faucet_addr))
1281+
.deactivate_features(&[enable_loader_v4::id()])
1282+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
1283+
.expect("validator start failed");
12371284

12381285
let rpc_client =
12391286
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -1351,8 +1398,17 @@ fn test_cli_program_extend_program() {
13511398
let mint_keypair = Keypair::new();
13521399
let mint_pubkey = mint_keypair.pubkey();
13531400
let faucet_addr = run_local_faucet(mint_keypair, None);
1354-
let test_validator =
1355-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
1401+
let test_validator = TestValidatorGenesis::default()
1402+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
1403+
.rent(Rent {
1404+
lamports_per_byte_year: 1,
1405+
exemption_threshold: 1.0,
1406+
..Rent::default()
1407+
})
1408+
.faucet_addr(Some(faucet_addr))
1409+
.deactivate_features(&[enable_loader_v4::id()])
1410+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
1411+
.expect("validator start failed");
13561412

13571413
let rpc_client =
13581414
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -1521,8 +1577,17 @@ fn test_cli_program_write_buffer() {
15211577
let mint_keypair = Keypair::new();
15221578
let mint_pubkey = mint_keypair.pubkey();
15231579
let faucet_addr = run_local_faucet(mint_keypair, None);
1524-
let test_validator =
1525-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
1580+
let test_validator = TestValidatorGenesis::default()
1581+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
1582+
.rent(Rent {
1583+
lamports_per_byte_year: 1,
1584+
exemption_threshold: 1.0,
1585+
..Rent::default()
1586+
})
1587+
.faucet_addr(Some(faucet_addr))
1588+
.deactivate_features(&[enable_loader_v4::id()])
1589+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
1590+
.expect("validator start failed");
15261591

15271592
let rpc_client =
15281593
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2008,8 +2073,17 @@ fn test_cli_program_set_buffer_authority() {
20082073
let mint_keypair = Keypair::new();
20092074
let mint_pubkey = mint_keypair.pubkey();
20102075
let faucet_addr = run_local_faucet(mint_keypair, None);
2011-
let test_validator =
2012-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
2076+
let test_validator = TestValidatorGenesis::default()
2077+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
2078+
.rent(Rent {
2079+
lamports_per_byte_year: 1,
2080+
exemption_threshold: 1.0,
2081+
..Rent::default()
2082+
})
2083+
.faucet_addr(Some(faucet_addr))
2084+
.deactivate_features(&[enable_loader_v4::id()])
2085+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
2086+
.expect("validator start failed");
20132087

20142088
let rpc_client =
20152089
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2180,8 +2254,17 @@ fn test_cli_program_mismatch_buffer_authority() {
21802254
let mint_keypair = Keypair::new();
21812255
let mint_pubkey = mint_keypair.pubkey();
21822256
let faucet_addr = run_local_faucet(mint_keypair, None);
2183-
let test_validator =
2184-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
2257+
let test_validator = TestValidatorGenesis::default()
2258+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
2259+
.rent(Rent {
2260+
lamports_per_byte_year: 1,
2261+
exemption_threshold: 1.0,
2262+
..Rent::default()
2263+
})
2264+
.faucet_addr(Some(faucet_addr))
2265+
.deactivate_features(&[enable_loader_v4::id()])
2266+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
2267+
.expect("validator start failed");
21852268

21862269
let rpc_client =
21872270
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2306,8 +2389,17 @@ fn test_cli_program_deploy_with_offline_signing(use_offline_signer_as_fee_payer:
23062389
let mint_keypair = Keypair::new();
23072390
let mint_pubkey = mint_keypair.pubkey();
23082391
let faucet_addr = run_local_faucet(mint_keypair, None);
2309-
let test_validator =
2310-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
2392+
let test_validator = TestValidatorGenesis::default()
2393+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
2394+
.rent(Rent {
2395+
lamports_per_byte_year: 1,
2396+
exemption_threshold: 1.0,
2397+
..Rent::default()
2398+
})
2399+
.faucet_addr(Some(faucet_addr))
2400+
.deactivate_features(&[enable_loader_v4::id()])
2401+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
2402+
.expect("validator start failed");
23112403

23122404
let rpc_client =
23132405
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2499,8 +2591,17 @@ fn test_cli_program_show() {
24992591
let mint_keypair = Keypair::new();
25002592
let mint_pubkey = mint_keypair.pubkey();
25012593
let faucet_addr = run_local_faucet(mint_keypair, None);
2502-
let test_validator =
2503-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
2594+
let test_validator = TestValidatorGenesis::default()
2595+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
2596+
.rent(Rent {
2597+
lamports_per_byte_year: 1,
2598+
exemption_threshold: 1.0,
2599+
..Rent::default()
2600+
})
2601+
.faucet_addr(Some(faucet_addr))
2602+
.deactivate_features(&[enable_loader_v4::id()])
2603+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
2604+
.expect("validator start failed");
25042605

25052606
let rpc_client =
25062607
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2696,8 +2797,17 @@ fn test_cli_program_dump() {
26962797
let mint_keypair = Keypair::new();
26972798
let mint_pubkey = mint_keypair.pubkey();
26982799
let faucet_addr = run_local_faucet(mint_keypair, None);
2699-
let test_validator =
2700-
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
2800+
let test_validator = TestValidatorGenesis::default()
2801+
.fee_rate_governor(FeeRateGovernor::new(0, 0))
2802+
.rent(Rent {
2803+
lamports_per_byte_year: 1,
2804+
exemption_threshold: 1.0,
2805+
..Rent::default()
2806+
})
2807+
.faucet_addr(Some(faucet_addr))
2808+
.deactivate_features(&[enable_loader_v4::id()])
2809+
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
2810+
.expect("validator start failed");
27012811

27022812
let rpc_client =
27032813
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
@@ -2835,6 +2945,7 @@ fn test_cli_program_deploy_with_args(compute_unit_price: Option<u64>, use_rpc: b
28352945
exemption_threshold: 1.0,
28362946
..Rent::default()
28372947
})
2948+
.deactivate_features(&[enable_loader_v4::id()])
28382949
.rpc_config(JsonRpcConfig {
28392950
enable_rpc_transaction_history: true,
28402951
faucet_addr: Some(faucet_addr),

programs/sbf/benches/bpf_loader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use {
3232
bank::Bank,
3333
bank_client::BankClient,
3434
genesis_utils::{create_genesis_config, GenesisConfigInfo},
35-
loader_utils::{load_program_from_file, load_upgradeable_program_and_advance_slot},
35+
loader_utils::{load_program_from_file, load_program_of_loader_v4},
3636
},
3737
solana_sdk::{
3838
account::AccountSharedData,
@@ -202,9 +202,9 @@ fn bench_program_execute_noop(bencher: &mut Bencher) {
202202
let authority_keypair = Keypair::new();
203203
let mint_pubkey = mint_keypair.pubkey();
204204

205-
let (_, invoke_program_id) = load_upgradeable_program_and_advance_slot(
205+
let (_bank, invoke_program_id) = load_program_of_loader_v4(
206206
&mut bank_client,
207-
bank_forks.as_ref(),
207+
&bank_forks,
208208
&mint_keypair,
209209
&authority_keypair,
210210
"noop",

0 commit comments

Comments
 (0)