Skip to content

Commit

Permalink
Use abort_on_panic() in context-aware tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Nov 27, 2023
1 parent 1c137c2 commit b993b36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions core/lib/zksync_core/src/sync_layer/gossip/buffered/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use zksync_concurrency::{
ctx::{self, channel},
scope,
sync::{self, watch},
testonly::abort_on_panic,
time,
};
use zksync_consensus_roles::validator::{BlockHeader, BlockNumber, FinalBlock, Payload};
Expand Down Expand Up @@ -131,6 +132,7 @@ async fn test_buffered_storage(
block_interval: time::Duration,
shuffle_blocks: impl FnOnce(&mut StdRng, &mut [FinalBlock]),
) {
abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);
let rng = &mut ctx.rng();

Expand Down
9 changes: 8 additions & 1 deletion core/lib/zksync_core/src/sync_layer/gossip/storage/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use rand::{thread_rng, Rng};

use zksync_concurrency::scope;
use zksync_concurrency::{scope, testonly::abort_on_panic};
use zksync_consensus_roles::validator;
use zksync_types::L2ChainId;

Expand All @@ -23,6 +23,7 @@ const TEST_TIMEOUT: time::Duration = time::Duration::seconds(10);

#[tokio::test]
async fn block_store_basics_for_postgres() {
abort_on_panic();
let pool = ConnectionPool::test_pool().await;
run_state_keeper_with_multiple_miniblocks(pool.clone()).await;

Expand Down Expand Up @@ -58,6 +59,7 @@ async fn block_store_basics_for_postgres() {

#[tokio::test]
async fn subscribing_to_block_updates_for_postgres() {
abort_on_panic();
let pool = ConnectionPool::test_pool().await;
let mut storage = pool.access_storage().await.unwrap();
if storage.blocks_dal().is_genesis_needed().await.unwrap() {
Expand Down Expand Up @@ -101,6 +103,7 @@ async fn subscribing_to_block_updates_for_postgres() {

#[tokio::test]
async fn processing_new_blocks() {
abort_on_panic();
let pool = ConnectionPool::test_pool().await;
run_state_keeper_with_multiple_miniblocks(pool.clone()).await;

Expand Down Expand Up @@ -144,6 +147,7 @@ async fn processing_new_blocks() {

#[tokio::test]
async fn ensuring_consensus_fields_for_genesis_block() {
abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);
let pool = ConnectionPool::test_pool().await;
let mut storage = pool.access_storage().await.unwrap();
Expand Down Expand Up @@ -202,6 +206,7 @@ async fn ensuring_consensus_fields_for_genesis_block() {

#[tokio::test]
async fn genesis_block_payload_mismatch() {
abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);
let pool = ConnectionPool::test_pool().await;
let mut storage = pool.access_storage().await.unwrap();
Expand Down Expand Up @@ -240,6 +245,7 @@ async fn genesis_block_payload_mismatch() {

#[tokio::test]
async fn missing_genesis_block() {
abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);
let pool = ConnectionPool::test_pool().await;
let mut storage = pool.access_storage().await.unwrap();
Expand All @@ -264,6 +270,7 @@ async fn missing_genesis_block() {

#[tokio::test]
async fn using_non_zero_genesis_block() {
abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);
let pool = ConnectionPool::test_pool().await;
run_state_keeper_with_multiple_miniblocks(pool.clone()).await;
Expand Down
8 changes: 4 additions & 4 deletions core/lib/zksync_core/src/sync_layer/gossip/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use test_casing::{test_casing, Product};

use std::ops;

use zksync_concurrency::{ctx, scope, time};
use zksync_concurrency::{ctx, scope, testonly::abort_on_panic, time};
use zksync_consensus_executor::testonly::FullValidatorConfig;
use zksync_consensus_roles::validator::{self, FinalBlock};
use zksync_consensus_storage::{InMemoryStorage, WriteBlockStore};
Expand Down Expand Up @@ -177,7 +177,7 @@ pub(super) async fn assert_second_block_actions(actions: &mut ActionQueue) -> Ve
#[test_casing(4, Product(([false, true], [false, true])))]
#[tokio::test]
async fn syncing_via_gossip_fetcher(delay_first_block: bool, delay_second_block: bool) {
zksync_concurrency::testonly::abort_on_panic();
abort_on_panic();
let pool = ConnectionPool::test_pool().await;
let tx_hashes = run_state_keeper_with_multiple_miniblocks(pool.clone()).await;

Expand Down Expand Up @@ -302,7 +302,7 @@ async fn reset_storage(mut storage: StorageProcessor<'_>) -> Vec<SyncBlock> {
#[tokio::test]
async fn syncing_via_gossip_fetcher_with_multiple_l1_batches(initial_block_count: usize) {
assert!(initial_block_count <= 3);
zksync_concurrency::testonly::abort_on_panic();
abort_on_panic();

let pool = ConnectionPool::test_pool().await;
let tx_hashes = run_state_keeper_with_multiple_l1_batches(pool.clone()).await;
Expand Down Expand Up @@ -377,7 +377,7 @@ async fn syncing_via_gossip_fetcher_with_multiple_l1_batches(initial_block_count
#[test_casing(2, [1, 2])]
#[tokio::test]
async fn syncing_from_non_zero_block(first_block_number: u32) {
zksync_concurrency::testonly::abort_on_panic();
abort_on_panic();
let pool = ConnectionPool::test_pool().await;
let tx_hashes = run_state_keeper_with_multiple_l1_batches(pool.clone()).await;
let tx_hashes: Vec<_> = tx_hashes.iter().map(Vec::as_slice).collect();
Expand Down

0 comments on commit b993b36

Please sign in to comment.