summaryrefslogtreecommitdiff
path: root/src/test/plop_test.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2014-04-25 12:21:38 +0200
committerLinus Nordberg <linus@nordu.net>2014-04-25 12:21:38 +0200
commit80ae7bd6d3e139078ee58d9861f159b555d28b38 (patch)
tree96646e9643bc23944b3aee855becd73b4b3f4256 /src/test/plop_test.erl
parentfad037a338a48a4e83b33860663632a774aff522 (diff)
Produce SPT's, add tests.
NOTE: Test vectors not verified.
Diffstat (limited to 'src/test/plop_test.erl')
-rw-r--r--src/test/plop_test.erl57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/plop_test.erl b/src/test/plop_test.erl
new file mode 100644
index 0000000..0cbe5cc
--- /dev/null
+++ b/src/test/plop_test.erl
@@ -0,0 +1,57 @@
+-module(plop_test).
+-include("plop.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+adding_test_() ->
+ {"Verifies startup and adding log entries.",
+ {setup, % TODO: use 'foreach'
+ fun start/0,
+ fun stop/1,
+ fun (Arg) ->
+ [test_simple_add(Arg),
+ test_add(Arg)]
+ end}}.
+
+start() ->
+ plop:start("test/rsakey.pem", "sikrit").
+
+stop(Pid) ->
+ Pid ! {self(), quit},
+ [?_assert(receive
+ {ok, quit} -> true
+ after 500 -> false
+ end)].
+
+test_simple_add(Pid) ->
+ ?_assertEqual("foo", Pid ! plop:dummy_add("foo")).
+
+test_add(Pid) ->
+ TestVector =
+ <<1,247,141,118,3,148,171,128,29,143,106,97,200,179,204,166,242,98,70,185,
+ 231,78,193,39,12,245,82,254,230,136,69,69,0,0,0,0,0,0,0,18,103,71,39,45,
+ 246,185,69,39,104,49,16,150,96,168,113,65,36,147,66,168,111,142,244,248,
+ 11,108,194,21,223,116,136,222,26,163,97,48,219,95,0,43,82,83,197,76,120,
+ 166,210,62,103,219,185,216,102,111,217,48,18,100,24,180,17,226,107,180,
+ 101,221,143,50,132,243,45,181,74,217,231,119,222,8,37,8,94,155,113,29,
+ 115,237,147,115,133,21,63,145,44,115,22,72,237,76,0,14,38,140,193,213,
+ 178,112,35,63,183,26,36,160,52,72,17,202,235,114,22,51,25,7,181,32,75,
+ 122,184,47,236,22,184,155,189,253,39,71,149,74,169,234,41,62,89,217,49,
+ 144,134,206,92,112,126,96,199,131,214,17,74,236,193,188,56,150,91,12,
+ 157,93,192,124,192,79,89,164,194,135,159,136,202,198,115,236,76,90,233,
+ 225,109,97,2,194,182,222,4,242,183,44,83,132,240,67,192,128,86,115,236,
+ 84,193,120,213,10,25,198,189,197,147,117,151,103,12,6,1,80,37,237,125,
+ 233,158,237,1,93,202,223,88,245,234,34,113,157,92,39,186,103,89,66,14,
+ 78,168,208,141,78,183,57,28,196,252,251,249,153,203>>,
+ Entry = #plop_entry{type = ?PLOP_ENTRY_TYPE_TEST,
+ entry = <<"some data">>},
+ PlopData = #plop_data{signature_type = ?PLOP_SIGTYPE_TEST,
+ timestamp = 4711,
+ entry = Entry},
+ Pid ! {self(), {add, PlopData}},
+ Res = receive M -> M end,
+ %% {ok, Dev} = file:open("d", write),
+ %% io:format(Dev, "~p~n", [Res]),
+ %% file:close(Dev),
+ [?_assertEqual({ok, TestVector}, Res)].
+
+% Helpers.