anchor.diff:  % versioning information it will be much easier to resolve which
   % node's view for any given object is newer.
   %
  -% See the code of test_merkle/0 for trivial example usage.
  +% See the code of merkle_test/0 for trivial example usage.
   %
   % Application usage note: the 'crypto' OTP application must be started
   % before any of this module's functions will work.
  
positive.code: %% limitations under the License.
  
  -module(merkerl).
  -export([insert/2,delete/2,build_tree/1,diff/2,test_merkle/0,allkeys/1]).
  
  % TODO: fix doc, userdata is the ONLY user-exposed key
  -record(merk, {nodetype,           % atom: expected values are 'leaf' or 'inner'
  
negative.code: sha(X) ->
      crypto:sha(term_to_binary(X)).
  
  % @spec merkle_test() -> bool()
  % @doc A test function and example code.
  %
  % This should be changed into a proper unit test suite.
  merkle_test() ->
      case lists:keymember(crypto, 1, application:loaded_applications()) of
          true  -> ok;
          false -> ok = application:start(crypto)
      end,
      A = [{one,"one data"},{two,"two data"},{three,"three data"},
  	 {four,"four data"},{five,"five data"}],
      B = [{one,"one data"},{two,"other two"},{three,"three data"},
  	 {four,"other four"},{five,"five data"}],
      A2 = build_tree(A),
      B2 = build_tree(B),
      ?assertEqual(lists:usort([two, four]), diff(A2,B2)),
      C = [{one,"one data"}],
      C2 = build_tree(C),
      ?assertEqual(lists:usort([two, three, four, five]), diff(A2,C2)),
      D = insert({four, sha("changed!")}, A2),
      ?assertEqual([four], diff(A2,D)),
      E = insert({five, sha("changed more!")}, D),
      ?assertEqual([five], diff(D,E)),
      ?assertEqual(lists:usort([four, five]), diff(A2,E)),
      F = delete(five,D),
      G = delete(five,E),
      ?assertEqual([], diff(F,G)),
      H = delete(two,A2),
      ?assertEqual([two], diff(A2,H)),
      ?assertEqual([one], diff(C2,undefined)),
      STree1 = build_tree([{"hello", "hi"},{"and", "what"}]),
      STree2 = build_tree([{"hello", "hi"},{"goodbye", "bye"}]),
      ?assertEqual(lists:usort(["and", "goodbye"]), diff(STree1, STree2)).
  
  
  