Skip to content

Commit a11dcf9

Browse files
authored
feat: add proper assert for rust tests (#459)
* add proper assert for rust tests * Update test.rs
1 parent b697acb commit a11dcf9

File tree

14 files changed

+29
-28
lines changed
  • basics
    • account-data/native/program/tests
    • checking-accounts/native/program/tests
    • close-account/native/program/tests
    • counter/native/program/tests
    • create-account/native/program/tests
    • cross-program-invocation/native/programs/hand/tests
    • favorites/native/program/tests
    • pda-rent-payer/native/program/tests
    • processing-instructions/native/program/tests
    • program-derived-addresses/native/program/tests
    • realloc/native/program/tests
    • rent/native/program/tests
    • repository-layout/native/program/tests
    • transfer-sol/native/program/tests

14 files changed

+29
-28
lines changed

basics/account-data/native/program/tests/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn test_account_data() {
4949
svm.latest_blockhash(),
5050
);
5151

52-
svm.send_transaction(tx).unwrap();
52+
assert!(svm.send_transaction(tx).is_ok());
5353

5454
let address_info_account_data = &svm
5555
.get_account(&address_info_account.pubkey())

basics/checking-accounts/native/program/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn test_checking_accounts() {
3636
);
3737

3838
// verify tx was sent successfully
39-
let _ = svm.send_transaction(tx).is_ok();
39+
assert!(svm.send_transaction(tx).is_ok());
4040

4141
let ix = Instruction {
4242
program_id,
@@ -57,5 +57,5 @@ fn test_checking_accounts() {
5757
);
5858

5959
// verify tx was sent successfully
60-
let _ = svm.send_transaction(tx).is_ok();
60+
assert!(svm.send_transaction(tx).is_ok());
6161
}

basics/close-account/native/program/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_close_account() {
4646
svm.latest_blockhash(),
4747
);
4848

49-
let _ = svm.send_transaction(tx).is_ok();
49+
assert!(svm.send_transaction(tx).is_ok());
5050

5151
// clsose user ix
5252
let data = borsh::to_vec(&MyInstruction::CloseUser).unwrap();
@@ -68,5 +68,5 @@ fn test_close_account() {
6868
svm.latest_blockhash(),
6969
);
7070

71-
let _ = svm.send_transaction(tx).is_ok();
71+
assert!(svm.send_transaction(tx).is_ok());
7272
}

basics/counter/native/program/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn test_counter() {
3838
&[&payer, &counter_account],
3939
svm.latest_blockhash(),
4040
);
41-
svm.send_transaction(tx).unwrap();
41+
assert!(svm.send_transaction(tx).is_ok());
4242

4343
let ix = Instruction {
4444
program_id,

basics/create-account/native/program/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ fn test_create_account() {
3434
svm.latest_blockhash(),
3535
);
3636

37-
let _ = svm.send_transaction(tx).is_ok();
37+
assert!(svm.send_transaction(tx).is_ok());
3838
}

basics/cross-program-invocation/native/programs/hand/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_cpi() {
4646
svm.latest_blockhash(),
4747
);
4848

49-
let _ = svm.send_transaction(tx).is_ok();
49+
assert!(svm.send_transaction(tx).is_ok());
5050

5151
let data = borsh::to_vec(&SetPowerStatus {
5252
name: "Chris".to_string(),
@@ -69,5 +69,5 @@ fn test_cpi() {
6969
svm.latest_blockhash(),
7070
);
7171

72-
let _ = svm.send_transaction(tx).is_ok();
72+
assert!(svm.send_transaction(tx).is_ok());
7373
}

basics/favorites/native/program/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test_favorites() {
5151
svm.latest_blockhash(),
5252
);
5353

54-
let _ = svm.send_transaction(tx).is_ok();
54+
assert!(svm.send_transaction(tx).is_ok());
5555

5656
let favorites_account_data = svm.get_account(&favorites_pda).unwrap().data;
5757

@@ -79,5 +79,5 @@ fn test_favorites() {
7979
svm.latest_blockhash(),
8080
);
8181

82-
let _ = svm.send_transaction(tx).is_ok();
82+
assert!(svm.send_transaction(tx).is_ok());
8383
}

basics/pda-rent-payer/native/program/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn test_pda_rent_payer() {
4343
svm.latest_blockhash(),
4444
);
4545

46-
let _ = svm.send_transaction(tx).is_ok();
46+
assert!(svm.send_transaction(tx).is_ok());
4747

4848
let new_account = Keypair::new();
4949

@@ -66,5 +66,5 @@ fn test_pda_rent_payer() {
6666
svm.latest_blockhash(),
6767
);
6868

69-
let _ = svm.send_transaction(tx).is_ok();
69+
assert!(svm.send_transaction(tx).is_ok());
7070
}

basics/processing-instructions/native/program/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ fn test_processing_ixs() {
4747
svm.latest_blockhash(),
4848
);
4949

50-
let _ = svm.send_transaction(tx).is_ok();
50+
assert!(svm.send_transaction(tx).is_ok());
5151
}

basics/program-derived-addresses/native/program/tests/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test_pda() {
4040
svm.latest_blockhash(),
4141
);
4242

43-
let _ = svm.send_transaction(tx).is_ok();
43+
assert!(svm.send_transaction(tx).is_ok());
4444

4545
let (pda, bump) =
4646
Pubkey::find_program_address(&[b"page_visits", test_user.pubkey().as_ref()], &program_id);
@@ -69,7 +69,7 @@ fn test_pda() {
6969
svm.latest_blockhash(),
7070
);
7171

72-
let _ = svm.send_transaction(tx).is_ok();
72+
assert!(svm.send_transaction(tx).is_ok());
7373

7474
let data = borsh::to_vec(&IncrementPageVisits {}).unwrap();
7575

@@ -89,7 +89,7 @@ fn test_pda() {
8989
svm.latest_blockhash(),
9090
);
9191

92-
let _ = svm.send_transaction(tx).is_ok();
92+
assert!(svm.send_transaction(tx).is_ok());
9393

9494
// read page visits
9595
let account_info = svm.get_account(&pda).unwrap();

0 commit comments

Comments
 (0)