Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generator for transaction_pool tests #16285

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions src/lib/mina_base/zkapp_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1443,32 +1443,33 @@ let inner_query =
Fields_derivers_zkapps.(inner_query (deriver @@ Derivers.o ())) )

module For_tests = struct
let replace_vks t vk =
let replace_vk vk (p : Account_update.t) =
{ p with
body =
{ p.body with
update =
{ p.body.update with
verification_key =
(* replace dummy vks in vk Setting *)
( match p.body.update.verification_key with
| Set _vk ->
Set vk
| Keep ->
Keep )
}
; authorization_kind =
(* replace dummy vk hashes in authorization kind *)
( match p.body.authorization_kind with
| Proof _vk_hash ->
Proof (With_hash.hash vk)
| ak ->
ak )
}
}

let replace_vks (t : t) vk =
{ t with
account_updates =
Call_forest.map t.account_updates ~f:(fun (p : Account_update.t) ->
{ p with
body =
{ p.body with
update =
{ p.body.update with
verification_key =
(* replace dummy vks in vk Setting *)
( match p.body.update.verification_key with
| Set _vk ->
Set vk
| Keep ->
Keep )
}
; authorization_kind =
(* replace dummy vk hashes in authorization kind *)
( match p.body.authorization_kind with
| Proof _vk_hash ->
Proof (With_hash.hash vk)
| ak ->
ak )
}
} )
account_updates = Call_forest.map t.account_updates ~f:(replace_vk vk)
}
end

Expand Down
7 changes: 4 additions & 3 deletions src/lib/mina_generators/zkapp_command_generators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ let gen_zkapp_command_from ?global_slot ?memo ?(no_account_precondition = false)
?(no_token_accounts = false) ?(limited = false)
?(generate_new_accounts = true) ?failure
?(max_account_updates = max_account_updates)
?(max_token_updates = max_token_updates)
?(max_token_updates = max_token_updates) ?(map_account_update = ident)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

New line in between ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite sure this is managed by the code formatter

~(fee_payer_keypair : Signature_lib.Keypair.t)
~(keymap :
Signature_lib.Private_key.t Signature_lib.Public_key.Compressed.Map.t )
Expand Down Expand Up @@ -1535,8 +1535,9 @@ let gen_zkapp_command_from ?global_slot ?memo ?(no_account_precondition = false)
let zkapp_command_dummy_authorizations : Zkapp_command.t =
{ fee_payer
; account_updates =
account_updates
|> Zkapp_command.Call_forest.map ~f:Account_update.of_simple
Zkapp_command.Call_forest.map
~f:(Fn.compose map_account_update Account_update.of_simple)
account_updates
|> Zkapp_command.Call_forest.accumulate_hashes_predicated
; memo
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/mina_generators/zkapp_command_generators.mli
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ val gen_zkapp_command_from :
-> ?failure:failure
-> ?max_account_updates:int
-> ?max_token_updates:int
-> ?map_account_update:(Account_update.t -> Account_update.t)
-> fee_payer_keypair:Signature_lib.Keypair.t
-> keymap:
Signature_lib.Private_key.t Signature_lib.Public_key.Compressed.Map.t
Expand Down
49 changes: 21 additions & 28 deletions src/lib/network_pool/transaction_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2113,33 +2113,26 @@ let%test_module _ =
Mina_generators.Zkapp_command_generators.gen_zkapp_command_from
~max_token_updates:1 ~keymap ~account_state_tbl
~fee_payer_keypair ~ledger:best_tip_ledger ~constraint_constants
~genesis_constants ()
in
let zkapp_command =
{ zkapp_command with
account_updates =
Zkapp_command.Call_forest.map zkapp_command.account_updates
~f:(fun (p : Account_update.t) ->
{ p with
body =
{ p.body with
preconditions =
{ p.body.preconditions with
account =
( match p.body.preconditions.account.nonce with
| Zkapp_basic.Or_ignore.Check n as c
when Zkapp_precondition.Numeric.(
is_constant Tc.nonce c) ->
Zkapp_precondition.Account.nonce n.lower
| _ ->
Zkapp_precondition.Account.accept )
}
}
} )
}
in
let zkapp_command_valid_vk_hashes =
Zkapp_command.For_tests.replace_vks zkapp_command vk
~genesis_constants
~map_account_update:(fun (p : Account_update.t) ->
Zkapp_command.For_tests.replace_vk vk
{ p with
body =
{ p.body with
preconditions =
{ p.body.preconditions with
account =
( match p.body.preconditions.account.nonce with
| Zkapp_basic.Or_ignore.Check n as c
when Zkapp_precondition.Numeric.(
is_constant Tc.nonce c) ->
Zkapp_precondition.Account.nonce n.lower
| _ ->
Zkapp_precondition.Account.accept )
}
}
} )
()
in
let valid_zkapp_command =
Or_error.ok_exn
Expand All @@ -2150,7 +2143,7 @@ let%test_module _ =
~location_of_account:
(Mina_ledger.Ledger.location_of_account
best_tip_ledger ) )
zkapp_command_valid_vk_hashes )
zkapp_command )
in
User_command.Zkapp_command valid_zkapp_command
in
Expand Down