Skip to content

Commit a477162

Browse files
committed
compare pubkeys directly to avoid slice eq
1 parent 9755f5a commit a477162

1 file changed

Lines changed: 48 additions & 9 deletions

File tree

program/src/entrypoint-runtime-verification.rs

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,12 @@ fn test_process_initialize_mint_no_freeze(
983983
assert_eq!(get_mint(&accounts[0]).decimals(), instruction_data[0]);
984984

985985
if instruction_data[33] == 1 {
986-
assert_eq!(get_mint(&accounts[0]).freeze_authority().unwrap().as_ref(), &instruction_data[34..66]);
986+
let expected_freeze_authority =
987+
Pubkey::new_from_array(instruction_data[34..66].try_into().unwrap());
988+
assert_eq!(
989+
*get_mint(&accounts[0]).freeze_authority().unwrap(),
990+
expected_freeze_authority
991+
);
987992
}
988993
}
989994

@@ -2344,7 +2349,9 @@ fn test_process_set_authority_account(
23442349
return result;
23452350
}
23462351

2347-
assert_eq!(get_account(&accounts[0]).owner().as_ref(), &instruction_data[2..34]);
2352+
let expected_owner =
2353+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2354+
assert_eq!(get_account(&accounts[0]).owner(), expected_owner);
23482355
assert_eq!(get_account(&accounts[0]).delegate(), None);
23492356
assert_eq!(get_account(&accounts[0]).delegated_amount(), 0);
23502357
if get_account(&accounts[0]).is_native() {
@@ -2363,7 +2370,12 @@ fn test_process_set_authority_account(
23632370
)?;
23642371

23652372
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2366-
assert_eq!(get_account(&accounts[0]).close_authority().unwrap().as_ref(), &instruction_data[2..34]);
2373+
let expected_close_authority =
2374+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2375+
assert_eq!(
2376+
*get_account(&accounts[0]).close_authority().unwrap(),
2377+
expected_close_authority
2378+
);
23672379
} else {
23682380
assert_eq!(get_account(&accounts[0]).close_authority(), None);
23692381
}
@@ -2469,7 +2481,9 @@ fn test_process_set_authority_account_multisig(
24692481
return result;
24702482
}
24712483

2472-
assert_eq!(get_account(&accounts[0]).owner().as_ref(), &instruction_data[2..34]);
2484+
let expected_owner =
2485+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2486+
assert_eq!(get_account(&accounts[0]).owner(), expected_owner);
24732487
assert_eq!(get_account(&accounts[0]).delegate(), None);
24742488
assert_eq!(get_account(&accounts[0]).delegated_amount(), 0);
24752489
if get_account(&accounts[0]).is_native() {
@@ -2488,7 +2502,12 @@ fn test_process_set_authority_account_multisig(
24882502
)?;
24892503

24902504
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2491-
assert_eq!(get_account(&accounts[0]).close_authority().unwrap().as_ref(), &instruction_data[2..34]);
2505+
let expected_close_authority =
2506+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2507+
assert_eq!(
2508+
*get_account(&accounts[0]).close_authority().unwrap(),
2509+
expected_close_authority
2510+
);
24922511
} else {
24932512
assert_eq!(get_account(&accounts[0]).close_authority(), None);
24942513
}
@@ -2584,7 +2603,12 @@ fn test_process_set_authority_mint(
25842603
)?;
25852604

25862605
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2587-
assert_eq!(get_mint(&accounts[0]).mint_authority().unwrap().as_ref(), &instruction_data[2..34]);
2606+
let expected_mint_authority =
2607+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2608+
assert_eq!(
2609+
*get_mint(&accounts[0]).mint_authority().unwrap(),
2610+
expected_mint_authority
2611+
);
25882612
} else {
25892613
assert_eq!(get_mint(&accounts[0]).mint_authority(), None);
25902614
}
@@ -2604,7 +2628,12 @@ fn test_process_set_authority_mint(
26042628
)?;
26052629

26062630
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2607-
assert_eq!(get_mint(&accounts[0]).freeze_authority().unwrap().as_ref(), &instruction_data[2..34]);
2631+
let expected_freeze_authority =
2632+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2633+
assert_eq!(
2634+
*get_mint(&accounts[0]).freeze_authority().unwrap(),
2635+
expected_freeze_authority
2636+
);
26082637
} else {
26092638
assert_eq!(get_mint(&accounts[0]).freeze_authority(), None);
26102639
}
@@ -2700,7 +2729,12 @@ fn test_process_set_authority_mint_multisig(
27002729
)?;
27012730

27022731
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2703-
assert_eq!(get_mint(&accounts[0]).mint_authority().unwrap().as_ref(), &instruction_data[2..34]);
2732+
let expected_mint_authority =
2733+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2734+
assert_eq!(
2735+
*get_mint(&accounts[0]).mint_authority().unwrap(),
2736+
expected_mint_authority
2737+
);
27042738
} else {
27052739
assert_eq!(get_mint(&accounts[0]).mint_authority(), None);
27062740
}
@@ -2720,7 +2754,12 @@ fn test_process_set_authority_mint_multisig(
27202754
)?;
27212755

27222756
if instruction_data[1] == 1 { // 1 ==> 34 <= instruction_data.len()
2723-
assert_eq!(get_mint(&accounts[0]).freeze_authority().unwrap().as_ref(), &instruction_data[2..34]);
2757+
let expected_freeze_authority =
2758+
Pubkey::new_from_array(instruction_data[2..34].try_into().unwrap());
2759+
assert_eq!(
2760+
*get_mint(&accounts[0]).freeze_authority().unwrap(),
2761+
expected_freeze_authority
2762+
);
27242763
} else {
27252764
assert_eq!(get_mint(&accounts[0]).freeze_authority(), None);
27262765
}

0 commit comments

Comments
 (0)