Refactor id layer contract to use records instead of tuples

This commit is contained in:
John David Pressman 2020-02-25 00:04:52 -08:00 committed by Pierre-Emmanuel Wulfman
parent 2112e5dee7
commit 8d781eebca
2 changed files with 256 additions and 167 deletions

View File

@ -6,9 +6,21 @@ type id_details = {
profile: bytes profile: bytes
} }
type buy = bytes * address option type buy = {
type update_owner = id * address profile: bytes;
type update_details = id * bytes option * address option initial_controller: address option;
}
type update_owner = {
id: id;
new_owner: address;
}
type update_details = {
id: id;
new_profile: bytes option;
new_controller: address option;
}
type action = type action =
| Buy of buy | Buy of buy
@ -19,7 +31,14 @@ type action =
(* The prices kept in storage can be changed by bakers, though they (* The prices kept in storage can be changed by bakers, though they
should only be adjusted down over time, not up. *) should only be adjusted down over time, not up. *)
type storage = (id, id_details) big_map * int * (tez * tez) (* The prices kept in storage can be changed by bakers, though they should only be
adjusted down over time, not up. *)
type storage = {
identities: (id, id_details) big_map;
next_id: int;
name_price: tez;
skip_price: tez;
}
type return = operation list * storage type return = operation list * storage
@ -38,13 +57,17 @@ a lot that could be eaten up. Should probably do some napkin
calculations for how expensive skipping needs to be to deter people calculations for how expensive skipping needs to be to deter people
from doing it just to chew up address space. *) from doing it just to chew up address space. *)
let buy (parameter, storage: (bytes * address option) * storage) = let buy (parameter, storage: buy * storage) =
let void : unit = let void: unit =
if Tezos.amount <> storage.2.0 if amount = storage.name_price
then (failwith "Incorrect amount paid.": unit) in then ()
let profile, initial_controller = parameter in else (failwith "Incorrect amount paid.": unit)
let identities, new_id, prices = storage in in
let controller : address = let profile = parameter.profile in
let initial_controller = parameter.initial_controller in
let identities = storage.identities in
let new_id = storage.next_id in
let controller: address =
match initial_controller with match initial_controller with
| Some addr -> addr | Some addr -> addr
| None -> sender in | None -> sender in
@ -54,74 +77,98 @@ let buy (parameter, storage: (bytes * address option) * storage) =
profile = profile} in profile = profile} in
let updated_identities : (id, id_details) big_map = let updated_identities : (id, id_details) big_map =
Big_map.update new_id (Some new_id_details) identities Big_map.update new_id (Some new_id_details) identities
in ([]: operation list), (updated_identities, new_id + 1, prices) in
([]: operation list), {identities = updated_identities;
next_id = new_id + 1;
name_price = storage.name_price;
skip_price = storage.skip_price;
}
let update_owner (parameter, storage : (id * address) * storage) = let update_owner (parameter, storage: update_owner * storage) =
if amount <> 0tez if (amount <> 0mutez)
then (failwith "Updating owner doesn't cost anything.": return) then (failwith "Updating owner doesn't cost anything.": (operation list) * storage)
else else
let id, new_owner = parameter in let id = parameter.id in
let identities, last_id, prices = storage in let new_owner = parameter.new_owner in
let current_id_details : id_details = let identities = storage.identities in
match Big_map.find_opt id identities with let current_id_details: id_details =
| Some id_details -> id_details match Big_map.find_opt id identities with
| None -> (failwith "This ID does not exist." : id_details) in | Some id_details -> id_details
let is_allowed : bool = | None -> (failwith "This ID does not exist.": id_details)
if Tezos.sender = current_id_details.owner in
then true let is_allowed: bool =
else (failwith "You are not the owner of this ID." : bool) in if sender = current_id_details.owner
let updated_id_details : id_details = { then true
else (failwith "You are not the owner of this ID.": bool)
in
let updated_id_details: id_details = {
owner = new_owner; owner = new_owner;
controller = current_id_details.controller; controller = current_id_details.controller;
profile = current_id_details.profile} in profile = current_id_details.profile;
let updated_identities = }
Big_map.update id (Some updated_id_details) identities in
in ([]: operation list), (updated_identities, last_id, prices) let updated_identities = Big_map.update id (Some updated_id_details) identities in
([]: operation list), {identities = updated_identities;
next_id = storage.next_id;
name_price = storage.name_price;
skip_price = storage.skip_price;
}
let update_details (parameter, storage: (id * bytes option * address option) * storage) = let update_details (parameter, storage: update_details * storage) =
if Tezos.amount <> 0tez if (amount <> 0mutez)
then then (failwith "Updating details doesn't cost anything.": (operation list) * storage)
(failwith "Updating details doesn't cost anything." : return)
else else
let id, new_profile, new_controller = parameter in let id = parameter.id in
let identities, last_id, prices = storage in let new_profile = parameter.new_profile in
let current_id_details: id_details = let new_controller = parameter.new_controller in
match Big_map.find_opt id identities with let identities = storage.identities in
| Some id_details -> id_details let current_id_details: id_details =
| None -> (failwith "This ID does not exist.": id_details) in match Big_map.find_opt id identities with
let is_allowed : bool = | Some id_details -> id_details
if Tezos.sender = current_id_details.controller | None -> (failwith "This ID does not exist.": id_details)
|| Tezos.sender = current_id_details.owner in
then true let is_allowed: bool =
else if (sender = current_id_details.controller) || (sender = current_id_details.owner)
(failwith ("You are not the owner or controller of this ID.") then true
: bool) in else (failwith ("You are not the owner or controller of this ID."): bool)
let owner : address = current_id_details.owner in in
let profile : bytes = let owner: address = current_id_details.owner in
match new_profile with let profile: bytes =
| None -> (* Default *) current_id_details.profile match new_profile with
| Some new_profile -> new_profile in | None -> (* Default *) current_id_details.profile
let controller : address = | Some new_profile -> new_profile
match new_controller with in
| None -> (* Default *) current_id_details.controller let controller: address =
| Some new_controller -> new_controller in match new_controller with
let updated_id_details: id_details = { | None -> (* Default *) current_id_details.controller
owner = owner; | Some new_controller -> new_controller
controller = controller; in
profile = profile} in let updated_id_details: id_details = {
owner = owner;
controller = controller;
profile = profile;
}
in
let updated_identities: (id, id_details) big_map = let updated_identities: (id, id_details) big_map =
Big_map.update id (Some updated_id_details) identities Big_map.update id (Some updated_id_details) identities in
in ([]: operation list), (updated_identities, last_id, prices) ([]: operation list), {identities = updated_identities;
next_id = storage.next_id;
name_price = storage.name_price;
skip_price = storage.skip_price;
}
(* Let someone skip the next identity so nobody has to take one that's (* Let someone skip the next identity so nobody has to take one that's undesirable *)
undesirable *) let skip (p,storage: unit * storage) =
let void: unit =
let skip (p, storage: unit * storage) = if amount = storage.skip_price
let void : unit = then ()
if Tezos.amount <> storage.2.1 else (failwith "Incorrect amount paid.": unit)
then (failwith "Incorrect amount paid." : unit) in in
let identities, last_id, prices = storage in ([]: operation list), {identities = storage.identities;
([]: operation list), (identities, last_id + 1, prices) next_id = storage.next_id + 1;
name_price = storage.name_price;
skip_price = storage.skip_price;
}
let main (action, storage : action * storage) : return = let main (action, storage : action * storage) : return =
match action with match action with

View File

@ -40,9 +40,10 @@ let buy_id () =
("controller", e_address owner_addr) ; ("controller", e_address owner_addr) ;
("profile", owner_website)] ("profile", owner_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1)]) ; let storage = e_record_ez [("identities", (e_big_map [(e_int 0, id_details_1)])) ;
e_int 1; ("next_id", e_int 1) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_addr = first_owner in let new_addr = first_owner in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options let options = Proto_alpha_utils.Memory_proto_alpha.make_options
@ -54,11 +55,15 @@ let buy_id () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let param = e_pair owner_website (e_some (e_address new_addr)) in let param = e_record_ez [("profile", owner_website) ;
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; ("initial_controller", (e_some (e_address new_addr))) ;
(e_int 1, id_details_2)]) ; ] in
e_int 2; let new_storage = e_record_ez [("identities", (e_big_map
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] [(e_int 0, id_details_1) ;
(e_int 1, id_details_2)])) ;
("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let%bind () = expect_eq ~options (program, state) "buy" let%bind () = expect_eq ~options (program, state) "buy"
(e_pair param storage) (e_pair param storage)
@ -73,9 +78,10 @@ let buy_id_sender_addr () =
("controller", e_address owner_addr) ; ("controller", e_address owner_addr) ;
("profile", owner_website)] ("profile", owner_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1)]) ; let storage = e_record_ez [("identities", (e_big_map [(e_int 0, id_details_1)])) ;
e_int 1; ("next_id", e_int 1) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_addr = first_owner in let new_addr = first_owner in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options let options = Proto_alpha_utils.Memory_proto_alpha.make_options
@ -87,11 +93,14 @@ let buy_id_sender_addr () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let param = e_pair owner_website (e_typed_none (t_address ())) in let param = e_record_ez [("profile", owner_website) ;
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; ("initial_controller", (e_typed_none (t_address ())))] in
(e_int 1, id_details_2)]) ; let new_storage = e_record_ez [("identities", (e_big_map
e_int 2; [(e_int 0, id_details_1) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] (e_int 1, id_details_2)])) ;
("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let%bind () = expect_eq ~options (program, state) "buy" let%bind () = expect_eq ~options (program, state) "buy"
(e_pair param storage) (e_pair param storage)
@ -107,18 +116,20 @@ let buy_id_wrong_amount () =
("controller", e_address owner_addr) ; ("controller", e_address owner_addr) ;
("profile", owner_website)] ("profile", owner_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1)]) ; let storage = e_record_ez [("identities", (e_big_map [(e_int 0, id_details_1)])) ;
e_int 1; ("next_id", e_int 1) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_addr = first_owner in let new_addr = first_owner in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options let options = Proto_alpha_utils.Memory_proto_alpha.make_options
~sender:first_contract ~sender:first_contract
~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.fifty_cents) () ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.fifty_cents) ()
in in
let param = e_pair owner_website (e_some (e_address new_addr)) in let param = e_record_ez [("profile", owner_website) ;
("initial_controller", (e_some (e_address new_addr)))] in
let%bind () = expect_string_failwith ~options (program, state) "buy" let%bind () = expect_string_failwith ~options (program, state) "buy"
(e_pair param storage) (e_pair param storage)
"Incorrect amount paid." "Incorrect amount paid."
in ok () in ok ()
@ -133,7 +144,7 @@ let update_details_owner () =
let new_addr = first_owner in let new_addr = first_owner in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options let options = Proto_alpha_utils.Memory_proto_alpha.make_options
~sender:first_contract ~sender:first_contract
~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero)
() ()
in in
let new_website = e_bytes_string "ligolang.org" in let new_website = e_bytes_string "ligolang.org" in
@ -144,20 +155,24 @@ let update_details_owner () =
let id_details_2_diff = e_record_ez [("owner", e_address new_addr) ; let id_details_2_diff = e_record_ez [("owner", e_address new_addr) ;
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] in ("profile", new_website)] in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let new_storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2_diff)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2_diff)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let details = e_bytes_string "ligolang.org" in let details = e_bytes_string "ligolang.org" in
let param = e_tuple [e_int 1 ; let param = e_record_ez [("id", e_int 1) ;
e_some details ; ("new_profile", e_some details) ;
e_some (e_address new_addr)] in ("new_controller", e_some (e_address new_addr))] in
let%bind () = expect_eq ~options (program, state) "update_details" let%bind () = expect_eq ~options (program, state) "update_details"
(e_pair param storage) (e_pair param storage)
(e_pair (e_list []) new_storage) (e_pair (e_list []) new_storage)
@ -185,20 +200,24 @@ let update_details_controller () =
let id_details_2_diff = e_record_ez [("owner", e_address owner_addr) ; let id_details_2_diff = e_record_ez [("owner", e_address owner_addr) ;
("controller", e_address owner_addr) ; ("controller", e_address owner_addr) ;
("profile", new_website)] in ("profile", new_website)] in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let new_storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2_diff)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2_diff)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let details = e_bytes_string "ligolang.org" in let details = e_bytes_string "ligolang.org" in
let param = e_tuple [e_int 1 ; let param = e_record_ez [("id", e_int 1) ;
e_some details ; ("new_profile", e_some details) ;
e_some (e_address owner_addr)] in ("new_controller", e_some (e_address owner_addr))] in
let%bind () = expect_eq ~options (program, state) "update_details" let%bind () = expect_eq ~options (program, state) "update_details"
(e_pair param storage) (e_pair param storage)
(e_pair (e_list []) new_storage) (e_pair (e_list []) new_storage)
@ -224,15 +243,17 @@ let update_details_nonexistent () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let details = e_bytes_string "ligolang.org" in let details = e_bytes_string "ligolang.org" in
let param = e_tuple [e_int 2 ; let param = e_record_ez [("id", e_int 2) ;
e_some details ; ("new_profile", e_some details) ;
e_some (e_address owner_addr)] in ("new_controller", e_some (e_address owner_addr))] in
let%bind () = expect_string_failwith ~options (program, state) "update_details" let%bind () = expect_string_failwith ~options (program, state) "update_details"
(e_pair param storage) (e_pair param storage)
"This ID does not exist." "This ID does not exist."
@ -257,15 +278,17 @@ let update_details_wrong_addr () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let details = e_bytes_string "ligolang.org" in let details = e_bytes_string "ligolang.org" in
let param = e_tuple [e_int 0 ; let param = e_record_ez [("id", e_int 0) ;
e_some details ; ("new_profile", e_some details) ;
e_some (e_address owner_addr)] in ("new_controller", e_some (e_address owner_addr))] in
let%bind () = expect_string_failwith ~options (program, state) "update_details" let%bind () = expect_string_failwith ~options (program, state) "update_details"
(e_pair param storage) (e_pair param storage)
"You are not the owner or controller of this ID." "You are not the owner or controller of this ID."
@ -291,14 +314,16 @@ let update_details_unchanged () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let param = e_tuple [e_int 1 ; let param = e_record_ez [("id", e_int 1) ;
e_typed_none (t_bytes ()) ; ("new_profile", e_typed_none (t_bytes ())) ;
e_typed_none (t_address ())] in ("new_controller", e_typed_none (t_address ()))] in
let%bind () = expect_eq ~options (program, state) "update_details" let%bind () = expect_eq ~options (program, state) "update_details"
(e_pair param storage) (e_pair param storage)
(e_pair (e_list []) storage) (e_pair (e_list []) storage)
@ -326,17 +351,22 @@ let update_owner () =
let id_details_2_diff = e_record_ez [("owner", e_address owner_addr) ; let id_details_2_diff = e_record_ez [("owner", e_address owner_addr) ;
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] in ("profile", new_website)] in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let new_storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2_diff)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2_diff)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let param = e_pair (e_int 1) (e_address owner_addr) in let param = e_record_ez [("id", e_int 1) ;
("new_owner", e_address owner_addr)] in
let%bind () = expect_eq ~options (program, state) "update_owner" let%bind () = expect_eq ~options (program, state) "update_owner"
(e_pair param storage) (e_pair param storage)
(e_pair (e_list []) new_storage) (e_pair (e_list []) new_storage)
@ -362,12 +392,15 @@ let update_owner_nonexistent () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let param = e_pair (e_int 2) (e_address new_addr) in let param = e_record_ez [("id", e_int 2);
("new_owner", e_address new_addr)] in
let%bind () = expect_string_failwith ~options (program, state) "update_owner" let%bind () = expect_string_failwith ~options (program, state) "update_owner"
(e_pair param storage) (e_pair param storage)
"This ID does not exist." "This ID does not exist."
@ -393,12 +426,15 @@ let update_owner_wrong_addr () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let param = e_pair (e_int 0) (e_address new_addr) in let param = e_record_ez [("id", e_int 0);
("new_owner", e_address new_addr)] in
let%bind () = expect_string_failwith ~options (program, state) "update_owner" let%bind () = expect_string_failwith ~options (program, state) "update_owner"
(e_pair param storage) (e_pair param storage)
"You are not the owner of this ID." "You are not the owner of this ID."
@ -422,15 +458,19 @@ let skip () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let new_storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let new_storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 3; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 3) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let%bind () = expect_eq ~options (program, state) "skip" let%bind () = expect_eq ~options (program, state) "skip"
(e_pair (e_unit ()) storage) (e_pair (e_unit ()) storage)
@ -456,10 +496,12 @@ let skip_wrong_amount () =
("controller", e_address new_addr) ; ("controller", e_address new_addr) ;
("profile", new_website)] ("profile", new_website)]
in in
let storage = e_tuple [(e_big_map [(e_int 0, id_details_1) ; let storage = e_record_ez [("identities", (e_big_map
(e_int 1, id_details_2)]) ; [(e_int 0, id_details_1) ;
e_int 2; (e_int 1, id_details_2)])) ;
e_tuple [e_mutez 1000000 ; e_mutez 1000000]] ("next_id", e_int 2) ;
("name_price", e_mutez 1000000) ;
("skip_price", e_mutez 1000000) ; ]
in in
let%bind () = expect_string_failwith ~options (program, state) "skip" let%bind () = expect_string_failwith ~options (program, state) "skip"
(e_pair (e_unit ()) storage) (e_pair (e_unit ()) storage)