Commit e758a8de authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Fix web with new legacy test data

 * remove signatures (which will be called "records")
parent fbaf12b7
open Lwt
open Util
open Serializable_compat_t
......@@ -46,10 +47,44 @@ let load_elections_and_votes dirname =
Serializable_builtin_j.read_number raw
in
(assert_lwt (Uuidm.equal uuid election.e_uuid)) >>
let public_data =
data "public.json" |>
load_from_file (Serializable_compat_j.read_election_public_data Serializable_builtin_j.read_number)
lwt public_keys =
data "public_keys.jsons" |>
Lwt_io.lines_of_file |>
Lwt_stream.map (fun x ->
Serializable_compat_j.trustee_public_key_of_string Serializable_builtin_j.read_number x
) |>
Lwt_stream.to_list >>= wrap1 Array.of_list
in
lwt election_result, state =
match (
try Some (
data "result.json" |>
load_from_file Serializable_compat_j.read_raw_result
) with Sys_error _ -> None
) with
| Some result ->
let encrypted_tally =
data "encrypted_tally.json" |>
load_from_file (Serializable_compat_j.read_encrypted_tally Serializable_builtin_j.read_number)
in
lwt partial_decryptions =
data "partial_decryptions.jsons" |>
Lwt_io.lines_of_file |>
Lwt_stream.map (fun x ->
Serializable_compat_j.partial_decryption_of_string Serializable_builtin_j.read_number x
) |>
Lwt_stream.to_list >>= wrap1 Array.of_list
in return (Some { encrypted_tally; partial_decryptions; result }, `Finished)
| None -> return (None, `Started)
in
let public_data = {
public_keys;
election_result;
admin = { user_name = "admin"; user_type = "dummy" };
private_p = false;
featured_p = true;
state;
} in
let fingerprint = hashB raw in
let ballots =
let file = data "ballots.json" in
......@@ -62,18 +97,8 @@ let load_elections_and_votes dirname =
)
) else Lwt_stream.from_direct (fun () -> None)
in
let signatures =
let file = data "signatures.json" in
if Sys.file_exists file then (
Lwt_io.lines_of_file file |>
Lwt_stream.map (fun x ->
let v = Serializable_compat_j.signature_of_string x in
v
)
) else Lwt_stream.from_direct (fun () -> None)
in
let election_data = { raw; fingerprint; election; public_data } in
Lwt.return (Some (election_data, ballots, signatures))
Lwt.return (Some (election_data, ballots))
| None -> assert false
) else Lwt.return None
)
......
......@@ -8,7 +8,7 @@ type election_data = {
}
val load_elections_and_votes :
string -> (election_data * Z.t ballot Lwt_stream.t * signature Lwt_stream.t) Lwt_stream.t
string -> (election_data * Z.t ballot Lwt_stream.t) Lwt_stream.t
val hash_ballot : Z.t ballot -> string
val hash_user : user -> string
......@@ -25,20 +25,16 @@ let () =
Ocsigen_messages.debug
(fun () -> "Loading elections from " ^ dir ^ "...");
Common.load_elections_and_votes dir |>
Lwt_stream.iter_s (fun (e, ballots, signatures) ->
Lwt_stream.iter_s (fun (e, ballots) ->
let uuid = Uuidm.to_string e.Common.election.e_uuid in
Ocsigen_messages.debug
(fun () -> Printf.sprintf "-- loading %s (%s)" uuid e.Common.election.e_short_name);
lwt () = Ocsipersist.add elections_table uuid e in
let uuid_underscored = String.map (function '-' -> '_' | c -> c) uuid in
let table = Ocsipersist.open_table ("ballots_" ^ uuid_underscored) in
let signatures_table = Ocsipersist.open_table ("signatures_" ^ uuid_underscored) in
lwt () = Lwt_stream.iter_s (fun v ->
Ocsipersist.add table (Common.hash_ballot v) v
) ballots in
lwt () = Lwt_stream.iter_s (fun v ->
Ocsipersist.add signatures_table (Common.hash_user v.sig_user) v
) signatures in
return ()
) |>
Lwt_main.run
......
......@@ -27,13 +27,13 @@
<host charset="utf-8" hostfilter="*" defaulthostname="localhost">
<site path="static" charset="utf-8">
<static dir="_SRCDIR_/web/helios/static" />
<static dir="_SRCDIR_/media/static" />
</site>
<site path="booth" charset="utf-8">
<static dir="_SRCDIR_/web/helios/booth" />
<static dir="_SRCDIR_/media/booth" />
</site>
<eliom module="_build/web/server.cma">
<load dir="tests/data/legacy"/>
<eliom module="_build/src/web/server.cma">
<load dir="tests/legacy"/>
</eliom>
</host>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment