anchor.diff:  -include_lib("eunit/include/eunit.hrl").
   -ifdef(TEST).
   encode_message_test() ->	
  -	?assertEqual([{cookie, <<"Cookie">>}, {node, <<"Node">>}, {state, <<"State">>}, {time, <<"Time">>}],decode_message(<<"SEARCH:Cookie:Node:State:Time">>)).
  +	?assertEqual([{valid, false}, {node, <<"Node">>}, {state, <<"State">>}, {time, <<"Time">>}],decode_message(<<"SEARCH:1234567890123456Node:State:Time">>)).
   
   decode_cookie_test() ->
   	crypto:start(),
  
positive.code: 	Cookie =:= encode_cookie(Local_cookie).
  
  get_env(Key) ->
  	{ok, Value} = application:get_env(searcher, multi_port),
  	Value.
  %% --------------------------------------------------------------------
  %%% Test functions
  
negative.code: %% --------------------------------------------------------------------
  %%% Internal functions
  %% --------------------------------------------------------------------
  %% <<"SEARCH:COOKIENODE:STATE:TIME">>
  decode_message(<<_Action:7/binary, Cookie:16/binary, Rest/binary>> = Message) ->	
  	Is_valid_cookie = decode_cookie(Cookie, get_local_cookie()),
  	[Node, R1] = binary:split(Rest,<<":">>),
  	[State, Time] = binary:split(R1,<<":">>),
  	[{valid, Is_valid_cookie},{node, Node}, {state, State}, {time, Time}].
  	
  decode_message(false, _Node, _State, _Time, Ip) ->	
  	error_logger:info_msg("Cookie which was received is not a requested one~n"),
  	ok.
  	
  save_node([{valid, true}, {node, Node}, {state, State}, {time, _Time}, {ip, _Ip}]) ->
  	error_logger:info_msg("save : ~p in state : ~p ~n", [Node, State]);
  	
  save_node([{valid, false}, {node, Node}, {state, State}, {time, _Time}, {ip, _Ip}]) ->
  	error_logger:info_msg("don't save : ~p in state : ~p ~n", [Node, State]).
  	
  get_node_repo() ->
  	Module = get_env(node_repo),
  	Msg = get_env(node_repo_msg),
  	[Module, Msg].
  	
  start_timer() ->
  	erlang:send_after(get_env(timer), self(), send_alive).
  