You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

3 years ago
  1. use elseware::common::serverstate::{ClientId, ServerState};
  2. use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
  3. use elseware::ship::ship::{ShipServerState, RecvShipPacket};
  4. use libpso::packet::ship::*;
  5. #[path = "common.rs"]
  6. mod common;
  7. use common::*;
  8. #[async_std::test]
  9. async fn test_guildcard_add_friend() {
  10. let mut entity_gateway = InMemoryGateway::default();
  11. let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
  12. let mut ship = Box::new(ShipServerState::builder()
  13. .gateway(entity_gateway.clone())
  14. .build());
  15. log_in_char(&mut ship, ClientId(1), "a1", "a").await;
  16. join_lobby(&mut ship, ClientId(1)).await;
  17. // Accept friend request from "Test Char 2"
  18. ship.handle(ClientId(1), &RecvShipPacket::GuildcardAccept(GuildcardAccept {
  19. id: 2,
  20. 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],
  21. team: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  22. 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],
  23. one: 1,
  24. language: 0,
  25. section_id: 0,
  26. class: 0,
  27. })).await.unwrap().for_each(drop);
  28. let friendlist = entity_gateway.get_guild_card_data_by_user(&user1).await.unwrap();
  29. 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]);
  30. }
  31. /*
  32. TODO: actually write these tests at some point. also add a test for transmute/repr(C)?
  33. #[async_std::test]
  34. async fn test_guildcard_block_rival() {}
  35. #[async_std::test]
  36. async fn test_guildcard_write_comment() {}
  37. #[async_std::test]
  38. async fn test_player_chat() {}
  39. #[async_std::test]
  40. async fn test_update_infoboard() {}
  41. */