summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-09-27 15:45:14 +0200
committerLinus Nordberg <linus@nordberg.se>2014-09-29 10:21:56 +0200
commitb676b219edbc7f743dc4e186433a48e36424723a (patch)
tree3c527ffb679bada1ab0c9a746bf02b2868ad8514 /test
parentf44b7bf29dc10a4dc3a13bbe8ae5ad74979517b1 (diff)
Clean up the plop interface, in preparation for a new db implementation.
Diffstat (limited to 'test')
-rw-r--r--test/plop_test.erl94
1 files changed, 0 insertions, 94 deletions
diff --git a/test/plop_test.erl b/test/plop_test.erl
deleted file mode 100644
index ce2a052..0000000
--- a/test/plop_test.erl
+++ /dev/null
@@ -1,94 +0,0 @@
--module(plop_test).
--include("plop.hrl").
--include_lib("eunit/include/eunit.hrl").
-
-%% start_stop_test_() ->
-%% {"The server can be started, stopped and is regsitered",
-%% {setup, fun start/0, fun stop/1, fun is_registered/1}}.
-
-%% "Entries can be added and the STH changes."
-%% FIXME: This way, if a test fails, we don't stop plop. The tests
-%% must run and be validated in strict order though.
-adding_verifying_test() ->
- %%Pid = start(),
- Pubkey = plop:testing_get_pubkey(),
- add_sth_add_sth(Pubkey).
- %%stop(Pid).
-
-%% "Entries can be retrieved."
-get_entries_test_() ->
- Entries = plop:get(1, 2),
- [?_assertEqual(2, length(Entries)),
- ?_assertMatch(#mtl{}, hd(Entries))].
-
-%%% Setup.
-%% start() ->
-%% {ok, Pid} = plop:start_link("../test/rsakey.pem", "sikrit"),
-%% Pid.
-
-%% stop(_) ->
-%% plop:stop().
-
-%%% Tests.
-%% is_registered(Pid) ->
-%% [?_assert(erlang:is_process_alive(Pid)),
-%% ?_assertEqual(Pid, whereis(plop))].
-
-%%% Helpers.
-
-add_sth_add_sth(Pubkey) ->
- add(0, Pubkey),
- STH0 = sth(Pubkey),
- add(1, Pubkey),
- STH1 = sth(Pubkey),
- ?assertNotEqual(STH0, STH1).
-
-add(0, Pubkey) ->
- Msg = crypto:rand_bytes(32),
- Entry = #timestamped_entry{
- timestamp = 4711,
- entry = #plop_entry{
- type = test,
- data = Msg}},
- DataSigned = <<0:8, 0:8, 4711:64, 2:16, Msg/binary>>,
- #spt{
- version = Version,
- timestamp = Timestamp,
- signature = #signature{signature = Signature}
- } = plop:add(Entry),
- ?assertEqual(0, Version),
- ?assertEqual(4711, Timestamp),
- ?assert(public_key:verify(DataSigned, sha256, Signature, Pubkey));
-add(1, Pubkey) ->
- Msg = crypto:rand_bytes(32),
- Entry = #timestamped_entry{
- timestamp = 4712,
- entry = #plop_entry{
- type = test,
- data = Msg}},
- DataSigned = <<0:8, 0:8, 4712:64, 2:16, Msg/binary>>,
- #spt{
- version = Version,
- timestamp = Timestamp,
- signature = #signature{signature = Signature}
- } = plop:add(Entry),
- ?assertEqual(0, Version),
- ?assertEqual(4712, Timestamp),
- ?assert(public_key:verify(DataSigned, sha256, Signature, Pubkey)).
-
-%% TODO
-%% add(2) ->
-%% TestVector = <<>>,
-%% %% Same data as in 0, should not result in new database entry.
-
-sth(Pubkey) ->
- #sth{
- treesize = Treesize,
- timestamp = Timestamp,
- roothash = Roothash,
- signature = #signature{signature = Signature}
- } = STH = plop:sth(),
- Data = list_to_binary([<<0:8, 1:8, Timestamp:64, Treesize:64>>, Roothash]),
- ?assert(public_key:verify(Data, sha256, Signature, Pubkey)),
- STH.
-