Mavryk_p2p_test_common.P2p_test_utils
This module provides functions used for tests.
val wait_pred :
?timeout:'a timeout_t ->
pred:('a -> bool) ->
arg:'a ->
unit ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
wait_pred
wait until pred arg
is true. If pred
is not satisfy after timeout.time
seconds a Timeout (timeout.msg arg)
error is raised.
val wait_pred_s :
?timeout:'a timeout_t ->
pred:('a -> bool Lwt.t) ->
arg:'a ->
unit ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
Same as wait_pred
.
val wait_conns :
?timeout:float ->
pool:('a, 'b, 'c) Mavryk_p2p.P2p_pool.t ->
int ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
Based on wait_pred
. wait_conns ~pool n
waits until at least n
connections are actives in ~pool
.
val connect_all :
?timeout:Mavryk_base.TzPervasives.Time.System.Span.t ->
('a, 'b, 'c) Mavryk_p2p.P2p_connect_handler.t ->
Mavryk_base.TzPervasives.P2p_point.Id.t list ->
('a, 'b, 'c) Mavryk_p2p.P2p_conn.t list Mavryk_base.TzPervasives.tzresult
Lwt.t
connect_all connect_handler points
establishes the connections to points
using connect_handler
and returns them. If one connection need more than ?timeout
seconds to be established, the function fails with Timeout
error.
val close_active_conns : ('a, 'b, 'c) Mavryk_p2p.P2p_pool.t -> unit Lwt.t
close_active_conns pool@
closes all actives connections of the pool. This function waits until the connections are effectively closed.
val version : Mavryk_base.Network_version.t
val conn_meta_config :
unit Mavryk_base.TzPervasives.P2p_params.conn_meta_config
val proof_of_work_target : Mavryk_crypto.Crypto_box.pow_target
val id1 : Mavryk_base.TzPervasives.P2p_identity.t Lwt.t
val id2 : Mavryk_base.TzPervasives.P2p_identity.t Lwt.t
val run_nodes :
addr:Mavryk_base.TzPervasives.P2p_addr.t ->
?port:int ->
((unit, unit) Process.Channel.t ->
Mavryk_p2p.P2p_io_scheduler.t ->
Ipaddr.V6.t ->
int ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t) ->
((unit, unit) Process.Channel.t ->
Mavryk_p2p.P2p_io_scheduler.t ->
Lwt_unix.file_descr ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t) ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t
val run_nodes_fd :
addr:Mavryk_base.TzPervasives.P2p_addr.t ->
?port:int ->
((unit, unit) Process.Channel.t ->
Ipaddr.V6.t ->
int ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t) ->
((unit, unit) Process.Channel.t ->
Lwt_unix.file_descr ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t) ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t
val raw_accept :
Mavryk_p2p.P2p_io_scheduler.t ->
Lwt_unix.file_descr ->
(Mavryk_p2p.P2p_io_scheduler.connection
* (Mavryk_base.TzPervasives.P2p_addr.t * int),
Mavryk_p2p.P2p_fd.accept_error)
Stdlib.result
Lwt.t
val accept :
?id:Mavryk_base.TzPervasives.P2p_identity.t Lwt.t ->
?proof_of_work_target:Mavryk_crypto.Crypto_box.pow_target ->
Mavryk_p2p.P2p_io_scheduler.t ->
Lwt_unix.file_descr ->
(unit Mavryk_base.TzPervasives.P2p_connection.Info.t
* unit Mavryk_p2p.P2p_socket.authenticated_connection,
Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t
val raw_connect :
Mavryk_p2p.P2p_io_scheduler.t ->
Mavryk_base.TzPervasives.P2p_addr.t ->
int ->
(Mavryk_p2p.P2p_io_scheduler.connection, Mavryk_p2p.P2p_fd.connect_error)
Stdlib.result
Lwt.t
val connect :
?proof_of_work_target:Mavryk_crypto.Crypto_box.pow_target ->
Mavryk_p2p.P2p_io_scheduler.t ->
Mavryk_base.TzPervasives.P2p_addr.t ->
int ->
Mavryk_base.TzPervasives.P2p_identity.t ->
(unit Mavryk_base.TzPervasives.P2p_connection.Info.t
* unit Mavryk_p2p.P2p_socket.authenticated_connection,
Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t
val sync :
(unit, unit) Process.Channel.t ->
(unit, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace)
Stdlib.result
Lwt.t