cleanup some tests (#26139)
This commit is contained in:
parent
29bec3eb54
commit
a32523c43b
|
@ -7805,7 +7805,9 @@ pub(crate) mod tests {
|
|||
MAX_LOCKOUT_HISTORY,
|
||||
},
|
||||
},
|
||||
std::{result, sync::atomic::Ordering::Release, thread::Builder, time::Duration},
|
||||
std::{
|
||||
result, str::FromStr, sync::atomic::Ordering::Release, thread::Builder, time::Duration,
|
||||
},
|
||||
test_utils::goto_end_of_slot,
|
||||
};
|
||||
|
||||
|
@ -9383,10 +9385,11 @@ pub(crate) mod tests {
|
|||
])
|
||||
);
|
||||
let range = Bank::pubkey_range_from_partition((0, 1, max));
|
||||
const ONE: u8 = 0x01;
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ONE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
])
|
||||
|
@ -9397,6 +9400,7 @@ pub(crate) mod tests {
|
|||
])
|
||||
);
|
||||
let range = Bank::pubkey_range_from_partition((max - 3, max - 2, max));
|
||||
const FD: u8 = 0xfd;
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
|
@ -9405,7 +9409,7 @@ pub(crate) mod tests {
|
|||
0x00, 0x00, 0x00, 0x00,
|
||||
])
|
||||
..=Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, FD, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
|
@ -9417,12 +9421,7 @@ pub(crate) mod tests {
|
|||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
])
|
||||
..=Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
])..=pubkey_max_value()
|
||||
);
|
||||
|
||||
fn should_cause_overflow(partition_count: u64) -> bool {
|
||||
|
@ -9442,19 +9441,7 @@ pub(crate) mod tests {
|
|||
|
||||
for max in &[max_exact, max_inexact] {
|
||||
let range = Bank::pubkey_range_from_partition((max - 1, max - 1, *max));
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
..=Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
);
|
||||
assert_eq!(range, pubkey_max_value()..=pubkey_max_value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9490,11 +9477,7 @@ pub(crate) mod tests {
|
|||
let range = Bank::pubkey_range_from_partition((0, 0, 3));
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
])
|
||||
Pubkey::new_from_array([0x00; 32])
|
||||
..=Pubkey::new_from_array([
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x54, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
@ -9504,38 +9487,26 @@ pub(crate) mod tests {
|
|||
let _ = test_map.range(range);
|
||||
|
||||
let range = Bank::pubkey_range_from_partition((1, 1, 3));
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
])
|
||||
..=Pubkey::new_from_array([
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
])
|
||||
);
|
||||
let same = Pubkey::new_from_array([
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
]);
|
||||
assert_eq!(range, same..=same);
|
||||
let _ = test_map.range(range);
|
||||
|
||||
let range = Bank::pubkey_range_from_partition((2, 2, 3));
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
..=Pubkey::new_from_array([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
])
|
||||
);
|
||||
assert_eq!(range, pubkey_max_value()..=pubkey_max_value());
|
||||
let _ = test_map.range(range);
|
||||
}
|
||||
|
||||
fn pubkey_max_value() -> Pubkey {
|
||||
let highest = Pubkey::from_str("JEKNVnkbo3jma5nREBBJCDoXFVeKkD56V3xKrvRmWxFG").unwrap();
|
||||
let arr = Pubkey::new_from_array([0xff; 32]);
|
||||
assert_eq!(highest, arr);
|
||||
arr
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rent_eager_pubkey_range_dividable() {
|
||||
let test_map = map_to_test_bad_range();
|
||||
|
@ -9543,11 +9514,7 @@ pub(crate) mod tests {
|
|||
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
])
|
||||
Pubkey::new_from_array([0x00; 32])
|
||||
..=Pubkey::new_from_array([
|
||||
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
@ -9581,11 +9548,7 @@ pub(crate) mod tests {
|
|||
let range = Bank::pubkey_range_from_partition((0, 0, 3));
|
||||
assert_eq!(
|
||||
range,
|
||||
Pubkey::new_from_array([
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
])
|
||||
Pubkey::new_from_array([0x00; 32])
|
||||
..=Pubkey::new_from_array([
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x54, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
@ -14712,7 +14675,6 @@ pub(crate) mod tests {
|
|||
Maybe, inconsistent program activation is detected on snapshot restore?"
|
||||
)]
|
||||
fn test_add_builtin_account_after_frozen() {
|
||||
use std::str::FromStr;
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||
|
||||
let slot = 123;
|
||||
|
@ -14734,7 +14696,6 @@ pub(crate) mod tests {
|
|||
CiXgo2KHKSDmDnV1F6B69eWFgNAPiSBjjYvfB4cvRNre)."
|
||||
)]
|
||||
fn test_add_builtin_account_replace_none() {
|
||||
use std::str::FromStr;
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||
|
||||
let slot = 123;
|
||||
|
@ -14826,7 +14787,6 @@ pub(crate) mod tests {
|
|||
Maybe, inconsistent program activation is detected on snapshot restore?"
|
||||
)]
|
||||
fn test_add_precompiled_account_after_frozen() {
|
||||
use std::str::FromStr;
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||
|
||||
let slot = 123;
|
||||
|
|
Loading…
Reference in New Issue