test(multiplayer): grade §6.4's reconnect from the returning player's side

The disconnect scenario only ever asserted the server's bookkeeping, and
the client's half was failing every run. run_disconnect_host_check ticked
60 physics frames past the reclaim and then shut the server down, so the
reconnecting client - whose wiring check waits a 2.0s settle before it
looks at anything - had its peer torn out from under it and reported
"current_scene is not NetworkedMatch after 2.0s". The host printed PASS
throughout, and the host was the side anyone read.

The hold is now a real window (8s), and the host also asserts that the
reconnected player's input reaches the server and moves the ship the
server owns - every other assertion there is slot bookkeeping that would
hold identically for a client whose input pipeline came back dead. Both
position and connection state are sampled while the peer is still
connected: the client leaves on its own schedule, and an end-of-hold
sample reported still_connected=false for a good run.

New --role=client-reconnect asserts the returning player is not a
spectator, owns a slot with its own peer_id, has a real ship, rejoined a
live match with the clock already known (§6.2 step 2's bootstrap), and
can still drive. That set is chosen because a stale _last_match_config
once made a reconnecting player a spectator, and that bug was visible in
this scenario's own logs while it reported PASS.

Verified 3/3 both sides. Control: rejoining while the slot is still
occupied fails on is_player=false - and since the first control run
reported it as the generic "lost its ship mid-drive", the spectator case
is now diagnosed before the drive rather than after.
This commit is contained in:
Josh Creek
2026-08-21 16:25:25 +01:00
parent 866efa0d9b
commit 5714829c13
3 changed files with 158 additions and 9 deletions
+21
View File
@@ -67,6 +67,18 @@ func _ready() -> void:
return
print("SMOKE: joining ...")
MatchNet.welcomed.connect(_on_client_welcomed)
"client-reconnect":
# Same name as --role=client on purpose: §6.4 keys the reservation
# to it. Run this as the SECOND life against --role=host-disconnect,
# after a plain `client` has joined and dropped.
MatchNet.local_player_name = "NetTest"
var rerr := NetworkManager.join("127.0.0.1", PORT)
if rerr != OK:
print("SMOKE FAIL: join() failed: %s" % error_string(rerr))
get_tree().quit(1)
return
print("SMOKE: rejoining to reclaim a reserved slot ...")
MatchNet.welcomed.connect(_on_reconnect_welcomed)
"client-spectator":
# A name nobody reserved, so the server has no slot for it.
MatchNet.local_player_name = "Watcher"
@@ -136,6 +148,15 @@ func _on_disconnect_host_player_joined(_peer_id: int, _name: String) -> void:
hooks.run_disconnect_host_check.call_deferred(_drive_seconds)
func _on_reconnect_welcomed() -> void:
MatchNet.welcomed.disconnect(_on_reconnect_welcomed)
print("SMOKE: reconnecting client loading networked_match.tscn ...")
get_tree().change_scene_to_file.call_deferred("res://scenes/networked_match.tscn")
var hooks := preload("res://tests/networked_match_test_hooks.gd").new()
get_tree().root.add_child.call_deferred(hooks)
hooks.run_reconnect_client_check.call_deferred(_settle_seconds, _drive_seconds)
func _on_spectator_welcomed() -> void:
MatchNet.welcomed.disconnect(_on_spectator_welcomed)
get_tree().change_scene_to_file.call_deferred("res://scenes/networked_match.tscn")