Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make should_panic tests compatible with 1.73+ panic format #33099

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.no_shrink_in_progress()")]
#[should_panic(expected = "self.no_shrink_in_progress()")]
fn test_get_slot_storage_entry_fail() {
let storage = AccountStorage::default();
storage
Expand All @@ -362,7 +362,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.no_shrink_in_progress()")]
#[should_panic(expected = "self.no_shrink_in_progress()")]
fn test_all_slots_fail() {
let storage = AccountStorage::default();
storage
Expand All @@ -372,7 +372,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.no_shrink_in_progress()")]
#[should_panic(expected = "self.no_shrink_in_progress()")]
fn test_initialize_fail() {
let mut storage = AccountStorage::default();
storage
Expand All @@ -382,9 +382,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(
expected = "assertion failed: shrink_can_be_active || self.shrink_in_progress_map.is_empty()"
)]
#[should_panic(expected = "shrink_can_be_active || self.shrink_in_progress_map.is_empty()")]
fn test_remove_fail() {
let storage = AccountStorage::default();
storage
Expand All @@ -394,7 +392,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.no_shrink_in_progress()")]
#[should_panic(expected = "self.no_shrink_in_progress()")]
fn test_iter_fail() {
let storage = AccountStorage::default();
storage
Expand All @@ -404,7 +402,7 @@ pub(crate) mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.no_shrink_in_progress()")]
#[should_panic(expected = "self.no_shrink_in_progress()")]
fn test_insert_fail() {
let storage = AccountStorage::default();
let sample = storage.get_test_storage();
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17764,7 +17764,7 @@ pub mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: self.storage.remove")]
#[should_panic(expected = "self.storage.remove")]
fn test_handle_dropped_roots_for_ancient_assert() {
solana_logger::setup();
let common_store_path = Path::new("");
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ pub mod tests {

#[test]
#[should_panic(
expected = "assertion failed: accounts_to_combine.target_slots_sorted.len() >= packed_contents.len()"
expected = "accounts_to_combine.target_slots_sorted.len() >= packed_contents.len()"
)]
fn test_write_packed_storages_too_few_slots() {
let (db, storages, slots, _infos) = get_sample_storages(1, None);
Expand Down
14 changes: 10 additions & 4 deletions accounts-db/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ pub mod tests {
static_assertions::assert_eq_align!(u64, StoredMeta, AccountMeta);

#[test]
#[should_panic(expected = "assertion failed: accounts.has_hash_and_write_version()")]
#[should_panic(expected = "accounts.has_hash_and_write_version()")]
fn test_storable_accounts_with_hashes_and_write_versions_new() {
let account = AccountSharedData::default();
// for (Slot, &'a [(&'a Pubkey, &'a T)], IncludeSlotInHash)
Expand Down Expand Up @@ -765,19 +765,25 @@ pub mod tests {
}

#[test]
#[should_panic(expected = "assertion failed:")]
// rust 1.73+ (our as-of-writing nightly version) changed panic message. we're stuck with this
// short common substring until the monorepo is fully 1.73+ including stable.
#[should_panic(expected = "left == right")]
fn test_storable_accounts_with_hashes_and_write_versions_new2() {
test_mismatch(false, false);
}

#[test]
#[should_panic(expected = "assertion failed:")]
// rust 1.73+ (our as-of-writing nightly version) changed panic message. we're stuck with this
// short common substring until the monorepo is fully 1.73+ including stable.
#[should_panic(expected = "left == right")]
fn test_storable_accounts_with_hashes_and_write_versions_new3() {
test_mismatch(false, true);
}

#[test]
#[should_panic(expected = "assertion failed:")]
// rust 1.73+ (our as-of-writing nightly version) changed panic message. we're stuck with this
// short common substring until the monorepo is fully 1.73+ including stable.
#[should_panic(expected = "left == right")]
fn test_storable_accounts_with_hashes_and_write_versions_new4() {
test_mismatch(true, false);
}
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/rolling_bit_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,13 @@ pub mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: max_width.is_power_of_two()")]
#[should_panic(expected = "max_width.is_power_of_two()")]
fn test_bitfield_power_2() {
let _ = RollingBitField::new(3);
}

#[test]
#[should_panic(expected = "assertion failed: max_width > 0")]
#[should_panic(expected = "max_width > 0")]
fn test_bitfield_0() {
let _ = RollingBitField::new(0);
}
Expand Down
2 changes: 1 addition & 1 deletion entry/src/poh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mod tests {
}

#[test]
#[should_panic(expected = "assertion failed: hashes_per_tick > 1")]
#[should_panic(expected = "hashes_per_tick > 1")]
fn test_target_poh_time_hashes_per_tick() {
let zero = Hash::default();
let poh = Poh::new(zero, Some(0));
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3585,7 +3585,7 @@ fn test_bank_hash_internal_state_verify() {
}

#[test]
#[should_panic(expected = "assertion failed: self.is_frozen()")]
#[should_panic(expected = "self.is_frozen()")]
fn test_verify_hash_unfrozen() {
let bank = create_simple_test_bank(2_000);
assert!(bank.verify_hash());
Expand Down Expand Up @@ -12459,7 +12459,7 @@ fn test_distribute_partitioned_epoch_rewards() {
}

#[test]
#[should_panic(expected = "assertion failed: self.epoch_schedule.get_slots_in_epoch")]
#[should_panic(expected = "self.epoch_schedule.get_slots_in_epoch")]
fn test_distribute_partitioned_epoch_rewards_too_many_partitions() {
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);
let mut bank = Bank::new_for_tests(&genesis_config);
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/epoch_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod tests {

#[test]
#[should_panic(
expected = "assertion failed: self.distributed_rewards.saturating_add(amount) <= self.total_rewards"
expected = "self.distributed_rewards.saturating_add(amount) <= self.total_rewards"
)]
fn test_epoch_rewards_distribute_panic() {
let mut epoch_rewards = EpochRewards::new(100, 0, 64);
Expand Down