Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit f62b1b8

Browse files
authored
stake-pool: Add error logging during test failures (#5278)
1 parent 8dabc33 commit f62b1b8

21 files changed

+116
-116
lines changed

stake-pool/program/tests/decrease.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async fn success(use_additional_instruction: bool) {
108108
use_additional_instruction,
109109
)
110110
.await;
111-
assert!(error.is_none());
111+
assert!(error.is_none(), "{:?}", error);
112112

113113
// Check validator stake account balance
114114
let validator_stake_account =
@@ -291,7 +291,7 @@ async fn fail_twice_diff_seed(use_additional_instruction: bool) {
291291
use_additional_instruction,
292292
)
293293
.await;
294-
assert!(error.is_none());
294+
assert!(error.is_none(), "{:?}", error);
295295

296296
let transient_stake_seed = validator_stake.transient_stake_seed * 100;
297297
let transient_stake_address = find_transient_stake_program_address(
@@ -358,7 +358,7 @@ async fn twice(success: bool, use_additional_first_time: bool, use_additional_se
358358
use_additional_first_time,
359359
)
360360
.await;
361-
assert!(error.is_none());
361+
assert!(error.is_none(), "{:?}", error);
362362

363363
let error = stake_pool_accounts
364364
.decrease_validator_stake_either(
@@ -374,7 +374,7 @@ async fn twice(success: bool, use_additional_first_time: bool, use_additional_se
374374
.await;
375375

376376
if success {
377-
assert!(error.is_none());
377+
assert!(error.is_none(), "{:?}", error);
378378
// no ephemeral account
379379
let ephemeral_stake = find_ephemeral_stake_program_address(
380380
&id(),
@@ -565,7 +565,7 @@ async fn fail_additional_with_increasing() {
565565
validator_stake.transient_stake_seed,
566566
)
567567
.await;
568-
assert!(error.is_none());
568+
assert!(error.is_none(), "{:?}", error);
569569

570570
let error = stake_pool_accounts
571571
.decrease_validator_stake_either(

stake-pool/program/tests/deposit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async fn success(token_program_id: Pubkey) {
182182
&user,
183183
)
184184
.await;
185-
assert!(error.is_none());
185+
assert!(error.is_none(), "{:?}", error);
186186

187187
// Original stake account should be drained
188188
assert!(context
@@ -355,7 +355,7 @@ async fn success_with_extra_stake_lamports() {
355355
&referrer_token_account.pubkey(),
356356
)
357357
.await;
358-
assert!(error.is_none());
358+
assert!(error.is_none(), "{:?}", error);
359359

360360
// Original stake account should be drained
361361
assert!(context
@@ -875,7 +875,7 @@ async fn success_with_slippage(token_program_id: Pubkey) {
875875
tokens_issued_user,
876876
)
877877
.await;
878-
assert!(error.is_none());
878+
assert!(error.is_none(), "{:?}", error);
879879

880880
// Original stake account should be drained
881881
assert!(context

stake-pool/program/tests/deposit_authority.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async fn success_deposit() {
120120
&user,
121121
)
122122
.await;
123-
assert!(error.is_none());
123+
assert!(error.is_none(), "{:?}", error);
124124
}
125125

126126
#[tokio::test]

stake-pool/program/tests/deposit_edge_cases.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ async fn success_with_preferred_deposit() {
151151
&user,
152152
)
153153
.await;
154-
assert!(error.is_none());
154+
assert!(error.is_none(), "{:?}", error);
155155
}
156156

157157
#[tokio::test]

stake-pool/program/tests/deposit_sol.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async fn success(token_program_id: Pubkey) {
9898
None,
9999
)
100100
.await;
101-
assert!(error.is_none());
101+
assert!(error.is_none(), "{:?}", error);
102102

103103
let tokens_issued = TEST_STAKE_AMOUNT; // For now tokens are 1:1 to stake
104104

@@ -309,7 +309,7 @@ async fn success_with_sol_deposit_authority() {
309309
None,
310310
)
311311
.await;
312-
assert!(error.is_none());
312+
assert!(error.is_none(), "{:?}", error);
313313

314314
let sol_deposit_authority = Keypair::new();
315315

@@ -336,7 +336,7 @@ async fn success_with_sol_deposit_authority() {
336336
Some(&sol_deposit_authority),
337337
)
338338
.await;
339-
assert!(error.is_none());
339+
assert!(error.is_none(), "{:?}", error);
340340
}
341341

342342
#[tokio::test]
@@ -569,7 +569,7 @@ async fn success_with_slippage(token_program_id: Pubkey) {
569569
tokens_issued,
570570
)
571571
.await;
572-
assert!(error.is_none());
572+
assert!(error.is_none(), "{:?}", error);
573573

574574
// Stake pool should add its balance to the pool balance
575575
let post_stake_pool = get_account(

stake-pool/program/tests/force_destake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async fn success_update() {
146146
false,
147147
)
148148
.await;
149-
assert!(error.is_none());
149+
assert!(error.is_none(), "{:?}", error);
150150
let post_reserve_lamports = context
151151
.banks_client
152152
.get_account(stake_pool_accounts.reserve_stake.pubkey())

stake-pool/program/tests/helpers/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ pub async fn simple_add_validator_to_pool(
20852085
sol_deposit_authority,
20862086
)
20872087
.await;
2088-
assert!(error.is_none());
2088+
assert!(error.is_none(), "{:?}", error);
20892089

20902090
create_vote(
20912091
banks_client,
@@ -2106,7 +2106,7 @@ pub async fn simple_add_validator_to_pool(
21062106
validator_stake.validator_stake_seed,
21072107
)
21082108
.await;
2109-
assert!(error.is_none());
2109+
assert!(error.is_none(), "{:?}", error);
21102110

21112111
validator_stake
21122112
}
@@ -2207,7 +2207,7 @@ impl DepositStakeAccount {
22072207
)
22082208
.await;
22092209
self.pool_tokens = get_token_balance(banks_client, &self.pool_account.pubkey()).await;
2210-
assert!(error.is_none());
2210+
assert!(error.is_none(), "{:?}", error);
22112211
}
22122212
}
22132213

stake-pool/program/tests/huge_pool.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ async fn update(max_validators: u32) {
184184
false, /* no_merge */
185185
)
186186
.await;
187-
assert!(error.is_none());
187+
assert!(error.is_none(), "{:?}", error);
188188

189189
let error = stake_pool_accounts
190190
.update_stake_pool_balance(
@@ -193,7 +193,7 @@ async fn update(max_validators: u32) {
193193
&context.last_blockhash,
194194
)
195195
.await;
196-
assert!(error.is_none());
196+
assert!(error.is_none(), "{:?}", error);
197197

198198
let error = stake_pool_accounts
199199
.cleanup_removed_validator_entries(
@@ -202,7 +202,7 @@ async fn update(max_validators: u32) {
202202
&context.last_blockhash,
203203
)
204204
.await;
205-
assert!(error.is_none());
205+
assert!(error.is_none(), "{:?}", error);
206206
}
207207

208208
//#[test_case(MAX_POOL_SIZE_WITH_REQUESTED_COMPUTE_UNITS; "compute-budget")]
@@ -236,7 +236,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
236236
&transient_stake_address,
237237
)
238238
.await;
239-
assert!(error.is_none());
239+
assert!(error.is_none(), "{:?}", error);
240240

241241
let middle_index = max_validators as usize / 2;
242242
let middle_vote = vote_account_pubkeys[middle_index];
@@ -262,7 +262,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
262262
&transient_stake_address,
263263
)
264264
.await;
265-
assert!(error.is_none());
265+
assert!(error.is_none(), "{:?}", error);
266266

267267
let last_index = max_validators as usize - 1;
268268
let last_vote = vote_account_pubkeys[last_index];
@@ -288,7 +288,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
288288
&transient_stake_address,
289289
)
290290
.await;
291-
assert!(error.is_none());
291+
assert!(error.is_none(), "{:?}", error);
292292

293293
let validator_list = get_account(
294294
&mut context.banks_client,
@@ -330,7 +330,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
330330
false, /* no_merge */
331331
)
332332
.await;
333-
assert!(error.is_none());
333+
assert!(error.is_none(), "{:?}", error);
334334

335335
let mut instructions = vec![instruction::update_validator_list_balance(
336336
&id(),
@@ -355,7 +355,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
355355
.process_transaction(transaction)
356356
.await
357357
.err();
358-
assert!(error.is_none());
358+
assert!(error.is_none(), "{:?}", error);
359359

360360
let mut instructions = vec![instruction::update_validator_list_balance(
361361
&id(),
@@ -380,7 +380,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
380380
.process_transaction(transaction)
381381
.await
382382
.err();
383-
assert!(error.is_none());
383+
assert!(error.is_none(), "{:?}", error);
384384

385385
let error = stake_pool_accounts
386386
.cleanup_removed_validator_entries(
@@ -389,7 +389,7 @@ async fn remove_validator_from_pool(max_validators: u32) {
389389
&context.last_blockhash,
390390
)
391391
.await;
392-
assert!(error.is_none());
392+
assert!(error.is_none(), "{:?}", error);
393393

394394
let validator_list = get_account(
395395
&mut context.banks_client,
@@ -454,7 +454,7 @@ async fn add_validator_to_pool(max_validators: u32) {
454454
None,
455455
)
456456
.await;
457-
assert!(error.is_none());
457+
assert!(error.is_none(), "{:?}", error);
458458

459459
let validator_list = get_account(
460460
&mut context.banks_client,
@@ -531,7 +531,7 @@ async fn set_preferred(max_validators: u32) {
531531
Some(vote_account_address),
532532
)
533533
.await;
534-
assert!(error.is_none());
534+
assert!(error.is_none(), "{:?}", error);
535535
let error = stake_pool_accounts
536536
.set_preferred_validator(
537537
&mut context.banks_client,
@@ -541,7 +541,7 @@ async fn set_preferred(max_validators: u32) {
541541
Some(vote_account_address),
542542
)
543543
.await;
544-
assert!(error.is_none());
544+
assert!(error.is_none(), "{:?}", error);
545545

546546
let stake_pool = get_account(
547547
&mut context.banks_client,
@@ -585,7 +585,7 @@ async fn deposit_stake(max_validators: u32) {
585585
&user,
586586
)
587587
.await;
588-
assert!(error.is_none());
588+
assert!(error.is_none(), "{:?}", error);
589589
}
590590

591591
#[test_case(MAX_POOL_SIZE_WITH_REQUESTED_COMPUTE_UNITS; "compute-budget")]
@@ -613,7 +613,7 @@ async fn withdraw(max_validators: u32) {
613613
&user,
614614
)
615615
.await;
616-
assert!(error.is_none());
616+
assert!(error.is_none(), "{:?}", error);
617617

618618
// Create stake account to withdraw to
619619
let user_stake_recipient = Keypair::new();
@@ -695,5 +695,5 @@ async fn cleanup_all(max_validators: u32) {
695695
&context.last_blockhash,
696696
)
697697
.await;
698-
assert!(error.is_none());
698+
assert!(error.is_none(), "{:?}", error);
699699
}

stake-pool/program/tests/increase.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async fn success(use_additional_instruction: bool) {
113113
use_additional_instruction,
114114
)
115115
.await;
116-
assert!(error.is_none());
116+
assert!(error.is_none(), "{:?}", error);
117117

118118
// Check reserve stake account balance
119119
let reserve_stake_account = get_account(
@@ -298,7 +298,7 @@ async fn fail_twice_diff_seed(use_additional_instruction: bool) {
298298
use_additional_instruction,
299299
)
300300
.await;
301-
assert!(error.is_none());
301+
assert!(error.is_none(), "{:?}", error);
302302

303303
let transient_stake_seed = validator_stake.transient_stake_seed * 100;
304304
let transient_stake_address = find_transient_stake_program_address(
@@ -370,7 +370,7 @@ async fn twice(success: bool, use_additional_first_time: bool, use_additional_se
370370
use_additional_first_time,
371371
)
372372
.await;
373-
assert!(error.is_none());
373+
assert!(error.is_none(), "{:?}", error);
374374

375375
let error = stake_pool_accounts
376376
.increase_validator_stake_either(
@@ -387,7 +387,7 @@ async fn twice(success: bool, use_additional_first_time: bool, use_additional_se
387387
.await;
388388

389389
if success {
390-
assert!(error.is_none());
390+
assert!(error.is_none(), "{:?}", error);
391391
let rent = context.banks_client.get_rent().await.unwrap();
392392
let stake_rent = rent.minimum_balance(std::mem::size_of::<stake::state::StakeState>());
393393
// no ephemeral account
@@ -563,7 +563,7 @@ async fn fail_additional_with_decreasing() {
563563
validator_stake.transient_stake_seed,
564564
)
565565
.await;
566-
assert!(error.is_none());
566+
assert!(error.is_none(), "{:?}", error);
567567

568568
let error = stake_pool_accounts
569569
.increase_validator_stake_either(

stake-pool/program/tests/redelegate.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async fn success() {
176176
destination_validator_stake.transient_stake_seed,
177177
)
178178
.await;
179-
assert!(error.is_none());
179+
assert!(error.is_none(), "{:?}", error);
180180

181181
// Check validator stake account balance
182182
let validator_stake_account = get_account(
@@ -377,7 +377,7 @@ async fn success_with_increasing_stake() {
377377
destination_validator_stake.transient_stake_seed,
378378
)
379379
.await;
380-
assert!(error.is_none());
380+
assert!(error.is_none(), "{:?}", error);
381381

382382
let validator_list = stake_pool_accounts
383383
.get_validator_list(&mut context.banks_client)
@@ -467,7 +467,7 @@ async fn success_with_increasing_stake() {
467467
destination_validator_stake.transient_stake_seed,
468468
)
469469
.await;
470-
assert!(error.is_none());
470+
assert!(error.is_none(), "{:?}", error);
471471

472472
// Check destination transient stake account
473473
let destination_transient_stake_account = get_account(
@@ -624,7 +624,7 @@ async fn fail_with_decreasing_stake() {
624624
destination_validator_stake.transient_stake_seed,
625625
)
626626
.await;
627-
assert!(error.is_none());
627+
assert!(error.is_none(), "{:?}", error);
628628

629629
let ephemeral_stake_seed = 20;
630630
let ephemeral_stake = find_ephemeral_stake_program_address(
@@ -993,7 +993,7 @@ async fn fail_redelegate_twice() {
993993
destination_validator_stake.transient_stake_seed,
994994
)
995995
.await;
996-
assert!(error.is_none());
996+
assert!(error.is_none(), "{:?}", error);
997997

998998
let last_blockhash = context
999999
.banks_client

0 commit comments

Comments
 (0)