From dde6addbfb092872baf5452db4ccbd66a63bdc61 Mon Sep 17 00:00:00 2001 From: Marco Stronati Date: Tue, 22 May 2018 16:58:14 +0200 Subject: [PATCH] Tests: add Context.{get_seed,get_seed_nonce_hash} --- src/proto_alpha/lib_protocol/test/helpers/context.ml | 11 +++++++++++ src/proto_alpha/lib_protocol/test/helpers/context.mli | 5 +++++ .../lib_protocol/test/helpers/incremental.ml | 1 + .../lib_protocol/test/helpers/incremental.mli | 1 + 4 files changed, 18 insertions(+) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 0a8be9e7a..18de74458 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -82,6 +82,17 @@ let get_bakers ctxt = (fun p -> p.Alpha_services.Delegate.Baking_rights.delegate) bakers) +let get_seed_nonce_hash ctxt = + let header = + match ctxt with + | B { header } -> header + | I i -> Incremental.header i in + match header.protocol_data.contents.seed_nonce_hash with + | None -> failwith "Ne committed nonce" + | Some hash -> return hash + +let get_seed ctxt = Alpha_services.Seed.get rpc_ctxt ctxt + let get_constants b = Alpha_services.Constants.all rpc_ctxt b diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 56b4eb27a..673338d2a 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -24,6 +24,11 @@ val get_endorser: t -> int -> public_key_hash tzresult Lwt.t val get_bakers: t -> public_key_hash list tzresult Lwt.t +val get_seed_nonce_hash: t -> Nonce_hash.t tzresult Lwt.t + +(** Returns the seed of the cycle to which the block belongs to. *) +val get_seed: t -> Seed.seed tzresult Lwt.t + (** Returns all the constants of the protocol *) val get_constants: t -> Constants.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml index 2c63a54ce..13c83327f 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -20,6 +20,7 @@ type t = { type incremental = t let predecessor { predecessor ; _ } = predecessor +let header st = st.header let level st = st.header.shell.level diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.mli b/src/proto_alpha/lib_protocol/test/helpers/incremental.mli index de6597905..50e737b31 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.mli @@ -14,6 +14,7 @@ type t type incremental = t val predecessor: incremental -> Block.t +val header: incremental -> Block_header.t val level: incremental -> int32