@@ -558,3 +558,40 @@ FIXTURE_TEST(test_transaction_start_without_fence, test_fixture) {
558558 another_tx_state->status , partition_transaction_status::ongoing);
559559 BOOST_REQUIRE_EQUAL (another_tx_state->first , another_batch.base_offset ());
560560}
561+
562+ FIXTURE_TEST (test_has_request_for_seq_range, test_fixture) {
563+ create_producer_state_manager (1 , 1 );
564+ auto producer = new_producer ();
565+ auto defer = ss::defer (
566+ [&] { manager ().deregister_producer (*producer, std::nullopt ); });
567+
568+ model::test::record_batch_spec spec{
569+ .offset = model::offset{10 },
570+ .allow_compression = true ,
571+ .count = 5 ,
572+ .bt = model::record_batch_type::raft_data,
573+ .enable_idempotence = true ,
574+ .producer_id = producer->id ().id ,
575+ .producer_epoch = producer->id ().epoch ,
576+ .base_sequence = 0 ,
577+ };
578+ auto batch = model::test::make_random_batch (spec);
579+ auto bid = model::batch_identity::from (batch.header ());
580+ auto request = producer->try_emplace_request (bid, model::term_id{1 }, true );
581+ BOOST_REQUIRE (!request.has_error ());
582+
583+ const auto & reqs = producer->idempotent_request_state ();
584+
585+ // Inflight request with seq range [0, 4] should be found.
586+ BOOST_REQUIRE (reqs.has_request_for_seq_range (0 , 4 ));
587+ // Non-matching ranges should not be found.
588+ BOOST_REQUIRE (!reqs.has_request_for_seq_range (0 , 3 ));
589+ BOOST_REQUIRE (!reqs.has_request_for_seq_range (1 , 4 ));
590+ BOOST_REQUIRE (!reqs.has_request_for_seq_range (5 , 9 ));
591+
592+ // Apply the batch to promote it to finished.
593+ producer->apply_data (batch.header (), kafka::offset{10 });
594+
595+ // Still found after apply - now in finished requests.
596+ BOOST_REQUIRE (reqs.has_request_for_seq_range (0 , 4 ));
597+ }
0 commit comments