anchor.diff:    State1 = State0#state{pending = [{L1, 2}]},
     ?assertEqual({ok, State1}, maybe_send(L1, State1)),
     L2 = erlang:list_to_pid("<0.0.2>"),
  -  FromBuffer = dict:store(L2, [d], dict:store(L1, [a, b, c], dict:new())),
  +  SendersBuffer = dict:store(L2, [d], dict:store(L1, [a, b, c], dict:new())),
     State2 = State0#state{ data_buffer = [{L1, foo}, {L2, bar}]
  -                       , from_buffer = FromBuffer},
  +                       , senders_buffer = SendersBuffer},
     ExpectedState = #state{ data_buffer = [{L2, bar}]
  -                        , from_buffer = dict:erase(L1, FromBuffer)
  +                        , senders_buffer = dict:erase(L1, SendersBuffer)
                           , pending = [{L1, {1, [a, b, c]}}]},
     ?assertEqual({ok, ExpectedState}, maybe_send(L1, State2)),
     ok.
  
positive.code:   {stop, normal, ok, State};
  handle_call(get_sockets, _From, State) ->
    {reply, {ok, State#state.sockets}, State};
  handle_call(Request, _From, State) ->
    {reply, {error, {unsupported_call, Request}}, State}.
  
  handle_cast(_Msg, State) ->
    {noreply, State}.
  
  handle_info({produce, From, Topic, Partition, KVList}, State0) ->
    case handle_produce(From, Topic, Partition, KVList, State0) of
      {ok, Leader, State1} ->
        {ok, State} = maybe_send(Leader, State1),
        {noreply, State};
      {error, Error} ->
        {Pid, Ref} = From,
        Pid ! {{Ref, self()}, {error, Error}},
        {noreply, State0}
    end;
  handle_info({msg, Leader, CorrId, #produce_response{}}, State0) ->
    {value, {_, {CorrId, FromList}}, Pending} =
      lists:keytake(Leader, 1, State0#state.pending),
    lists:foreach(fun({Pid, Ref}) ->
                      Pid ! {{Ref, self()}, ack}
                  end, FromList),
    {ok, State} = maybe_send(Leader, State0#state{pending = Pending}),
    {noreply, State};
  handle_info({'EXIT', Pid, Reason}, State) ->
  
negative.code:   H1 = {"h1", 2181},
    State0 = #state{hosts = [H1]},
    Error0 = {error, {unknown_topic, T0}},
    ?assertEqual(Error0, handle_produce(pid, ref, T0, p0, [{k0, v0}], State0)),
  
    S1 = s1,
    R1 = r1,
    L1 = 1,
    T1 = t1,
    P1 = p1,
    K1 = k1,
    V1 = v1,
    Leaders0 = [{{T1, P1}, L1}],
    SendersBuffer1 = dict:store(L1, [{s1, r1}], dict:new()),
    TopicBuffer1 = dict:store(P1, [{K1, V1}], dict:new()),
    DataBuffer1 = [{L1, [{T1, TopicBuffer1}]}],
    State1 = #state{leaders = Leaders0},
    {ok, L1, State2} = handle_produce(S1, R1, T1, P1, [{K1, V1}], State1),
    ?assertEqual(Leaders0, State2#state.leaders),
    ?assertEqual(SendersBuffer1, State2#state.senders_buffer),
    ?assertEqual(DataBuffer1, State2#state.data_buffer),
  
    K2 = k2,
    V2 = v2,
    TopicBuffer2 = dict:append(P1, {K2, V2}, TopicBuffer1),
    DataBuffer2 = [{L1, [{T1, TopicBuffer2}]}],
    SendersBuffer2 = dict:append(L1, {S1, R1}, State2#state.senders_buffer),
    {ok, L1, State3} = handle_produce(S1, R1, T1, P1, [{K2, V2}], State2),
    ?assertEqual(Leaders0, State2#state.leaders),
    ?assertEqual(SendersBuffer2, State3#state.senders_buffer),
    ?assertEqual(DataBuffer2, State3#state.data_buffer),
  
    S2 = s2,
    R2 = r2,
    L2 = 2,
    P2 = p2,
    K3 = k3,
    V3 = v3,
    SendersBuffer3 = dict:append(L2, {S2, R2}, State3#state.senders_buffer),
    Leaders1 = [{{T1, P2}, L2} | Leaders0],
    State4 = State3#state{leaders = Leaders1},
    TopicBuffer3 = dict:append(P2, {K3, V3}, dict:new()),
    %% ++ due to lists:keystore/4 behaviour
    DataBuffer3 = State4#state.data_buffer ++ [{L2, [{T1, TopicBuffer3}]}],
    {ok, L2, State5} = handle_produce(S2, R2, T1, P2, [{K3, V3}], State4),
    ?assertEqual(Leaders1, State5#state.leaders),
    ?assertEqual(SendersBuffer3, State5#state.senders_buffer),
    ?assertEqual(DataBuffer3, State5#state.data_buffer),
  
    T2 = t2,
    S3 = s3,
    R3 = r3,
    K4 = k4,
    V4 = v4,
    SendersBuffer5 = dict:append(L1, {S3, R3}, State5#state.senders_buffer),
    Leaders2 = [{{T2, P1}, L1} | Leaders1],
    State6 = State5#state{leaders = Leaders2},
    Topic2Buffer = dict:append(P1, {K4, V4}, dict:new()),
  