anchor.diff:          binary_to_integer(LastSeqInDb)
       end).
   
  --define(TIMEOUT, timer:seconds(30)).
  +-define(TIMEOUT, timer:seconds(10)).
   
   %% export for ct
   -export([all/0, init_per_suite/1, end_per_suite/1, init_per_testcase/2, end_per_testcase/2]).
  
positive.code:             lists:usort(Received)
      end.
  
  %% Clean mailbox
  flush() ->
      receive
          _ ->
  
negative.code: %%% Internal functions
  %%%===================================================================
  
  %% Saves docs for given value, model and range of keys
  save_docs(Worker, Value, Model, FirstKey, LastKey) ->
      lists:map(
          fun(Key) ->
              Doc = #document{key = Key, value = Value},
              ?assertEqual({ok, Key}, rpc:call(Worker, Model, save, [Doc])),
              {Key, Value, Model}
          end,
          lists:seq(FirstKey, LastKey)
      ).
  
  %% Receives all messages with given prefix
  receive_all(Prefix, Received) ->
      receive
          {Prefix, {_, stream_ended, _}} ->
              lists:usort(Received);
          {Prefix, Data} ->
              receive_all(Prefix, [Data | Received])
      after
  