Alpha: changes needed for test framework

This commit is contained in:
Grégoire Henry 2018-06-04 14:46:50 +02:00
parent bd3a9fabe5
commit 4105467603
7 changed files with 32 additions and 3 deletions

View File

@ -335,7 +335,6 @@ module Constants : sig
} }
val parametric_encoding: parametric Data_encoding.t val parametric_encoding: parametric Data_encoding.t
val parametric: context -> parametric val parametric: context -> parametric
val preserved_cycles: context -> int val preserved_cycles: context -> int
val blocks_per_cycle: context -> int32 val blocks_per_cycle: context -> int32
val blocks_per_commitment: context -> int32 val blocks_per_commitment: context -> int32
@ -361,6 +360,7 @@ module Constants : sig
val block_security_deposit: context -> Tez.t val block_security_deposit: context -> Tez.t
val endorsement_security_deposit: context -> Tez.t val endorsement_security_deposit: context -> Tez.t
(** All constants: fixed and parametric *)
type t = { type t = {
fixed : fixed ; fixed : fixed ;
parametric : parametric ; parametric : parametric ;
@ -577,6 +577,12 @@ module Contract : sig
context -> contract -> string -> (context * Script_repr.expr option) tzresult Lwt.t context -> contract -> string -> (context * Script_repr.expr option) tzresult Lwt.t
end end
(**/**)
(* Only for testing *)
type origination_nonce
val initial_origination_nonce : Operation_hash.t -> origination_nonce
val originated_contract : origination_nonce -> contract
end end
module Delegate : sig module Delegate : sig
@ -701,6 +707,8 @@ module Block_header : sig
type raw = Block_header.t type raw = Block_header.t
type shell_header = Block_header.shell_header type shell_header = Block_header.shell_header
val raw: block_header -> raw
val hash: block_header -> Block_hash.t val hash: block_header -> Block_hash.t
val hash_raw: raw -> Block_hash.t val hash_raw: raw -> Block_hash.t
@ -831,6 +839,7 @@ module Operation : sig
shell: Operation.shell_header ; shell: Operation.shell_header ;
protocol_data: protocol_data ; protocol_data: protocol_data ;
} }
val raw: operation -> raw
val encoding: operation Data_encoding.t val encoding: operation Data_encoding.t
val hash: operation -> Operation_hash.t val hash: operation -> Operation_hash.t

View File

@ -194,14 +194,14 @@ let check_endorsements_rights c level slots =
let paying_priorities c = let paying_priorities c =
0 --> (Constants.first_free_baking_slot c - 1) 0 --> (Constants.first_free_baking_slot c - 1)
type error += Incorect_priority type error += Incorrect_priority
let endorsement_reward ctxt ~block_priority:prio = let endorsement_reward ctxt ~block_priority:prio =
if Compare.Int.(prio >= 0) if Compare.Int.(prio >= 0)
then then
Lwt.return Lwt.return
Tez.(Constants.endorsement_reward ctxt /? (Int64.(succ (of_int prio)))) Tez.(Constants.endorsement_reward ctxt /? (Int64.(succ (of_int prio))))
else fail Incorect_priority else fail Incorrect_priority
let baking_priorities c level = let baking_priorities c level =
let rec f priority = let rec f priority =

View File

@ -55,6 +55,13 @@ let protocol_data_encoding =
contents_encoding contents_encoding
(obj1 (req "signature" Signature.encoding))) (obj1 (req "signature" Signature.encoding)))
let raw { shell ; protocol_data ; } =
let protocol_data =
Data_encoding.Binary.to_bytes_exn
protocol_data_encoding
protocol_data in
{ Block_header.shell ; protocol_data }
let unsigned_encoding = let unsigned_encoding =
let open Data_encoding in let open Data_encoding in
merge_objs merge_objs

View File

@ -28,6 +28,8 @@ type block_header = t
type raw = Block_header.t type raw = Block_header.t
type shell_header = Block_header.shell_header type shell_header = Block_header.shell_header
val raw: block_header -> raw
val encoding: block_header Data_encoding.encoding val encoding: block_header Data_encoding.encoding
val raw_encoding: raw Data_encoding.t val raw_encoding: raw Data_encoding.t
val contents_encoding: contents Data_encoding.t val contents_encoding: contents Data_encoding.t

View File

@ -66,5 +66,6 @@ val endorsement_reward:
val errors: val errors:
'a #RPC_context.simple -> 'a -> Data_encoding.json_schema shell_tzresult Lwt.t 'a #RPC_context.simple -> 'a -> Data_encoding.json_schema shell_tzresult Lwt.t
(** Returns all the constants of the protocol *)
val all: val all:
'a #RPC_context.simple -> 'a -> Constants.t shell_tzresult Lwt.t 'a #RPC_context.simple -> 'a -> Constants.t shell_tzresult Lwt.t

View File

@ -451,6 +451,14 @@ let protocol_data_encoding = Encoding.protocol_data_encoding
let unsigned_operation_encoding = Encoding.unsigned_operation_encoding let unsigned_operation_encoding = Encoding.unsigned_operation_encoding
let internal_operation_encoding = Encoding.internal_operation_encoding let internal_operation_encoding = Encoding.internal_operation_encoding
let raw { shell ; protocol_data } =
let proto =
Data_encoding.Binary.to_bytes_exn
protocol_data_encoding
protocol_data in
{ Operation.shell ; proto }
let acceptable_passes op = let acceptable_passes op =
match op.protocol_data.contents with match op.protocol_data.contents with
| Sourced_operation (Consensus_operation _) -> [0] | Sourced_operation (Consensus_operation _) -> [0]

View File

@ -111,6 +111,8 @@ val contents_encoding: contents Data_encoding.t
val protocol_data_encoding: protocol_data Data_encoding.t val protocol_data_encoding: protocol_data Data_encoding.t
val unsigned_operation_encoding: (Operation.shell_header * contents) Data_encoding.t val unsigned_operation_encoding: (Operation.shell_header * contents) Data_encoding.t
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