Skip to content

Commit

Permalink
Dominates should not take timestamp into account.
Browse files Browse the repository at this point in the history
Ensure that dominates does not take the timestamp into account; two
concurrent puts happening one second apart should not be considered
related.
  • Loading branch information
cmeiklejohn authored and reiddraper committed Jan 23, 2014
1 parent 8e860ec commit 67c24ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vclock.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ descends_dot(Vclock, Dot) ->

-spec dominates(vclock(), vclock()) -> boolean().
dominates(A, B) ->
descends(A, B) andalso not equal(A, B).
descends(A, B) andalso not descends(B, A).

% @doc Combine all VClocks in the input list into their least possible
% common descendant.
Expand Down Expand Up @@ -378,4 +378,10 @@ valid_entry_test() ->
?assertNot(valid_entry("huffle-puff")),
?assertNot(valid_entry([])).

dominates_test() ->
A1 = vclock:increment(a, vclock:fresh()),
timer:sleep(1000), %% Sleep 1, to alter timestamp for same actor.
A2 = vclock:increment(a, vclock:fresh()),
?assertEqual(false, vclock:dominates(A1, A2)).

-endif.

0 comments on commit 67c24ae

Please sign in to comment.