diff --git a/lib/delta_crdt/storage.ex b/lib/delta_crdt/storage.ex index f8a3ff0..761b921 100644 --- a/lib/delta_crdt/storage.ex +++ b/lib/delta_crdt/storage.ex @@ -10,7 +10,8 @@ defmodule DeltaCrdt.Storage do @type t :: module() @opaque storage_format :: - {node_id :: term(), sequence_number :: integer(), crdt_state :: term()} + {node_id :: term(), sequence_number :: integer(), crdt_state :: term(), + merkle_map :: term()} @callback write(name :: term(), storage_format()) :: :ok @callback read(name :: term()) :: storage_format() | nil diff --git a/test/aw_lww_map_property_test.exs b/test/aw_lww_map_property_test.exs index 3518702..33ab484 100644 --- a/test/aw_lww_map_property_test.exs +++ b/test/aw_lww_map_property_test.exs @@ -5,10 +5,12 @@ defmodule AWLWWMapPropertyTest do setup do operation_gen = - ExUnitProperties.gen all op <- StreamData.member_of([:add, :remove]), - node_id <- term(), - key <- term(), - value <- term() do + ExUnitProperties.gen all( + op <- StreamData.member_of([:add, :remove]), + node_id <- term(), + key <- term(), + value <- term() + ) do {op, key, value, node_id} end @@ -17,9 +19,11 @@ defmodule AWLWWMapPropertyTest do describe ".add/4" do property "can add an element" do - check all key <- term(), - val <- term(), - node_id <- term() do + check all( + key <- term(), + val <- term(), + node_id <- term() + ) do assert %{key => val} == AWLWWMap.join( AWLWWMap.compress_dots(AWLWWMap.new()), @@ -32,7 +36,7 @@ defmodule AWLWWMapPropertyTest do end property "arbitrary add and remove sequence results in correct map", context do - check all operations <- list_of(context.operation_gen) do + check all(operations <- list_of(context.operation_gen)) do actual_result = operations |> Enum.reduce(AWLWWMap.compress_dots(AWLWWMap.new()), fn @@ -60,9 +64,11 @@ defmodule AWLWWMapPropertyTest do describe ".remove/3" do property "can remove an element" do - check all key <- term(), - val <- term(), - node_id <- term() do + check all( + key <- term(), + val <- term(), + node_id <- term() + ) do crdt = AWLWWMap.compress_dots(AWLWWMap.new()) crdt = AWLWWMap.join(crdt, AWLWWMap.add(key, val, node_id, crdt), [key]) diff --git a/test/aw_lww_map_test.exs b/test/aw_lww_map_test.exs index e145369..c501c24 100644 --- a/test/aw_lww_map_test.exs +++ b/test/aw_lww_map_test.exs @@ -59,14 +59,16 @@ defmodule NewAWLWWMapTest do property "arbitrary add and remove sequence results in correct map" do operation_gen = - ExUnitProperties.gen all op <- StreamData.member_of([:add, :remove]), - node_id <- term(), - key <- term(), - value <- term() do + ExUnitProperties.gen all( + op <- StreamData.member_of([:add, :remove]), + node_id <- term(), + key <- term(), + value <- term() + ) do {op, key, value, node_id} end - check all operations <- list_of(operation_gen) do + check all(operations <- list_of(operation_gen)) do actual_result = operations |> Enum.reduce(AWLWWMap.new(), fn diff --git a/test/support/awlww_map_property.ex b/test/support/awlww_map_property.ex index 525ec27..4516913 100644 --- a/test/support/awlww_map_property.ex +++ b/test/support/awlww_map_property.ex @@ -3,25 +3,31 @@ defmodule AWLWWMapProperty do alias DeltaCrdt.{AWLWWMap} def add_operation do - ExUnitProperties.gen all key <- binary(), - val <- binary(), - node_id <- integer() do + ExUnitProperties.gen all( + key <- binary(), + val <- binary(), + node_id <- integer() + ) do fn state -> AWLWWMap.add(key, val, node_id, state) end end end def remove_operation do - ExUnitProperties.gen all key <- binary(), - node_id <- integer() do + ExUnitProperties.gen all( + key <- binary(), + node_id <- integer() + ) do fn state -> AWLWWMap.remove(key, node_id, state) end end end def random_operation do - ExUnitProperties.gen all operation <- one_of([:add, :remove]), - key <- binary(), - val <- binary(), - node_id <- integer() do + ExUnitProperties.gen all( + operation <- one_of([:add, :remove]), + key <- binary(), + val <- binary(), + node_id <- integer() + ) do case operation do :add -> fn