Add comprehensive documentation and unit tests
Documentation: - Add detailed README files for all services (auth, character, database, launcher, packet, utils, world) - Create API documentation for the database service with detailed endpoint specifications - Document database schema and relationships - Add service architecture overviews and configuration instructions Unit Tests: - Implement comprehensive test suite for database repositories (user, character, session) - Add gRPC service tests for database interactions - Create tests for packet service components (bufferpool, connection, packets) - Add utility service tests (health check, logging, load balancer, redis cache, service discovery) - Implement auth service user tests - Add character service tests Code Structure: - Reorganize test files into a more consistent structure - Create a dedicated tests crate for integration testing - Add test helpers and mock implementations for easier testing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::character_client::CharacterClient;
|
||||
use crate::character_client::CharacterClient;
|
||||
use crate::connection_service::ConnectionService;
|
||||
use crate::packet::{send_packet, Packet, PacketPayload};
|
||||
use crate::packet_type::PacketType;
|
||||
@@ -32,24 +32,14 @@ pub(crate) async fn handle_change_map_req(
|
||||
let session_id;
|
||||
if let Some(mut state) = connection_service.get_connection(&connection_id) {
|
||||
user_id = state.user_id.expect("Missing user id in connection state");
|
||||
session_id = state
|
||||
.session_id
|
||||
.expect("Missing session id in connection state");
|
||||
char_id = state
|
||||
.character_id
|
||||
.expect("Missing character id in connection state");
|
||||
character_id_list = state
|
||||
.character_list
|
||||
.clone()
|
||||
.expect("Missing character id list");
|
||||
session_id = state.session_id.expect("Missing session id in connection state");
|
||||
char_id = state.character_id.expect("Missing character id in connection state");
|
||||
character_id_list = state.character_list.clone().expect("Missing character id list");
|
||||
}
|
||||
|
||||
let mut character_client = character_client.lock().await;
|
||||
let character_data = character_client
|
||||
.get_character(
|
||||
&user_id.to_string(),
|
||||
character_id_list[char_id as usize] as u8,
|
||||
)
|
||||
.get_character(&user_id.to_string(), character_id_list[char_id as usize] as u8)
|
||||
.await?;
|
||||
|
||||
let character = character_data.character.unwrap_or_default();
|
||||
@@ -93,24 +83,14 @@ pub(crate) async fn handle_mouse_cmd_req(
|
||||
let mut char_id = 0;
|
||||
let mut character_id_list: Vec<u32> = Vec::new();
|
||||
if let Some(mut state) = connection_service.get_connection(&connection_id) {
|
||||
char_id = state
|
||||
.character_id
|
||||
.expect("Missing character id in connection state");
|
||||
character_id_list = state
|
||||
.character_list
|
||||
.clone()
|
||||
.expect("Missing character id list");
|
||||
char_id = state.character_id.expect("Missing character id in connection state");
|
||||
character_id_list = state.character_list.clone().expect("Missing character id list");
|
||||
}
|
||||
|
||||
let data = SrvMouseCmd {
|
||||
id: character_id_list[char_id as usize] as u16,
|
||||
target_id: request.target_id,
|
||||
distance: distance(
|
||||
520000 as f64,
|
||||
520000 as f64,
|
||||
request.x as f64,
|
||||
request.y as f64,
|
||||
),
|
||||
distance: distance(520000 as f64, 520000 as f64, request.x as f64, request.y as f64),
|
||||
x: request.x,
|
||||
y: request.y,
|
||||
z: request.z,
|
||||
|
||||
Reference in New Issue
Block a user