diff --git a/src/lib_p2p/test/test_p2p_banned_peers.ml b/src/lib_p2p/test/test_p2p_banned_peers.ml index dd7ed3df9a14c28349a40afefdc4e9683436223c..e7adcbb3a4d3a68c427b8b9bbb705f33b86834fb 100644 --- a/src/lib_p2p/test/test_p2p_banned_peers.ml +++ b/src/lib_p2p/test/test_p2p_banned_peers.ml @@ -23,12 +23,12 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_banned_peers - Subject: On banning peers and usage of Access Control Lists (ACL) - using sets and POSIX timestamps. +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_banned_peers + Subject: On banning peers and usage of Access Control Lists (ACL) + using sets and POSIX timestamps. *) include Internal_event.Legacy_logging.Make (struct @@ -48,9 +48,8 @@ let baz = a ("baz", "a::2") let peers = [foo; bar; baz] -(* Test. - In an empty ACL of size 10, nobody is tagged as blacklisted or - greylisted yet. +(** In an empty ACL of size 10, nobody is tagged as blacklisted or + greylisted yet. *) let test_empty _ = let empty = P2p_acl.create 10 in @@ -60,9 +59,8 @@ let test_empty _ = peers ; Lwt.return_unit -(* Test. - From an empty ACL of size 10, peers [foo], [bar] and [baz] are - greylisted. +(** From an empty ACL of size 10, peers [foo], [bar] and [baz] are + greylisted. *) let test_ban _ = let set = P2p_acl.create 10 in @@ -75,11 +73,10 @@ let test_ban _ = peers ; Lwt.return_unit -(* Test. - From an empty ACL of size 10, peers [peers] are greylisted since - epoch, then a garbage collection is triggered on the table at the - [Ptime.max] date (e.g., far in the future). All point should have - been removed. +(** From an empty ACL of size 10, peers [peers] are greylisted since + epoch, then a garbage collection is triggered on the table at the + [Ptime.max] date (e.g., far in the future). All point should have + been removed. *) let test_gc _ = let set = P2p_acl.create 10 in diff --git a/src/lib_p2p/test/test_p2p_io_scheduler.ml b/src/lib_p2p/test/test_p2p_io_scheduler.ml index ed19baf12850bf644e9529b1a8d111dc1e9a1860..bfe6868b04700f89fbda70094c32e8014e89c26d 100644 --- a/src/lib_p2p/test/test_p2p_io_scheduler.ml +++ b/src/lib_p2p/test/test_p2p_io_scheduler.ml @@ -24,12 +24,12 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_io_scheduler_ipv4 - Dependencies: src/lib_p2p/test/process.ml - Subject: On I/O scheduling of client-server connections. +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_io_scheduler_ipv4 + Dependencies: src/lib_p2p/test/process.ml + Subject: On I/O scheduling of client-server connections. *) include Internal_event.Legacy_logging.Make (struct @@ -168,10 +168,9 @@ let client ?max_upload_speed ?write_queue_size addr port time _n = let stat = P2p_io_scheduler.stat conn in lwt_log_notice "Client OK %a" P2p_stat.pp stat >>= fun () -> return_unit -(* Test. - Listens to address [addr] on port [port] to open a socket [main_socket]. - Spawns a server on it, and [n] clients connecting to the server. Then, - the server will close all connections. +(** Listens to address [addr] on port [port] to open a socket [main_socket]. + Spawns a server on it, and [n] clients connecting to the server. Then, + the server will close all connections. *) let run ?display_client_stat ?max_download_speed ?max_upload_speed ~read_buffer_size ?read_queue_size ?write_queue_size addr port time n = diff --git a/src/lib_p2p/test/test_p2p_ipv6set.ml b/src/lib_p2p/test/test_p2p_ipv6set.ml index bb16bc9557deb94496814e55f8d6925595f63e9f..0733ec24bc57266cc6f214feedec835cb08725f4 100644 --- a/src/lib_p2p/test/test_p2p_ipv6set.ml +++ b/src/lib_p2p/test/test_p2p_ipv6set.ml @@ -23,11 +23,11 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_ipv6set - Subject: Sets of IPV6 addresses (as keys in Patricia Trees). +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_ipv6set + Subject: Sets of IPV6 addresses (as keys in Patricia Trees). *) include Internal_event.Legacy_logging.Make (struct @@ -58,9 +58,7 @@ let of_list l = P2p_acl.IpSet.empty l -(* Test. - An empty set does not contain any IP address. -*) +(** An empty set does not contain any IP address. *) let test_empty _ = let addrs = List.map a ["::"; "ffff::"; "a::2"] in List.iter @@ -71,10 +69,9 @@ let test_empty _ = (P2p_acl.IpSet.mem addr P2p_acl.IpSet.empty)) addrs -(* Test. - Adds address prefixes to the set, and verifies that addresses with - that prefix (resp. without that prefix) are included (resp. not - included). +(** Adds address prefixes to the set, and verifies that addresses with + that prefix (resp. without that prefix) are included (resp. not + included). *) let test_inclusion _ = let set = @@ -120,9 +117,7 @@ let test_inclusion _ = assert_equal ~msg:__LOC__ false (P2p_acl.IpSet.mem (a "b111:8000::1") set) ; assert_equal ~msg:__LOC__ false (P2p_acl.IpSet.mem (a "1234:5678::100") set) -(* Test. - Contiguous prefixes preserve consistency of IP sets. -*) +(** Contiguous prefixes preserve consistency of IP sets. *) let test_contiguous _ = let set = of_list [p "::/1"; p "8000::/1"] in List.iter @@ -134,9 +129,8 @@ module PSet = Set.Make (Ipaddr.V6.Prefix) let print_pset ppf pset = PSet.iter (fun p -> Format.fprintf ppf "%a " Ipaddr.V6.Prefix.pp p) pset -(* Test. - A set created with [Pset.of_list] has the same elements as if it - was successively created with [Pset.add] from [Pset.empty]. +(** A set created with [Pset.of_list] has the same elements as if it + was successively created with [Pset.add] from [Pset.empty]. *) let test_fold _ = let addr_list = [p "::/1"; p "8000::/2"; p "ffff:ffff::/32"] in @@ -152,9 +146,7 @@ let test_fold _ = let print_list ppf l = List.iter (fun p -> Format.fprintf ppf "%a " Ipaddr.V6.Prefix.pp p) l -(* Test. - Creating a list from a set preserves the elements of the set. -*) +(** Creating a list from a set preserves the elements of the set. *) let test_to_list _ = let to_list s = P2p_acl.IpSet.fold (fun k _v acc -> k :: acc) s [] in let list_eq = List.for_all2 (fun x y -> Ipaddr.V6.Prefix.compare x y = 0) in diff --git a/src/lib_p2p/test/test_p2p_peerset.ml b/src/lib_p2p/test/test_p2p_peerset.ml index aad3060a2970b5cf688fc882c4dbe897813e5ec4..98ab84656ec369d3d9900229ba9127bd315d7bc7 100644 --- a/src/lib_p2p/test/test_p2p_peerset.ml +++ b/src/lib_p2p/test/test_p2p_peerset.ml @@ -23,12 +23,12 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_peerset - Subject: On banning peers and usage of Access Control Lists (ACL) - using FIFO caches filled with peers' ids. +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_peerset + Subject: On banning peers and usage of Access Control Lists (ACL) + using FIFO caches filled with peers' ids. *) include Internal_event.Legacy_logging.Make (struct @@ -39,9 +39,7 @@ let assert_equal_bool ~msg a b = if a <> b then Alcotest.fail msg let a s = P2p_peer.Id.hash_string [s] -(* Test. - An empty ACL (built as a FIFO cache) initially contains no peer. -*) +(** An empty ACL (built as a FIFO cache) initially contains no peer. *) let test_empty _ = let peers = List.map a ["foo"; "bar"; "baz"] in let empty = P2p_acl.PeerFIFOCache.create 10 in @@ -53,9 +51,7 @@ let test_empty _ = (P2p_acl.PeerFIFOCache.mem empty peer)) peers -(* Test. - From an empty ACL cache, we successively add "foo", "bar", "baz". -*) +(** From an empty ACL cache, we successively add "foo", "bar", "baz". *) let test_add _ = let peers = List.map a ["foo"; "bar"; "baz"] in let set = P2p_acl.PeerFIFOCache.create 10 in @@ -65,10 +61,9 @@ let test_add _ = assert_equal_bool ~msg:__LOC__ true (P2p_acl.PeerFIFOCache.mem set peer)) peers -(* Test. - From an empty ACL cache, we successively add "foo", "bar", "baz". - We test that "bar" exists, then remove it. Hence, it does not exist - in the cache anymore. +(** From an empty ACL cache, we successively add "foo", "bar", "baz". + We test that "bar" exists, then remove it. Hence, it does not exist + in the cache anymore. *) let test_remove _ = let peers = List.map a ["foo"; "bar"; "baz"] in @@ -81,10 +76,9 @@ let test_remove _ = false (P2p_acl.PeerFIFOCache.mem set (a "bar")) -(* Test. - An initial cache of size 3 is filled with 3 peer ids. Additionaly, - we add "foo" and "zor", hence they are cached but not for "bar" - anymore. "baz" is the FIFO head and so on... +(** An initial cache of size 3 is filled with 3 peer ids. Additionaly, + we add "foo" and "zor", hence they are cached but not for "bar" + anymore. "baz" is the FIFO head and so on... *) let test_LRU_overflow _ = let peers = List.map a ["foo"; "bar"; "baz"] in diff --git a/src/lib_p2p/test/test_p2p_pool.ml b/src/lib_p2p/test/test_p2p_pool.ml index 1c89439fc07069e7d63d8c3e981b4ba5974a1f5e..36a5efeb6923e5a31ab5c9752009d70b10d16d34 100644 --- a/src/lib_p2p/test/test_p2p_pool.ml +++ b/src/lib_p2p/test/test_p2p_pool.ml @@ -24,14 +24,14 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_ipv6set - Dependencies: src/lib_p2p/test/process.ml - Subject: Testing of the Pool - Each test launches nodes in separate process, each node - has its own pool and is given a function to be executed. +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_ipv6set + Dependencies: src/lib_p2p/test/process.ml + Subject: Testing of the Pool + Each test launches nodes in separate process, each node + has its own pool and is given a function to be executed. *) include Internal_event.Legacy_logging.Make (struct @@ -259,9 +259,8 @@ let detach_nodes ?prefix ?timeout ?min_connections ?max_connections type error += Connect | Write | Read -(* Test. - Detaches [!client] nodes. Each of them will send a [Ping] to each - other node, then await for reading one from each other node. +(** Detaches [!client] nodes. Each of them will send a [Ping] to each + other node, then await for reading one from each other node. *) module Simple = struct let rec connect ~timeout connect_handler pool point = @@ -372,11 +371,10 @@ module Simple = struct let run points = detach_nodes (fun _ -> node) points end -(* Test. - Detaches a number of nodes (which is [!clients]). Each of them will - connect to each other node at random points in time, to send a - ping, await for a message, then disconnect. This process is - repeated [repeat] times. +(** Detaches a number of nodes (which is [!clients]). Each of them will + connect to each other node at random points in time, to send a + ping, await for a message, then disconnect. This process is + repeated [repeat] times. *) module Random_connections = struct let rec connect_random connect_handler pool total rem point n = @@ -421,12 +419,11 @@ module Random_connections = struct let run points repeat = detach_nodes (fun _ _ -> node repeat) points end -(* Test. - Detaches a number of nodes. Each will connect to all other nodes - (peers) of the pool, sync, write garbled data, then await for - reading a message. Their process will finish whenever all - connections are closed. It is asserted that each closed connection - comes with an error. +(** Detaches a number of nodes. Each will connect to all other nodes + (peers) of the pool, sync, write garbled data, then await for + reading a message. Their process will finish whenever all + connections are closed. It is asserted that each closed connection + comes with an error. *) module Garbled = struct let is_connection_closed = function @@ -717,14 +714,13 @@ module Overcrowded = struct let trusted i points = if i = 0 then points else [List.hd points] - (* Test. - Detaches a number of nodes: one of them is the target (its - max_incoming_connections is set to zero), and all the rest are - clients (knowing only the target). The target will be overcrowded - by the other clients connecting to it. All clients should have - their pool populated with the list of points. Specifically for - this test function, each client use p2p v.1 and check that they - eventually know all other nodes thanks to the node reply. + (** Detaches a number of nodes: one of them is the target (its + max_incoming_connections is set to zero), and all the rest are + clients (knowing only the target). The target will be overcrowded + by the other clients connecting to it. All clients should have + their pool populated with the list of points. Specifically for + this test function, each client use p2p v.1 and check that they + eventually know all other nodes thanks to the node reply. *) let run points = (* setting connections to -1 ensure there will be no random @@ -743,11 +739,10 @@ module Overcrowded = struct points ~trusted - (* Test. - Same as previously but by mixing different protocol version - tags. Half the clients do as in run and half of the clients use - p2p v.0 and check that they didn't receive new nodes (meaning - that [target] actually sent a Nack_v_0. + (** Same as previously but by mixing different protocol version + tags. Half the clients do as in run and half of the clients use + p2p v.0 and check that they didn't receive new nodes (meaning + that [target] actually sent a Nack_v_0. *) let run_mixed_versions points = let prefix = function @@ -774,11 +769,10 @@ module Overcrowded = struct ~trusted end -(* Test. - Detaches a number of nodes (one target, the rest being clients) on - a different network. It is asserted that the connection must be - rejected due to the fact that the target is not on a common - network. +(** Detaches a number of nodes (one target, the rest being clients) on + a different network. It is asserted that the connection must be + rejected due to the fact that the target is not on a common + network. *) module No_common_network = struct let rec connect ?iter_count ~timeout connect_handler pool point = diff --git a/src/lib_p2p/test/test_p2p_socket.ml b/src/lib_p2p/test/test_p2p_socket.ml index 34fc70f619238270a5005e51c98bab3bf0f0d530..1148b511ab00d6759ace2956879b1bad81dcee9f 100644 --- a/src/lib_p2p/test/test_p2p_socket.ml +++ b/src/lib_p2p/test/test_p2p_socket.ml @@ -24,12 +24,12 @@ (* *) (*****************************************************************************) -(* Testing - ------- - Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_socket_ipv4 - Dependencies: src/lib_p2p/test/process.ml - Subject: Sockets and client-server communications. +(** Testing + ------- + Component: P2P + Invocation: dune build @src/lib_p2p/test/runtest_p2p_socket_ipv4 + Dependencies: src/lib_p2p/test/process.ml + Subject: Sockets and client-server communications. *) include Internal_event.Legacy_logging.Make (struct @@ -210,9 +210,8 @@ let is_decoding_error = function log_notice "Error: %a" pp_print_error err ; false -(* Test. - Writing then reading through the same pipe a chunk of message [msg] - with encryption/decryption. +(** Writing then reading through the same pipe a chunk of message [msg] + with encryption/decryption. *) module Crypto_test = struct (* maximal size of the buffer *) @@ -320,11 +319,10 @@ module Crypto_test = struct Format.kasprintf Stdlib.failwith "%a" pp_print_error error)) end -(* Test. - Spawns a client and a server. After the client getting connected to - the server, it reads a message [simple_msg] sent by the server and - stores in [msg] of fixed same size. It asserts that both messages - and identical. +(** Spawns a client and a server. After the client getting connected to + the server, it reads a message [simple_msg] sent by the server and + stores in [msg] of fixed same size. It asserts that both messages + and identical. *) module Low_level = struct let simple_msg = Rand.generate (1 lsl 4) @@ -347,11 +345,10 @@ module Low_level = struct let run _dir = run_nodes client server end -(* Test. - Spawns a client and a server. The client connects to the server - using identity [id2], this identity is checked on server-side. The - server sends a Nack message with no rejection motive. The client - asserts that its connection has been rejected by Nack. +(** Spawns a client and a server. The client connects to the server + using identity [id2], this identity is checked on server-side. The + server sends a Nack message with no rejection motive. The client + asserts that its connection has been rejected by Nack. *) module Nack = struct let encoding = Data_encoding.bytes @@ -386,10 +383,9 @@ module Nack = struct let run _dir = run_nodes client server end -(* Test. - Spawns a client and a server. A client trying to connect to a - server receives and Ack message but replies with a Nack. The - connection is hence rejected by the client. +(** Spawns a client and a server. A client trying to connect to a + server receives and Ack message but replies with a Nack. The + connection is hence rejected by the client. *) module Nacked = struct let encoding = Data_encoding.bytes @@ -410,11 +406,10 @@ module Nacked = struct let run _dir = return_unit end -(* Test. - Spawns a client and a server. A client tries to connect to a - server. Both parties acknowledge. The server sends [simple_msg], - while the client sends [simple_msg2]. Both messages are checked for - consistency. Then, the connection is closed. +(** Spawns a client and a server. A client tries to connect to a + server. Both parties acknowledge. The server sends [simple_msg], + while the client sends [simple_msg2]. Both messages are checked for + consistency. Then, the connection is closed. *) module Simple_message = struct let encoding = Data_encoding.bytes @@ -452,11 +447,10 @@ module Simple_message = struct let run _dir = run_nodes client server end -(* Test. - Spawns a client and a server. A client tries to connect to a - server. Both parties acknowledge. The server sends [simple_msg] and - the client sends [simple_msg2] with a binary chunk size of 21. Both - messages are checked for consistency. +(** Spawns a client and a server. A client tries to connect to a + server. Both parties acknowledge. The server sends [simple_msg] and + the client sends [simple_msg2] with a binary chunk size of 21. Both + messages are checked for consistency. *) module Chunked_message = struct let encoding = Data_encoding.bytes @@ -494,9 +488,8 @@ module Chunked_message = struct let run _dir = run_nodes client server end -(* Test. - Two messages of size 131072 bytes are randomly generated. After - successful connection, both parties send the latter messages. +(** Two messages of size 131072 bytes are randomly generated. After + successful connection, both parties send the latter messages. *) module Oversized_message = struct let encoding = Data_encoding.bytes @@ -534,10 +527,9 @@ module Oversized_message = struct let run _dir = run_nodes client server end -(* Test. - After then successful connection of a client to a server, the client - attempts to read a message. However, the server decides to close - the connection. +(** After then successful connection of a client to a server, the client + attempts to read a message. However, the server decides to close + the connection. *) module Close_on_read = struct let encoding = Data_encoding.bytes @@ -566,10 +558,9 @@ module Close_on_read = struct let run _dir = run_nodes client server end -(* Test. - After the successful connection of a client to a server, the client - attempts to send a message. However, the server decides to close - the connection. +(** After the successful connection of a client to a server, the client + attempts to send a message. However, the server decides to close + the connection. *) module Close_on_write = struct let encoding = Data_encoding.bytes @@ -600,13 +591,11 @@ module Close_on_write = struct let run _dir = run_nodes client server end -(* Test. - A dummy message is generated into [garbled_msg]. After the - successful connection of a client to a server, the server sends - [garbled_msg] and waits by reading a close connection is declared - by the client. On the side of the client, it is asserted that the - message cannot be decoded. - +(** A dummy message is generated into [garbled_msg]. After the + successful connection of a client to a server, the server sends + [garbled_msg] and waits by reading a close connection is declared + by the client. On the side of the client, it is asserted that the + message cannot be decoded. *) module Garbled_data = struct let encoding =