Fix commit test for hashlock

This commit is contained in:
John David Pressman 2020-02-13 04:35:21 -08:00
parent 62a4482ff3
commit f766840311
2 changed files with 6 additions and 4 deletions

View File

@ -22,8 +22,10 @@ type parameter =
(* We use hash-commit so that a baker can't steal *) (* We use hash-commit so that a baker can't steal *)
let commit ((p,s): unit * storage) : operation list * storage = let commit ((p,s): unit * storage) : operation list * storage =
let salted: bytes = Bytes.concat s.hashed (Bytes.pack sender) in let salted : bytes = Crypto.sha256 (Bytes.concat
let commit: commit = {date = Current.time + 86400; salted_hash = Crypto.sha256 salted;} in s.hashed
(Bytes.pack sender)) in
let commit: commit = {date = Current.time + 86400; salted_hash = salted;} in
let updated_map: commit_set = Big_map.update sender (Some commit) s.commits in let updated_map: commit_set = Big_map.update sender (Some commit) s.commits in
let s = {hashed = s.hashed; unused = s.unused; commits = updated_map} in let s = {hashed = s.hashed; unused = s.unused; commits = updated_map} in
(([]: operation list), s) (([]: operation list), s)

View File

@ -56,7 +56,7 @@ let commit () =
let%bind lock_time = mk_time "2000-01-02T00:10:11Z" in let%bind lock_time = mk_time "2000-01-02T00:10:11Z" in
let test_hash_raw = sha_256_hash (Bytes.of_string "hello world") in let test_hash_raw = sha_256_hash (Bytes.of_string "hello world") in
let test_hash = e_bytes_raw test_hash_raw in let test_hash = e_bytes_raw test_hash_raw in
let%bind packed_sender = pack_payload program (e_bytes_string first_committer) in let%bind packed_sender = pack_payload program (e_address first_committer) in
let salted_hash = e_bytes_raw (sha_256_hash let salted_hash = e_bytes_raw (sha_256_hash
(Bytes.concat Bytes.empty [test_hash_raw; (Bytes.concat Bytes.empty [test_hash_raw;
packed_sender])) packed_sender]))
@ -72,7 +72,7 @@ let commit () =
in in
let post_commits = e_big_map [((e_address first_committer), commit)] let post_commits = e_big_map [((e_address first_committer), commit)]
in in
let post_storage = storage salted_hash true post_commits in let post_storage = storage test_hash true post_commits in
let options = let options =
Proto_alpha_utils.Memory_proto_alpha.make_options Proto_alpha_utils.Memory_proto_alpha.make_options
~predecessor_timestamp ~predecessor_timestamp