diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index b5baf21c0ba3328b1c46fcc5f93b4d2c61926b5f..0985d18178c2a59d2e711faf2f02482de9b705f1 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -750,6 +750,24 @@ let get_chain_block_context_sc_rollups_all ?(chain = "main") ?(block = "head") ["chains"; chain; "blocks"; block; "context"; "sc_rollups"; "all"] Fun.id +let get_chain_block_context_sc_rollups_sc_rollup_game ?(chain = "main") + ?(block = "head") ~staker sc_rollup () = + make + GET + ~query_string:[("staker", staker)] + [ + "chains"; + chain; + "blocks"; + block; + "context"; + "sc_rollups"; + "sc_rollup"; + sc_rollup; + "game"; + ] + Fun.id + let get_chain_block_context_sc_rollups_all_inbox ?(chain = "main") ?(block = "head") () = make diff --git a/tezt/lib_tezos/RPC.mli b/tezt/lib_tezos/RPC.mli index c6b1af1d62eb7c2f5f5678f918bf0db0370c66ee..37992844ac2b1869da7369e178aa6c578d46e0e3 100644 --- a/tezt/lib_tezos/RPC.mli +++ b/tezt/lib_tezos/RPC.mli @@ -758,6 +758,10 @@ val get_chain_block_context_contract_all_ticket_balances : val get_chain_block_context_sc_rollups_all : ?chain:string -> ?block:string -> unit -> JSON.t t +(** RPC: [GET chains//blocks//context/sc_rollups/sc_rollup/game?staker=[stacker]] *) +val get_chain_block_context_sc_rollups_sc_rollup_game : + ?chain:string -> ?block:string -> staker:string -> string -> unit -> JSON.t t + (** RPC: [GET chains//blocks//context/sc_rollups/all/inbox] *) val get_chain_block_context_sc_rollups_all_inbox : ?chain:string -> ?block:string -> unit -> JSON.t t diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 09119c80f8121b073cc979f394ab71630388aa43..44a45386e162bdfedbb32df4cb24de4e78771a7d 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -949,6 +949,20 @@ let sc_rollup_node_simulate sc_rollup_node sc_rollup_client _sc_rollup node ~msg:(rex "Maximum number of messages reached for commitment period") sim_result +let bake_until ?hook cond n client = + assert (0 <= n) ; + let rec go i = + if 0 < i then + let* cond = cond client in + if cond then + let* () = match hook with None -> unit | Some hook -> hook i in + let* () = Client.bake_for_and_wait client in + go (i - 1) + else return () + else return () + in + go n + let bake_levels ?hook n client = fold n () @@ fun i () -> let* () = match hook with None -> unit | Some hook -> hook i in @@ -2668,6 +2682,7 @@ let test_refutation_scenario ?commitment_period ?challenge_window ~variant ~kind let bootstrap1_key = Constant.bootstrap1.public_key_hash in let bootstrap2_key = Constant.bootstrap2.public_key_hash in + let game_started = ref false in let conflict_detected = ref false in let _ = let* () = wait_for_conflict_detected sc_rollup_node in @@ -2712,7 +2727,23 @@ let test_refutation_scenario ?commitment_period ?challenge_window ~variant ~kind let level = after_inputs_level + i in stop_loser level in - let* () = bake_levels ~hook (final_level - List.length inputs) client in + let keep_going client = + let* game = + RPC.Client.call client + @@ RPC.get_chain_block_context_sc_rollups_sc_rollup_game + ~staker:bootstrap1_key + sc_rollup_address + () + in + if !game_started then return @@ not (JSON.is_null game) + else ( + game_started := not @@ JSON.is_null game ; + return true) + in + + let* () = + bake_until ~hook keep_going (final_level - List.length inputs) client + in if not !conflict_detected then Test.fail "Honest node did not detect the conflict" ;