diff options
author | Alex Auvolat <alex@adnab.me> | 2018-08-31 22:30:20 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-08-31 22:30:20 +0200 |
commit | e7e255682a81f4212171051bb59d0fedd0e88d3e (patch) | |
tree | e96430f7a636eca7afcaeb8c82e4686ca13e5908 /test/mst_test.exs | |
parent | c83ba74012e38c2fd1c46c063c9c094a78bf9680 (diff) | |
download | shard-e7e255682a81f4212171051bb59d0fedd0e88d3e.tar.gz shard-e7e255682a81f4212171051bb59d0fedd0e88d3e.zip |
Chat using Merkle search tree & block store, not yet 100% complete
Diffstat (limited to 'test/mst_test.exs')
-rw-r--r-- | test/mst_test.exs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/mst_test.exs b/test/mst_test.exs index 73b4f63..7fe340e 100644 --- a/test/mst_test.exs +++ b/test/mst_test.exs @@ -107,5 +107,25 @@ defmodule ShardTest.MST do IO.puts "y.root: #{y.root|>Base.encode16}" IO.puts "z.root: #{z.root|>Base.encode16}" assert y.root == z.root + + MST.last(y, nil, 10) + end + + test "merkle search tree 5" do + y = Enum.reduce(0..1000, %MST{}, + fn i, acc -> MST.insert(acc, i) end) + + assert(MST.last(y, nil, 2) == [{999, true}, {1000, true}]) + assert(MST.last(y, 42, 2) == [{40, true}, {41, true}]) + + stuff = for i <- 100..199, do: {i, true} + assert MST.last(y, 200, 100) == stuff + + stuff = for i <- 200..299, do: {i, true} + assert MST.last(y, 300, 100) == stuff + + stuff = for i <- 200..499, do: {i, true} + assert MST.last(y, 500, 300) == stuff end + end |