anchor.diff:      {PidsToKill, Pids1} = lists:split(3, Pids10),
   
       ?assertEqual(ok, rpc(Socket1, pg, join, [?FUNCTION_NAME, ?FUNCTION_NAME, Pids10])),
  -    sync({?FUNCTION_NAME, Peer1}),
  +    sync({?FUNCTION_NAME, Peer1}), %% Join broadcast have reached local
  +    sync(?FUNCTION_NAME), %% Join broadcast has been processed by local
       ?assertEqual(lists:sort(Pids10), lists:sort(pg:get_members(?FUNCTION_NAME, ?FUNCTION_NAME))),
       [rpc(Socket1, ?MODULE, stop_proc, [Pid]) || Pid <- PidsToKill],
       sync(?FUNCTION_NAME),
  
positive.code:     Pids = lists:sort(Pids1 ++ Pids2 ++ Pids11),
      ?assert(lists:all(fun erlang:is_pid/1, Pids)),
  
      net_kernel:disconnect(Peer1),
      net_kernel:disconnect(Peer2),
  
      sync(?FUNCTION_NAME),
      ?assertEqual([], lists:sort(pg:get_members(?FUNCTION_NAME, ?FUNCTION_NAME))),
  
      [?assertEqual(ok, rpc(Socket2, pg, join, [?FUNCTION_NAME, ?FUNCTION_NAME, Pid])) || Pid <- Pids2],
  
negative.code: 
  sync(GS) ->
      _ = sys:log(GS, get).
  
  ensure_peers_info(Scope, Peers) ->
      %% Ensures that pg server on local node has gotten info from
      %% pg servers on all Peer nodes passed as argument (assuming
      %% no connection failures).
      %% 
      %% This function assumes that all nodeup messages has been
      %% delivered to all local recipients (pg server) when called.
      %%
      %% Note that this relies on current ERTS implementation; not
      %% language guarantees.
      %%
  
      sync(Scope),
      %% Known: nodup handled and discover sent to Peer
  
      lists:foreach(fun (Peer) -> sync({Scope, Peer}) end, Peers),
      %% Known: nodeup handled by Peers and discover sent to local
      %% Known: discover received/handled by Peers and sync sent to local
      %% Known: discover received from Peer
      %% Known: sync received from Peer
  
      sync(Scope),
      %% Known: discover handled from Peers and sync sent to Peers
      %% Known: sync from Peers handled
      ok.
  
  -ifdef(CURRENTLY_UNUSED_BUT_SERVES_AS_DOC).
  
  ensure_synced(Scope, Peers) ->
      %% Ensures that the pg server on local node have synced
      %% with pg servers on all Peer nodes (assuming no connection
      %% failures).
      %% 
      %% This function assumes that all nodeup messages has been
      %% delivered to all local recipients (pg server) when called.
      %%
      %% Note that this relies on current ERTS implementation; not
      %% language guarantees.
      %%
      ensure_peer_info(Scope, Peer),
      %% Known: local has gotten info from all Peers
      %% Known: discover from Peers handled and sync sent to Peers
      lists:foreach(fun (Peer) -> sync({Scope, Peer}) end, Peers),
      %% Known: sync from local handled by Peers
      ok.
  
  -endif.
  
  disconnect_nodes(Nodes) ->
      %% The following is not a language guarantee, but internal
      %% knowledged about current implementation of ERTS and pg.
      %%
      %% The pg server reacts on 'DOWN's via process monitors of
      %% its peers. These are delivered before 'nodedown's from
      %% net_kernel:monitor_nodes(). That is, by waiting for
      %% 'nodedown' from net_kernel:monitor_nodes() we know that
      %% the 'DOWN' has been delivered to the pg server.
      %%
      %% We do this in a separate process to avoid stray
      %% nodeup/nodedown messages in the test process after
      %% the operation...
      F = fun () ->
                  ok = net_kernel:monitor_nodes(true),
                  lists:foreach(fun (Node) ->
                                        true = erlang:disconnect_node(Node)
                                end,
                                Nodes),
                  lists:foreach(fun (Node) ->
                                        receive {nodedown, Node} -> ok end
                                end,
                                Nodes)
          end,
      {Pid, Mon} = spawn_monitor(F),
      receive
          {'DOWN', Mon, process, Pid, Reason} ->
              normal = Reason
      end,
      ok.
  
  -define (LOCALHOST, {127, 0, 0, 1}).
  
  