From f3294dfce84ab4597cd7240f02c4d6f431194a8e Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 29 Apr 2022 00:33:38 +0000 Subject: [PATCH] a test i guess --- tests/test_communication.rs | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/test_communication.rs diff --git a/tests/test_communication.rs b/tests/test_communication.rs new file mode 100644 index 0000000..2e7e63b --- /dev/null +++ b/tests/test_communication.rs @@ -0,0 +1,55 @@ +use elseware::common::serverstate::{ClientId, ServerState}; +use elseware::entity::gateway::{EntityGateway, InMemoryGateway}; +use elseware::ship::ship::{ShipServerState, RecvShipPacket}; +use libpso::packet::ship::*; + +#[path = "common.rs"] +mod common; +use common::*; + +#[async_std::test] +async fn test_guildcard_add_friend() { + let mut entity_gateway = InMemoryGateway::default(); + let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await; + + let mut ship = Box::new(ShipServerState::builder() + .gateway(entity_gateway.clone()) + .build()); + + log_in_char(&mut ship, ClientId(1), "a1", "a").await; + join_lobby(&mut ship, ClientId(1)).await; + + // Accept friend request from "Test Char 2" + ship.handle(ClientId(1), &RecvShipPacket::GuildcardAccept(GuildcardAccept { + id: 2, + name: [84, 101, 115, 116, 32, 67, 104, 97, 114, 32, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + team: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + desc: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + one: 1, + language: 0, + section_id: 0, + class: 0, + })).await.unwrap().for_each(drop); + + let friendlist = entity_gateway.get_guild_card_data_by_user(&user1).await.unwrap(); + + assert!(friendlist.guildcard_data.friends[0].name == [84, 101, 115, 116, 32, 67, 104, 97, 114, 32, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); +} + + +/* +TODO: actually write these tests at some point. also add a test for transmute/repr(C)? + +#[async_std::test] +async fn test_guildcard_block_rival() {} + +#[async_std::test] +async fn test_guildcard_write_comment() {} + +#[async_std::test] +async fn test_player_chat() {} + +#[async_std::test] +async fn test_update_infoboard() {} + +*/ \ No newline at end of file