From 3f488bdc94c3037ff37d63c1a3b06aa7d7eab59c Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Mon, 30 Dec 2024 18:58:50 -0600 Subject: [PATCH] test_schedulable_threads --- .../prio_graph_scheduler.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs b/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs index e429182738b083..9256d26c3ac5c9 100644 --- a/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs +++ b/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs @@ -928,4 +928,23 @@ mod tests { assert_eq!(scheduling_summary.num_unschedulable, 0); assert_eq!(collect_work(&work_receivers[0]).1, vec![vec![2], vec![0]]); } + + #[test] + fn test_schedulable_threads() { + let (mut scheduler, _work_receivers, _finished_work_sender) = create_test_frame(2); + scheduler.config.max_scheduled_cus = 2; // only allow 1 tx per thread + let pubkey = Pubkey::new_unique(); + let keypair = Keypair::new(); + let mut container = create_container([ + (&Keypair::new(), &[pubkey], 1, 1), + (&keypair, &[pubkey], 1, 2), + (&Keypair::new(), &[Pubkey::new_unique()], 1, 3), + ]); + + let scheduling_summary = scheduler + .schedule(&mut container, test_pre_graph_filter, test_pre_lock_filter) + .unwrap(); + assert_eq!(scheduling_summary.num_scheduled, 2); + assert_eq!(scheduling_summary.num_unschedulable, 1); + } }