Gossipsub/Test: add test for score duplication bug

Adds a test for MR !13156 (merged).

The setup for the test seems more complicated than needed, but that's what I have for now.

Side remark: These MRs concern P3 which is not enabled on the DAL. (But they will be useful if/when P3 is enabled.)

Manually testing the MR

dune exec src/lib_gossipsub/test/main.exe -- --file test_unit.ml -t "Gossipsub: Test message duplicate score bug" -i

Then re-run the test on a commit before !13156 (merged), or on this patch:

diff --git a/src/lib_gossipsub/gossipsub_automaton.ml b/src/lib_gossipsub/gossipsub_automaton.ml
index 38466dd227..95d2a4d98c 100644
--- a/src/lib_gossipsub/gossipsub_automaton.ml
+++ b/src/lib_gossipsub/gossipsub_automaton.ml
@@ -1136,12 +1136,12 @@ module Make (C : AUTOMATON_CONFIG) :
           Message_cache.get_first_seen_time_and_senders message_id message_cache
         with
         | None -> unit
-        | Some (validated, peers) ->
+        | Some (validated, _peers) ->
             let* () =
-              if Peer.Set.mem sender peers then fun x -> (x, ())
-              else
-                update_score sender (fun stats ->
-                    Score.duplicate_message_delivered stats topic validated)
+              (* if Peer.Set.mem sender peers then fun x -> (x, ()) *)
+              (* else *)
+              update_score sender (fun stats ->
+                  Score.duplicate_message_delivered stats topic validated)
             in
             fail Already_received
       in

Merge request reports

Loading