chore: release version 2.3.5 and refactor lobby
Bump export_presets.cfg version to 2.3.5. Update CHANGELOG_DRAFT.md. Refactor lobby.gd into LobbyChat, LobbyMainMenu, LobbyRoomList, LobbyRoom. Move Nakama config to environment variables in nakama_manager.gd. Derive auth_manager.gd encryption key from OS.get_unique_id().sha256_text(). Remove Steam email auth fallback. Require auth ticket. Make GachaManager.pull() async in gacha_panel.gd. Remove dummy wallet seeding. Add store_type to IAP payload. Validate IAP receipts server-side in economy.lua. Register gacha module in main.lua. Clean backend_service.gd stubs. Fix featured_banners type safety in gacha_manager.gd. Guards non-array responses. Move tiles_armagedon_a1.res to assets/models/meshes/. Fix import fallback_path.
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
# tests/test_sync_desync.gd
|
||||
# Tests for Task [035]: Sync Desync Thresholds
|
||||
# Validates position/velocity deviation enforcement between client and server
|
||||
|
||||
extends GutTest
|
||||
|
||||
var sync_manager: Node
|
||||
|
||||
func before_all():
|
||||
gut.p("=== Sync Desync Tests [Task 035] ===")
|
||||
|
||||
func before_each():
|
||||
sync_manager = preload("res://scripts/managers/game_state_manager.gd").new()
|
||||
add_child(sync_manager)
|
||||
|
||||
func after_each():
|
||||
if sync_manager:
|
||||
sync_manager.queue_free()
|
||||
|
||||
# Test 1: Position deviation threshold is set
|
||||
func test_position_deviation_threshold_set():
|
||||
var threshold = _get_position_deviation_threshold()
|
||||
assert_true(threshold > 0, "Position deviation threshold should be set")
|
||||
|
||||
# Test 2: Velocity deviation threshold is set
|
||||
func test_velocity_deviation_threshold_set():
|
||||
var threshold = _get_velocity_deviation_threshold()
|
||||
assert_true(threshold > 0, "Velocity deviation threshold should be set")
|
||||
|
||||
# Test 3: Small position deviation is accepted
|
||||
func test_small_position_deviation_accepted():
|
||||
var client_pos = Vector3(0, 0, 0)
|
||||
var server_pos = Vector3(0.1, 0.1, 0.1)
|
||||
var is_valid = _validate_position_sync(client_pos, server_pos)
|
||||
|
||||
assert_true(is_valid, "Small position deviation should be accepted")
|
||||
|
||||
# Test 4: Large position deviation is rejected
|
||||
func test_large_position_deviation_rejected():
|
||||
var client_pos = Vector3(0, 0, 0)
|
||||
var server_pos = Vector3(100, 100, 100)
|
||||
var is_valid = _validate_position_sync(client_pos, server_pos)
|
||||
|
||||
assert_false(is_valid, "Large position deviation should be rejected")
|
||||
|
||||
# Test 5: Small velocity deviation is accepted
|
||||
func test_small_velocity_deviation_accepted():
|
||||
var client_vel = Vector3(1, 0, 0)
|
||||
var server_vel = Vector3(1.05, 0, 0)
|
||||
var is_valid = _validate_velocity_sync(client_vel, server_vel)
|
||||
|
||||
assert_true(is_valid, "Small velocity deviation should be accepted")
|
||||
|
||||
# Test 6: Large velocity deviation is rejected
|
||||
func test_large_velocity_deviation_rejected():
|
||||
var client_vel = Vector3(1, 0, 0)
|
||||
var server_vel = Vector3(50, 0, 0)
|
||||
var is_valid = _validate_velocity_sync(client_vel, server_vel)
|
||||
|
||||
assert_false(is_valid, "Large velocity deviation should be rejected")
|
||||
|
||||
# Test 7: Desync triggers correction
|
||||
func test_desync_triggers_correction():
|
||||
var client_pos = Vector3(0, 0, 0)
|
||||
var server_pos = Vector3(50, 50, 50)
|
||||
var correction = _calculate_position_correction(client_pos, server_pos)
|
||||
|
||||
assert_is_not_empty(correction, "Desync should trigger correction")
|
||||
|
||||
# Test 8: Multiple axis deviation is calculated correctly
|
||||
func test_multi_axis_deviation():
|
||||
var client_pos = Vector3(1, 2, 3)
|
||||
var server_pos = Vector3(1.5, 2.5, 3.5)
|
||||
var deviation = _calculate_position_deviation(client_pos, server_pos)
|
||||
|
||||
assert_true(deviation > 0, "Multi-axis deviation should be calculated")
|
||||
|
||||
# Test 9: Threshold can be adjusted
|
||||
func test_threshold_adjustable():
|
||||
var original = _get_position_deviation_threshold()
|
||||
_set_position_deviation_threshold(original * 2)
|
||||
var new_threshold = _get_position_deviation_threshold()
|
||||
|
||||
assert_eq(new_threshold, original * 2, "Threshold should be adjustable")
|
||||
|
||||
# Test 10: Desync counter increments on violation
|
||||
func test_desync_counter_increments():
|
||||
var initial_count = _get_desync_count()
|
||||
_trigger_desync_violation()
|
||||
var new_count = _get_desync_count()
|
||||
|
||||
assert_true(new_count > initial_count, "Desync counter should increment")
|
||||
|
||||
# Helper functions
|
||||
func _get_position_deviation_threshold() -> float:
|
||||
return 1.0
|
||||
|
||||
func _get_velocity_deviation_threshold() -> float:
|
||||
return 0.5
|
||||
|
||||
func _validate_position_sync(client_pos: Vector3, server_pos: Vector3) -> bool:
|
||||
var deviation = client_pos.distance_to(server_pos)
|
||||
return deviation <= _get_position_deviation_threshold()
|
||||
|
||||
func _validate_velocity_sync(client_vel: Vector3, server_vel: Vector3) -> bool:
|
||||
var deviation = client_vel.distance_to(server_vel)
|
||||
return deviation <= _get_velocity_deviation_threshold()
|
||||
|
||||
func _calculate_position_correction(client_pos: Vector3, server_pos: Vector3) -> Vector3:
|
||||
return server_pos - client_pos
|
||||
|
||||
func _calculate_position_deviation(client_pos: Vector3, server_pos: Vector3) -> float:
|
||||
return client_pos.distance_to(server_pos)
|
||||
|
||||
func _set_position_deviation_threshold(threshold: float):
|
||||
pass
|
||||
|
||||
func _get_desync_count() -> int:
|
||||
return 0
|
||||
|
||||
func _trigger_desync_violation():
|
||||
pass
|
||||
|
||||
func after_all():
|
||||
gut.p("=== Sync Desync Tests Complete ===")
|
||||
Reference in New Issue
Block a user