Alpha: adapt test to new operation type
This commit is contained in:
parent
2bb9c4d743
commit
8eac1b03ac
@ -910,6 +910,7 @@ module Operation : sig
|
|||||||
|
|
||||||
val hash: _ operation -> Operation_hash.t
|
val hash: _ operation -> Operation_hash.t
|
||||||
val hash_raw: raw -> Operation_hash.t
|
val hash_raw: raw -> Operation_hash.t
|
||||||
|
val hash_packed: packed_operation -> Operation_hash.t
|
||||||
|
|
||||||
val acceptable_passes: packed_operation -> int list
|
val acceptable_passes: packed_operation -> int list
|
||||||
|
|
||||||
|
@ -675,6 +675,12 @@ let hash (o : _ operation) =
|
|||||||
protocol_data_encoding
|
protocol_data_encoding
|
||||||
(Operation_data o.protocol_data) in
|
(Operation_data o.protocol_data) in
|
||||||
Operation.hash { shell = o.shell ; proto }
|
Operation.hash { shell = o.shell ; proto }
|
||||||
|
let hash_packed (o : packed_operation) =
|
||||||
|
let proto =
|
||||||
|
Data_encoding.Binary.to_bytes_exn
|
||||||
|
protocol_data_encoding
|
||||||
|
o.protocol_data in
|
||||||
|
Operation.hash { shell = o.shell ; proto }
|
||||||
|
|
||||||
type ('a, 'b) eq = Eq : ('a, 'a) eq
|
type ('a, 'b) eq = Eq : ('a, 'a) eq
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ val raw: _ operation -> raw
|
|||||||
|
|
||||||
val hash_raw: raw -> Operation_hash.t
|
val hash_raw: raw -> Operation_hash.t
|
||||||
val hash: _ operation -> Operation_hash.t
|
val hash: _ operation -> Operation_hash.t
|
||||||
|
val hash_packed: packed_operation -> Operation_hash.t
|
||||||
|
|
||||||
val acceptable_passes: packed_operation -> int list
|
val acceptable_passes: packed_operation -> int list
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ let valid_double_endorsement_evidence () =
|
|||||||
Context.get_endorser (B blk_a) 0 >>=? fun delegate ->
|
Context.get_endorser (B blk_a) 0 >>=? fun delegate ->
|
||||||
Op.endorsement ~delegate (B blk_a) [0] >>=? fun endorsement_a ->
|
Op.endorsement ~delegate (B blk_a) [0] >>=? fun endorsement_a ->
|
||||||
Op.endorsement ~delegate (B blk_b) [0] >>=? fun endorsement_b ->
|
Op.endorsement ~delegate (B blk_b) [0] >>=? fun endorsement_b ->
|
||||||
Block.bake ~operations:[endorsement_a] blk_a >>=? fun blk_a ->
|
Block.bake ~operations:[Operation.pack endorsement_a] blk_a >>=? fun blk_a ->
|
||||||
(* Block.bake ~operations:[endorsement_b] blk_b >>=? fun _ -> *)
|
(* Block.bake ~operations:[endorsement_b] blk_b >>=? fun _ -> *)
|
||||||
|
|
||||||
Op.double_endorsement (B blk_a) endorsement_a endorsement_b >>=? fun operation ->
|
Op.double_endorsement (B blk_a) endorsement_a endorsement_b >>=? fun operation ->
|
||||||
@ -84,7 +84,7 @@ let invalid_double_endorsement () =
|
|||||||
Block.bake b >>=? fun b ->
|
Block.bake b >>=? fun b ->
|
||||||
|
|
||||||
Op.endorsement (B b) [0] >>=? fun endorsement ->
|
Op.endorsement (B b) [0] >>=? fun endorsement ->
|
||||||
Block.bake ~operation:endorsement b >>=? fun b ->
|
Block.bake ~operation:(Operation.pack endorsement) b >>=? fun b ->
|
||||||
|
|
||||||
Op.double_endorsement (B b) endorsement endorsement >>=? fun operation ->
|
Op.double_endorsement (B b) endorsement endorsement >>=? fun operation ->
|
||||||
Block.bake ~operation b >>= fun res ->
|
Block.bake ~operation b >>= fun res ->
|
||||||
|
@ -68,7 +68,7 @@ let simple_endorsement () =
|
|||||||
(Contract.implicit_contract endorser) >>=? fun initial_balance ->
|
(Contract.implicit_contract endorser) >>=? fun initial_balance ->
|
||||||
Block.bake
|
Block.bake
|
||||||
~policy:(Excluding [endorser])
|
~policy:(Excluding [endorser])
|
||||||
~operations:[op]
|
~operations:[Operation.pack op]
|
||||||
b >>=? fun b2 ->
|
b >>=? fun b2 ->
|
||||||
assert_endorser_balance_consistency ~loc:__LOC__
|
assert_endorser_balance_consistency ~loc:__LOC__
|
||||||
(B b2) ~nb_endorsement:1 endorser initial_balance
|
(B b2) ~nb_endorsement:1 endorser initial_balance
|
||||||
@ -87,7 +87,7 @@ let max_endorsement () =
|
|||||||
let delegate = endorser.delegate in
|
let delegate = endorser.delegate in
|
||||||
Context.Contract.balance (B b) (Contract.implicit_contract delegate) >>=? fun balance ->
|
Context.Contract.balance (B b) (Contract.implicit_contract delegate) >>=? fun balance ->
|
||||||
Op.endorsement ~delegate (B b) endorser.slots >>=? fun op ->
|
Op.endorsement ~delegate (B b) endorser.slots >>=? fun op ->
|
||||||
return (delegate :: delegates, op :: ops, (List.length endorser.slots, balance) :: balances)
|
return (delegate :: delegates, Operation.pack op :: ops, (List.length endorser.slots, balance) :: balances)
|
||||||
)
|
)
|
||||||
([], [], [])
|
([], [], [])
|
||||||
endorsers >>=? fun (delegates, ops, previous_balances) ->
|
endorsers >>=? fun (delegates, ops, previous_balances) ->
|
||||||
@ -116,6 +116,7 @@ let consistent_priority () =
|
|||||||
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
||||||
|
|
||||||
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~policy:( Excluding [ endorser ] ) ~operation b >>=? fun b ->
|
Block.bake ~policy:( Excluding [ endorser ] ) ~operation b >>=? fun b ->
|
||||||
|
|
||||||
assert_endorser_balance_consistency ~loc:__LOC__ ~priority:15
|
assert_endorser_balance_consistency ~loc:__LOC__ ~priority:15
|
||||||
@ -140,6 +141,7 @@ let consistent_priorities () =
|
|||||||
|
|
||||||
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
||||||
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~policy:( Excluding [ endorser ] ) ~operation b >>=? fun b ->
|
Block.bake ~policy:( Excluding [ endorser ] ) ~operation b >>=? fun b ->
|
||||||
|
|
||||||
assert_endorser_balance_consistency ~loc:__LOC__ ~priority
|
assert_endorser_balance_consistency ~loc:__LOC__ ~priority
|
||||||
@ -156,6 +158,7 @@ let reward_retrieval () =
|
|||||||
Context.get_endorser (B b) slot >>=? fun endorser ->
|
Context.get_endorser (B b) slot >>=? fun endorser ->
|
||||||
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
Context.Contract.balance (B b) (Contract.implicit_contract endorser) >>=? fun balance ->
|
||||||
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
Op.endorsement ~delegate:endorser (B b) [slot] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~policy:(Excluding [ endorser ]) ~operation b >>=? fun b ->
|
Block.bake ~policy:(Excluding [ endorser ]) ~operation b >>=? fun b ->
|
||||||
(* Bake (preserved_cycles + 1) cycles *)
|
(* Bake (preserved_cycles + 1) cycles *)
|
||||||
fold_left_s (fun b _ ->
|
fold_left_s (fun b _ ->
|
||||||
@ -176,6 +179,7 @@ let wrong_endorsement_predecessor () =
|
|||||||
Context.get_endorser (B b) 0 >>=? fun genesis_endorser ->
|
Context.get_endorser (B b) 0 >>=? fun genesis_endorser ->
|
||||||
Block.bake b >>=? fun b' ->
|
Block.bake b >>=? fun b' ->
|
||||||
Op.endorsement ~delegate:genesis_endorser ~signing_context:(B b') (B b) [0] >>=? fun operation ->
|
Op.endorsement ~delegate:genesis_endorser ~signing_context:(B b') (B b) [0] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~operation b' >>= fun res ->
|
Block.bake ~operation b' >>= fun res ->
|
||||||
|
|
||||||
Assert.proto_error ~loc:__LOC__ res begin function
|
Assert.proto_error ~loc:__LOC__ res begin function
|
||||||
@ -190,6 +194,7 @@ let invalid_endorsement_level () =
|
|||||||
Context.get_level (B b) >>=? fun genesis_level ->
|
Context.get_level (B b) >>=? fun genesis_level ->
|
||||||
Block.bake b >>=? fun b ->
|
Block.bake b >>=? fun b ->
|
||||||
Op.endorsement ~level:genesis_level (B b) [0] >>=? fun operation ->
|
Op.endorsement ~level:genesis_level (B b) [0] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~operation b >>= fun res ->
|
Block.bake ~operation b >>= fun res ->
|
||||||
|
|
||||||
Assert.proto_error ~loc:__LOC__ res begin function
|
Assert.proto_error ~loc:__LOC__ res begin function
|
||||||
@ -202,8 +207,10 @@ let duplicate_endorsement () =
|
|||||||
Context.init 5 >>=? fun (b, _) ->
|
Context.init 5 >>=? fun (b, _) ->
|
||||||
Incremental.begin_construction b >>=? fun inc ->
|
Incremental.begin_construction b >>=? fun inc ->
|
||||||
Op.endorsement (B b) [0] >>=? fun operation ->
|
Op.endorsement (B b) [0] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Incremental.add_operation inc operation >>=? fun inc ->
|
Incremental.add_operation inc operation >>=? fun inc ->
|
||||||
Op.endorsement (B b) [0] >>=? fun operation ->
|
Op.endorsement (B b) [0] >>=? fun operation ->
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Incremental.add_operation inc operation >>= fun res ->
|
Incremental.add_operation inc operation >>= fun res ->
|
||||||
|
|
||||||
Assert.proto_error ~loc:__LOC__ res begin function
|
Assert.proto_error ~loc:__LOC__ res begin function
|
||||||
@ -219,6 +226,7 @@ let invalid_endorsement_slot () =
|
|||||||
Context.get_endorser (B b) 0 >>=? fun endorser ->
|
Context.get_endorser (B b) 0 >>=? fun endorser ->
|
||||||
Op.endorsement ~delegate:endorser (B b) [endorsers_per_block + 1] >>=? fun operation ->
|
Op.endorsement ~delegate:endorser (B b) [endorsers_per_block + 1] >>=? fun operation ->
|
||||||
|
|
||||||
|
let operation = Operation.pack operation in
|
||||||
Block.bake ~operation b >>= fun res ->
|
Block.bake ~operation b >>= fun res ->
|
||||||
|
|
||||||
Assert.proto_error ~loc:__LOC__ res begin function
|
Assert.proto_error ~loc:__LOC__ res begin function
|
||||||
|
@ -15,7 +15,7 @@ open Alpha_context
|
|||||||
type t = {
|
type t = {
|
||||||
hash : Block_hash.t ;
|
hash : Block_hash.t ;
|
||||||
header : Block_header.t ;
|
header : Block_header.t ;
|
||||||
operations : Operation.t list ;
|
operations : Operation.packed list ;
|
||||||
context : Tezos_protocol_environment_memory.Context.t ;
|
context : Tezos_protocol_environment_memory.Context.t ;
|
||||||
}
|
}
|
||||||
type block = t
|
type block = t
|
||||||
@ -152,7 +152,7 @@ module Forge = struct
|
|||||||
| { expected_commitment = true } -> Some (fst (Proto_Nonce.generate ()))
|
| { expected_commitment = true } -> Some (fst (Proto_Nonce.generate ()))
|
||||||
| { expected_commitment = false } -> None
|
| { expected_commitment = false } -> None
|
||||||
end >>=? fun seed_nonce_hash ->
|
end >>=? fun seed_nonce_hash ->
|
||||||
let hashes = List.map Operation.hash operations in
|
let hashes = List.map Operation.hash_packed operations in
|
||||||
let operations_hash = Operation_list_list_hash.compute
|
let operations_hash = Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute hashes] in
|
[Operation_list_hash.compute hashes] in
|
||||||
let header = make_header
|
let header = make_header
|
||||||
@ -229,7 +229,6 @@ let genesis
|
|||||||
?(blocks_per_roll_snapshot = Constants_repr.default.blocks_per_roll_snapshot)
|
?(blocks_per_roll_snapshot = Constants_repr.default.blocks_per_roll_snapshot)
|
||||||
?(blocks_per_voting_period = Constants_repr.default.blocks_per_voting_period)
|
?(blocks_per_voting_period = Constants_repr.default.blocks_per_voting_period)
|
||||||
?(time_between_blocks = Constants_repr.default.time_between_blocks)
|
?(time_between_blocks = Constants_repr.default.time_between_blocks)
|
||||||
?(first_free_baking_slot = Constants_repr.default.first_free_baking_slot)
|
|
||||||
?(endorsers_per_block = Constants_repr.default.endorsers_per_block)
|
?(endorsers_per_block = Constants_repr.default.endorsers_per_block)
|
||||||
?(hard_gas_limit_per_operation = Constants_repr.default.hard_gas_limit_per_operation)
|
?(hard_gas_limit_per_operation = Constants_repr.default.hard_gas_limit_per_operation)
|
||||||
?(hard_gas_limit_per_block = Constants_repr.default.hard_gas_limit_per_block)
|
?(hard_gas_limit_per_block = Constants_repr.default.hard_gas_limit_per_block)
|
||||||
@ -276,7 +275,6 @@ let genesis
|
|||||||
blocks_per_roll_snapshot ;
|
blocks_per_roll_snapshot ;
|
||||||
blocks_per_voting_period ;
|
blocks_per_voting_period ;
|
||||||
time_between_blocks ;
|
time_between_blocks ;
|
||||||
first_free_baking_slot ;
|
|
||||||
endorsers_per_block ;
|
endorsers_per_block ;
|
||||||
hard_gas_limit_per_operation ;
|
hard_gas_limit_per_operation ;
|
||||||
hard_gas_limit_per_block ;
|
hard_gas_limit_per_block ;
|
||||||
|
@ -13,7 +13,7 @@ open Alpha_context
|
|||||||
type t = {
|
type t = {
|
||||||
hash : Block_hash.t ;
|
hash : Block_hash.t ;
|
||||||
header : Block_header.t ;
|
header : Block_header.t ;
|
||||||
operations : Operation.t list ;
|
operations : Operation.packed list ;
|
||||||
context : Tezos_protocol_environment_memory.Context.t ; (** Resulting context *)
|
context : Tezos_protocol_environment_memory.Context.t ; (** Resulting context *)
|
||||||
}
|
}
|
||||||
type block = t
|
type block = t
|
||||||
@ -46,7 +46,7 @@ module Forge : sig
|
|||||||
The header can then be modified and applied with [apply]. *)
|
The header can then be modified and applied with [apply]. *)
|
||||||
val forge_header:
|
val forge_header:
|
||||||
?policy:baker_policy ->
|
?policy:baker_policy ->
|
||||||
?operations: Operation.t list ->
|
?operations: Operation.packed list ->
|
||||||
t -> header tzresult Lwt.t
|
t -> header tzresult Lwt.t
|
||||||
|
|
||||||
(** Sets seed_nonce_hash of a header *)
|
(** Sets seed_nonce_hash of a header *)
|
||||||
@ -67,7 +67,6 @@ val genesis:
|
|||||||
?blocks_per_roll_snapshot:int32 ->
|
?blocks_per_roll_snapshot:int32 ->
|
||||||
?blocks_per_voting_period:int32 ->
|
?blocks_per_voting_period:int32 ->
|
||||||
?time_between_blocks:Period_repr.t list ->
|
?time_between_blocks:Period_repr.t list ->
|
||||||
?first_free_baking_slot:int ->
|
|
||||||
?endorsers_per_block:int ->
|
?endorsers_per_block:int ->
|
||||||
?hard_gas_limit_per_operation:Z.t ->
|
?hard_gas_limit_per_operation:Z.t ->
|
||||||
?hard_gas_limit_per_block:Z.t ->
|
?hard_gas_limit_per_block:Z.t ->
|
||||||
@ -93,7 +92,7 @@ val genesis:
|
|||||||
(** Applies a header and its operations to a block and obtains a new block *)
|
(** Applies a header and its operations to a block and obtains a new block *)
|
||||||
val apply:
|
val apply:
|
||||||
Forge.header ->
|
Forge.header ->
|
||||||
?operations: Operation.t list ->
|
?operations: Operation.packed list ->
|
||||||
t -> t tzresult Lwt.t
|
t -> t tzresult Lwt.t
|
||||||
|
|
||||||
(**
|
(**
|
||||||
@ -103,8 +102,8 @@ val apply:
|
|||||||
*)
|
*)
|
||||||
val bake:
|
val bake:
|
||||||
?policy: baker_policy ->
|
?policy: baker_policy ->
|
||||||
?operation: Operation.t ->
|
?operation: Operation.packed ->
|
||||||
?operations: Operation.t list ->
|
?operations: Operation.packed list ->
|
||||||
t -> t tzresult Lwt.t
|
t -> t tzresult Lwt.t
|
||||||
|
|
||||||
(** Bakes [n] blocks. *)
|
(** Bakes [n] blocks. *)
|
||||||
|
@ -13,7 +13,7 @@ open Alpha_context
|
|||||||
type t = {
|
type t = {
|
||||||
predecessor: Block.t ;
|
predecessor: Block.t ;
|
||||||
state: M.validation_state ;
|
state: M.validation_state ;
|
||||||
rev_operations: Operation.t list ;
|
rev_operations: Operation.packed list ;
|
||||||
header: Block_header.t ;
|
header: Block_header.t ;
|
||||||
delegate: Account.t ;
|
delegate: Account.t ;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ let finalize_block st =
|
|||||||
let operations = List.rev st.rev_operations in
|
let operations = List.rev st.rev_operations in
|
||||||
let operations_hash =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute [
|
Operation_list_list_hash.compute [
|
||||||
Operation_list_hash.compute (List.map Operation.hash operations)
|
Operation_list_hash.compute (List.map Operation.hash_packed operations)
|
||||||
] in
|
] in
|
||||||
let header =
|
let header =
|
||||||
{ st.header with
|
{ st.header with
|
||||||
|
@ -23,7 +23,7 @@ val begin_construction:
|
|||||||
Block.t -> incremental tzresult Lwt.t
|
Block.t -> incremental tzresult Lwt.t
|
||||||
|
|
||||||
val add_operation:
|
val add_operation:
|
||||||
incremental -> Operation.t -> incremental tzresult Lwt.t
|
incremental -> Operation.packed -> incremental tzresult Lwt.t
|
||||||
|
|
||||||
val finalize_block: incremental -> Block.t tzresult Lwt.t
|
val finalize_block: incremental -> Block.t tzresult Lwt.t
|
||||||
|
|
||||||
|
@ -10,19 +10,20 @@
|
|||||||
open Proto_alpha
|
open Proto_alpha
|
||||||
open Alpha_context
|
open Alpha_context
|
||||||
|
|
||||||
let sign ?(watermark = Signature.Generic_operation) sk ctxt contents =
|
let sign ?(watermark = Signature.Generic_operation)
|
||||||
|
sk ctxt contents =
|
||||||
let branch = Context.branch ctxt in
|
let branch = Context.branch ctxt in
|
||||||
let unsigned =
|
let unsigned =
|
||||||
Data_encoding.Binary.to_bytes_exn
|
Data_encoding.Binary.to_bytes_exn
|
||||||
Operation.unsigned_encoding
|
Operation.unsigned_encoding
|
||||||
({ branch }, contents) in
|
({ branch }, Contents_list contents) in
|
||||||
let signature = Some (Signature.sign ~watermark sk unsigned) in
|
let signature = Some (Signature.sign ~watermark sk unsigned) in
|
||||||
{ shell = { branch } ;
|
({ shell = { branch } ;
|
||||||
protocol_data = {
|
protocol_data = {
|
||||||
contents ;
|
contents ;
|
||||||
signature ;
|
signature ;
|
||||||
} ;
|
} ;
|
||||||
}
|
} : _ Operation.t)
|
||||||
|
|
||||||
let endorsement ?delegate ?level ctxt =
|
let endorsement ?delegate ?level ctxt =
|
||||||
fun ?(signing_context=ctxt) slots ->
|
fun ?(signing_context=ctxt) slots ->
|
||||||
@ -38,40 +39,77 @@ let endorsement ?delegate ?level ctxt =
|
|||||||
| Some level -> return level
|
| Some level -> return level
|
||||||
end >>=? fun level ->
|
end >>=? fun level ->
|
||||||
let op =
|
let op =
|
||||||
let operations = Endorsements { block = Context.branch ctxt ; level ; slots = slots } in
|
Single
|
||||||
Sourced_operation (Consensus_operation operations) in
|
(Endorsements
|
||||||
|
{ block = Context.branch ctxt ; level ; slots = slots }) in
|
||||||
return (sign ~watermark:Signature.Endorsement delegate.sk signing_context op)
|
return (sign ~watermark:Signature.Endorsement delegate.sk signing_context op)
|
||||||
|
|
||||||
let manager_operations ?(fee = Tez.zero)
|
let sign ?watermark sk ctxt (Contents_list contents) =
|
||||||
|
Operation.pack (sign ?watermark sk ctxt contents)
|
||||||
|
|
||||||
|
let manager_operation
|
||||||
|
?(fee = Tez.zero)
|
||||||
?(gas_limit = Constants_repr.default.hard_gas_limit_per_operation)
|
?(gas_limit = Constants_repr.default.hard_gas_limit_per_operation)
|
||||||
?(storage_limit = Constants_repr.default.hard_storage_limit_per_operation)
|
?(storage_limit = Constants_repr.default.hard_storage_limit_per_operation)
|
||||||
?public_key ~source ctxt operations =
|
?public_key ~source ctxt operation =
|
||||||
Context.Contract.counter ctxt source >>=? fun counter ->
|
Context.Contract.counter ctxt source >>=? fun counter ->
|
||||||
Context.Contract.manager ctxt source >>=? fun account ->
|
Context.Contract.manager ctxt source >>=? fun account ->
|
||||||
let public_key = Option.unopt ~default:account.pk public_key in
|
let public_key = Option.unopt ~default:account.pk public_key in
|
||||||
let counter = Int32.succ counter in
|
let counter = Int32.succ counter in
|
||||||
Context.Contract.is_manager_key_revealed ctxt source >>=? begin function
|
Context.Contract.is_manager_key_revealed ctxt source >>=? function
|
||||||
| true -> return operations
|
| true ->
|
||||||
| false -> return @@ (Reveal public_key) :: operations end >>=? fun operations ->
|
let op =
|
||||||
return @@ Manager_operations {
|
Manager_operation {
|
||||||
source ;
|
source ;
|
||||||
fee ;
|
fee ;
|
||||||
counter ;
|
counter ;
|
||||||
operations ;
|
operation ;
|
||||||
gas_limit ;
|
gas_limit ;
|
||||||
storage_limit ;
|
storage_limit ;
|
||||||
}
|
} in
|
||||||
|
return (Contents_list (Single op))
|
||||||
|
| false ->
|
||||||
|
let op_reveal =
|
||||||
|
Manager_operation {
|
||||||
|
source ;
|
||||||
|
fee = Tez.zero ;
|
||||||
|
counter ;
|
||||||
|
operation = Reveal public_key ;
|
||||||
|
gas_limit = Z.of_int 20 ;
|
||||||
|
storage_limit = 0L ;
|
||||||
|
} in
|
||||||
|
let op =
|
||||||
|
Manager_operation {
|
||||||
|
source ;
|
||||||
|
fee ;
|
||||||
|
counter = Int32.succ counter ;
|
||||||
|
operation ;
|
||||||
|
gas_limit ;
|
||||||
|
storage_limit ;
|
||||||
|
} in
|
||||||
|
return (Contents_list (Cons (op_reveal, Single op)))
|
||||||
|
|
||||||
let revelation ctxt public_key =
|
let revelation ctxt public_key =
|
||||||
let pkh = Signature.Public_key.hash public_key in
|
let pkh = Signature.Public_key.hash public_key in
|
||||||
let contract = Contract.implicit_contract pkh in
|
let source = Contract.implicit_contract pkh in
|
||||||
manager_operations ~source:contract ~public_key ctxt [] >>=? fun mop ->
|
Context.Contract.counter ctxt source >>=? fun counter ->
|
||||||
let sop = Sourced_operation mop in
|
Context.Contract.manager ctxt source >>=? fun account ->
|
||||||
Context.Contract.manager ctxt contract >>=? fun account ->
|
let counter = Int32.succ counter in
|
||||||
|
let sop =
|
||||||
|
Contents_list
|
||||||
|
(Single
|
||||||
|
(Manager_operation {
|
||||||
|
source ;
|
||||||
|
fee = Tez.zero ;
|
||||||
|
counter ;
|
||||||
|
operation = Reveal public_key ;
|
||||||
|
gas_limit = Z.of_int 20 ;
|
||||||
|
storage_limit = 0L ;
|
||||||
|
})) in
|
||||||
return @@ sign account.sk ctxt sop
|
return @@ sign account.sk ctxt sop
|
||||||
|
|
||||||
let originated_contract (op:Operation.t) =
|
let originated_contract (op: Operation.packed) =
|
||||||
let nonce = Contract.initial_origination_nonce (Operation.hash op) in
|
let nonce = Contract.initial_origination_nonce (Operation.hash_packed op) in
|
||||||
Contract.originated_contract nonce
|
Contract.originated_contract nonce
|
||||||
|
|
||||||
exception Impossible
|
exception Impossible
|
||||||
@ -84,7 +122,8 @@ let origination ?delegate ?script
|
|||||||
let default_credit = Tez.of_mutez @@ Int64.of_int 1000001 in
|
let default_credit = Tez.of_mutez @@ Int64.of_int 1000001 in
|
||||||
let default_credit = Option.unopt_exn Impossible default_credit in
|
let default_credit = Option.unopt_exn Impossible default_credit in
|
||||||
let credit = Option.unopt ~default:default_credit credit in
|
let credit = Option.unopt ~default:default_credit credit in
|
||||||
let operations = [Origination {
|
let operation =
|
||||||
|
Origination {
|
||||||
manager ;
|
manager ;
|
||||||
delegate ;
|
delegate ;
|
||||||
script ;
|
script ;
|
||||||
@ -92,11 +131,10 @@ let origination ?delegate ?script
|
|||||||
delegatable ;
|
delegatable ;
|
||||||
credit ;
|
credit ;
|
||||||
preorigination ;
|
preorigination ;
|
||||||
}] in
|
} in
|
||||||
manager_operations ?public_key ?fee ?gas_limit ?storage_limit
|
manager_operation ?public_key ?fee ?gas_limit ?storage_limit
|
||||||
~source ctxt operations >>=? fun mop ->
|
~source ctxt operation >>=? fun sop ->
|
||||||
let sop = Sourced_operation mop in
|
let op = sign account.sk ctxt sop in
|
||||||
let op:Operation.t = sign account.sk ctxt sop in
|
|
||||||
return (op , originated_contract op)
|
return (op , originated_contract op)
|
||||||
|
|
||||||
let miss_signed_endorsement ?level ctxt slot =
|
let miss_signed_endorsement ?level ctxt slot =
|
||||||
@ -117,16 +155,14 @@ let transaction ?fee ?gas_limit ?storage_limit ?parameters ctxt
|
|||||||
parameters;
|
parameters;
|
||||||
destination=dst;
|
destination=dst;
|
||||||
} in
|
} in
|
||||||
manager_operations ?fee ?gas_limit ?storage_limit
|
manager_operation ?fee ?gas_limit ?storage_limit
|
||||||
~source:src ctxt [top] >>=? fun mop ->
|
~source:src ctxt top >>=? fun sop ->
|
||||||
let sop = Sourced_operation mop in
|
|
||||||
Context.Contract.manager ctxt src >>=? fun account ->
|
Context.Contract.manager ctxt src >>=? fun account ->
|
||||||
return @@ sign account.sk ctxt sop
|
return @@ sign account.sk ctxt sop
|
||||||
|
|
||||||
let delegation ?fee ctxt source dst =
|
let delegation ?fee ctxt source dst =
|
||||||
let top = Delegation dst in
|
let top = Delegation dst in
|
||||||
manager_operations ?fee ~source ctxt [top] >>=? fun mop ->
|
manager_operation ?fee ~source ctxt top >>=? fun sop ->
|
||||||
let sop = Sourced_operation mop in
|
|
||||||
Context.Contract.manager ctxt source >>=? fun account ->
|
Context.Contract.manager ctxt source >>=? fun account ->
|
||||||
return @@ sign account.sk ctxt sop
|
return @@ sign account.sk ctxt sop
|
||||||
|
|
||||||
@ -137,13 +173,11 @@ let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code =
|
|||||||
encrypted public key hash" Signature.Public_key_hash.pp pkh
|
encrypted public key hash" Signature.Public_key_hash.pp pkh
|
||||||
end >>=? fun id ->
|
end >>=? fun id ->
|
||||||
let contents =
|
let contents =
|
||||||
Anonymous_operations
|
Single (Activate_account { id ; activation_code } ) in
|
||||||
[ Activation { id ; activation_code } ]
|
|
||||||
in
|
|
||||||
let branch = Context.branch ctxt in
|
let branch = Context.branch ctxt in
|
||||||
return {
|
return {
|
||||||
shell = { branch } ;
|
shell = { branch } ;
|
||||||
protocol_data = {
|
protocol_data = Operation_data {
|
||||||
contents ;
|
contents ;
|
||||||
signature = None ;
|
signature = None ;
|
||||||
} ;
|
} ;
|
||||||
@ -151,13 +185,11 @@ let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code =
|
|||||||
|
|
||||||
let double_endorsement ctxt op1 op2 =
|
let double_endorsement ctxt op1 op2 =
|
||||||
let contents =
|
let contents =
|
||||||
Anonymous_operations [
|
Single (Double_endorsement_evidence {op1 ; op2}) in
|
||||||
Double_endorsement_evidence {op1 ; op2}
|
|
||||||
] in
|
|
||||||
let branch = Context.branch ctxt in
|
let branch = Context.branch ctxt in
|
||||||
return {
|
return {
|
||||||
shell = { branch } ;
|
shell = { branch } ;
|
||||||
protocol_data = {
|
protocol_data = Operation_data {
|
||||||
contents ;
|
contents ;
|
||||||
signature = None ;
|
signature = None ;
|
||||||
} ;
|
} ;
|
||||||
@ -165,13 +197,11 @@ let double_endorsement ctxt op1 op2 =
|
|||||||
|
|
||||||
let double_baking ctxt bh1 bh2 =
|
let double_baking ctxt bh1 bh2 =
|
||||||
let contents =
|
let contents =
|
||||||
Anonymous_operations [
|
Single (Double_baking_evidence {bh1 ; bh2}) in
|
||||||
Double_baking_evidence {bh1 ; bh2}
|
|
||||||
] in
|
|
||||||
let branch = Context.branch ctxt in
|
let branch = Context.branch ctxt in
|
||||||
return {
|
return {
|
||||||
shell = { branch } ;
|
shell = { branch } ;
|
||||||
protocol_data = {
|
protocol_data = Operation_data {
|
||||||
contents ;
|
contents ;
|
||||||
signature = None ;
|
signature = None ;
|
||||||
} ;
|
} ;
|
||||||
|
@ -14,11 +14,11 @@ val endorsement:
|
|||||||
?delegate:public_key_hash ->
|
?delegate:public_key_hash ->
|
||||||
?level:Raw_level.t ->
|
?level:Raw_level.t ->
|
||||||
Context.t -> ?signing_context:Context.t ->
|
Context.t -> ?signing_context:Context.t ->
|
||||||
int list -> Operation.t tzresult Lwt.t
|
int list -> Kind.endorsements Operation.t tzresult Lwt.t
|
||||||
|
|
||||||
val miss_signed_endorsement:
|
val miss_signed_endorsement:
|
||||||
?level:Raw_level.t ->
|
?level:Raw_level.t ->
|
||||||
Context.t -> int -> Operation.t tzresult Lwt.t
|
Context.t -> int -> Kind.endorsements Operation.t tzresult Lwt.t
|
||||||
|
|
||||||
val transaction:
|
val transaction:
|
||||||
?fee:Tez.tez ->
|
?fee:Tez.tez ->
|
||||||
@ -29,15 +29,15 @@ val transaction:
|
|||||||
Contract.t ->
|
Contract.t ->
|
||||||
Contract.t ->
|
Contract.t ->
|
||||||
Tez.t ->
|
Tez.t ->
|
||||||
Operation.t tzresult Lwt.t
|
Operation.packed tzresult Lwt.t
|
||||||
|
|
||||||
val delegation:
|
val delegation:
|
||||||
?fee:Tez.tez -> Context.t ->
|
?fee:Tez.tez -> Context.t ->
|
||||||
Contract.t -> public_key_hash option ->
|
Contract.t -> public_key_hash option ->
|
||||||
Operation.t tzresult Lwt.t
|
Operation.packed tzresult Lwt.t
|
||||||
|
|
||||||
val revelation:
|
val revelation:
|
||||||
Context.t -> public_key -> Operation.t tzresult Lwt.t
|
Context.t -> public_key -> Operation.packed tzresult Lwt.t
|
||||||
|
|
||||||
val origination:
|
val origination:
|
||||||
?delegate:public_key_hash ->
|
?delegate:public_key_hash ->
|
||||||
@ -53,20 +53,24 @@ val origination:
|
|||||||
?storage_limit:int64 ->
|
?storage_limit:int64 ->
|
||||||
Context.t ->
|
Context.t ->
|
||||||
Contract.contract ->
|
Contract.contract ->
|
||||||
(Operation.t * Contract.contract) tzresult Lwt.t
|
(Operation.packed * Contract.contract) tzresult Lwt.t
|
||||||
|
|
||||||
val originated_contract:
|
val originated_contract:
|
||||||
Operation.t -> Contract.contract
|
Operation.packed -> Contract.contract
|
||||||
|
|
||||||
val double_endorsement:
|
val double_endorsement:
|
||||||
Context.t -> Operation.t -> Operation.t
|
Context.t ->
|
||||||
-> Operation.t tzresult Lwt.t
|
Kind.endorsements Operation.t ->
|
||||||
|
Kind.endorsements Operation.t ->
|
||||||
|
Operation.packed tzresult Lwt.t
|
||||||
|
|
||||||
val double_baking:
|
val double_baking:
|
||||||
Context.t -> Block_header.block_header -> Block_header.block_header
|
Context.t ->
|
||||||
-> Operation.t tzresult Lwt.t
|
Block_header.block_header ->
|
||||||
|
Block_header.block_header ->
|
||||||
|
Operation.packed tzresult Lwt.t
|
||||||
|
|
||||||
val activation:
|
val activation:
|
||||||
Context.t ->
|
Context.t ->
|
||||||
Signature.Public_key_hash.t -> Blinded_public_key_hash.activation_code ->
|
Signature.Public_key_hash.t -> Blinded_public_key_hash.activation_code ->
|
||||||
Operation.t tzresult Lwt.t
|
Operation.packed tzresult Lwt.t
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
-open Tezos_alpha_test_helpers
|
-open Tezos_alpha_test_helpers
|
||||||
))))
|
))))
|
||||||
|
|
||||||
;;(alias
|
(alias
|
||||||
;; ((name buildtest)
|
((name buildtest)
|
||||||
;; (package tezos-protocol-alpha)
|
(package tezos-protocol-alpha)
|
||||||
;; (deps (main.exe))))
|
(deps (main.exe))))
|
||||||
|
|
||||||
; runs only the `Quick tests
|
; runs only the `Quick tests
|
||||||
(alias
|
(alias
|
||||||
@ -34,10 +34,10 @@
|
|||||||
(package tezos-protocol-alpha)
|
(package tezos-protocol-alpha)
|
||||||
(action (chdir ${ROOT} (run ${exe:main.exe} -v)))))
|
(action (chdir ${ROOT} (run ${exe:main.exe} -v)))))
|
||||||
|
|
||||||
;;(alias
|
(alias
|
||||||
;; ((name runtest)
|
((name runtest)
|
||||||
;; (package tezos-protocol-alpha)
|
(package tezos-protocol-alpha)
|
||||||
;; (deps ((alias runtest_proto_alpha)))))
|
(deps ((alias runtest_proto_alpha)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_indent)
|
((name runtest_indent)
|
||||||
|
Loading…
Reference in New Issue
Block a user