From f76684031156e7a21627fc92a70bf94ae924132b Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Thu, 13 Feb 2020 04:35:21 -0800 Subject: [PATCH] Fix commit test for hashlock --- src/test/contracts/hashlock.mligo | 6 ++++-- src/test/hash_lock_tests.ml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/contracts/hashlock.mligo b/src/test/contracts/hashlock.mligo index 028f0baec..d158bbfd0 100644 --- a/src/test/contracts/hashlock.mligo +++ b/src/test/contracts/hashlock.mligo @@ -22,8 +22,10 @@ type parameter = (* We use hash-commit so that a baker can't steal *) let commit ((p,s): unit * storage) : operation list * storage = - let salted: bytes = Bytes.concat s.hashed (Bytes.pack sender) in - let commit: commit = {date = Current.time + 86400; salted_hash = Crypto.sha256 salted;} in + let salted : bytes = Crypto.sha256 (Bytes.concat + 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 s = {hashed = s.hashed; unused = s.unused; commits = updated_map} in (([]: operation list), s) diff --git a/src/test/hash_lock_tests.ml b/src/test/hash_lock_tests.ml index b82fa5af2..de83d13ca 100644 --- a/src/test/hash_lock_tests.ml +++ b/src/test/hash_lock_tests.ml @@ -56,7 +56,7 @@ let commit () = 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 = 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 (Bytes.concat Bytes.empty [test_hash_raw; packed_sender])) @@ -72,7 +72,7 @@ let commit () = in let post_commits = e_big_map [((e_address first_committer), commit)] in - let post_storage = storage salted_hash true post_commits in + let post_storage = storage test_hash true post_commits in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp