private void doInitTransactions(TransactionManager transactionManager, ProducerIdAndEpoch producerIdAndEpoch) {
        TransactionalRequestResult result = transactionManager.initializeTransactions();
        prepareFindCoordinatorResponse(Errors.NONE, transactionManager.transactionalId());
        sender.runOnce();
        sender.runOnce();

        prepareInitProducerResponse(Errors.NONE, producerIdAndEpoch.producerId, producerIdAndEpoch.epoch);
        sender.runOnce();
        assertTrue(transactionManager.hasProducerId());
        result.await();
    }
It creates response with new leader info and new nodes, as stated in KIP-951
clients/src/test/java/org/apache/kafka/clients/producer/internals/SenderTest.java