Browse Source

add new arg for new_user_character and fix tests. add keyboard config tests. fix and clean up warnings in test files

pull/104/head
andy 3 years ago
parent
commit
1af69800ed
  1. 4
      src/bin/main.rs
  2. 4
      src/entity/character.rs
  3. 2
      src/login/character.rs
  4. 22
      src/ship/items/transaction.rs
  5. 4
      tests/common.rs
  6. 78
      tests/test_bank.rs
  7. 73
      tests/test_character.rs
  8. 10
      tests/test_exp_gain.rs
  9. 6
      tests/test_item_actions.rs
  10. 48
      tests/test_item_pickup.rs
  11. 10
      tests/test_item_use.rs
  12. 10
      tests/test_mags.rs
  13. 8
      tests/test_rooms.rs
  14. 58
      tests/test_shops.rs
  15. 158
      tests/test_trade.rs

4
src/bin/main.rs

@ -65,12 +65,12 @@ fn main() {
}; };
let fake_user = entity_gateway.create_user(fake_user).await.unwrap(); let fake_user = entity_gateway.create_user(fake_user).await.unwrap();
entity_gateway.create_user_settings(NewUserSettingsEntity::new(fake_user.id)).await.unwrap(); entity_gateway.create_user_settings(NewUserSettingsEntity::new(fake_user.id)).await.unwrap();
let mut character = NewCharacterEntity::new(fake_user.id);
let mut character = NewCharacterEntity::new(fake_user.id, 1);
character.name = format!("Test Char {}", i*2); character.name = format!("Test Char {}", i*2);
let character = entity_gateway.create_character(character).await.unwrap(); let character = entity_gateway.create_character(character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&character.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&character.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap(); entity_gateway.set_bank_meseta(&character.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap();
let mut character = NewCharacterEntity::new(fake_user.id);
let mut character = NewCharacterEntity::new(fake_user.id, 1);
character.slot = 2; character.slot = 2;
character.name = "ItemRefactor".into(); character.name = "ItemRefactor".into();
character.exp = 80000000; character.exp = 80000000;

4
src/entity/character.rs

@ -368,7 +368,7 @@ pub struct NewCharacterEntity {
} }
impl NewCharacterEntity { impl NewCharacterEntity {
pub fn new(user: UserAccountId) -> NewCharacterEntity {
pub fn new(user: UserAccountId, keyboard_config_preset: usize,) -> NewCharacterEntity {
NewCharacterEntity { NewCharacterEntity {
user_id: user, user_id: user,
slot: 0, slot: 0,
@ -384,7 +384,7 @@ impl NewCharacterEntity {
materials: CharacterMaterials::default(), materials: CharacterMaterials::default(),
tech_menu: CharacterTechMenu::default(), tech_menu: CharacterTechMenu::default(),
option_flags: 0, option_flags: 0,
keyboard_config: CharacterKeyboardConfig::new(1),
keyboard_config: CharacterKeyboardConfig::new(keyboard_config_preset),
gamepad_config: CharacterGamepadConfig::default(), gamepad_config: CharacterGamepadConfig::default(),
} }
} }

2
src/login/character.rs

@ -712,7 +712,7 @@ impl<EG: EntityGateway> InterserverActor for CharacterServerState<EG> {
fn new_character_from_preview(user: &UserAccountEntity, preview: &CharacterPreview) -> NewCharacterEntity { fn new_character_from_preview(user: &UserAccountEntity, preview: &CharacterPreview) -> NewCharacterEntity {
let mut character = NewCharacterEntity::new(user.id);
let mut character = NewCharacterEntity::new(user.id, 1); // it should not be possible for the client to specify the kbm config preset from the char create screen
character.slot = preview.slot; character.slot = preview.slot;
character.name = String::from_utf16_lossy(&preview.character.name).trim_matches(char::from(0)).into(); character.name = String::from_utf16_lossy(&preview.character.name).trim_matches(char::from(0)).into();
character.section_id = preview.character.section_id.into(); character.section_id = preview.character.section_id.into();

22
src/ship/items/transaction.rs

@ -163,7 +163,7 @@ mod test {
item_manager.id_counter += self.value; item_manager.id_counter += self.value;
entity_gateway.create_character(NewCharacterEntity { entity_gateway.create_character(NewCharacterEntity {
slot: self.value, slot: self.value,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
}) })
.await?; .await?;
Ok(()) Ok(())
@ -209,7 +209,7 @@ mod test {
#[derive(Default, Clone)] #[derive(Default, Clone)]
struct DummyGateway { struct DummyGateway {
d1_set: String,
_d1_set: String,
d2_inc: u32, d2_inc: u32,
} }
@ -224,10 +224,10 @@ mod test {
#[async_trait::async_trait] #[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 { impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity { entity_gateway.create_character(NewCharacterEntity {
slot: 1, slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
}) })
.await?; .await?;
Ok(()) Ok(())
@ -236,10 +236,10 @@ mod test {
#[async_trait::async_trait] #[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 { impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity { entity_gateway.create_character(NewCharacterEntity {
slot: 1, slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
}) })
.await?; .await?;
Ok(()) Ok(())
@ -279,7 +279,7 @@ mod test {
#[derive(Default, Clone)] #[derive(Default, Clone)]
struct DummyGateway { struct DummyGateway {
d1_set: String,
_d1_set: String,
d2_inc: u32, d2_inc: u32,
} }
@ -294,10 +294,10 @@ mod test {
#[async_trait::async_trait] #[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 { impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity { entity_gateway.create_character(NewCharacterEntity {
slot: 1, slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
}) })
.await?; .await?;
Err(GatewayError::Error.into()) Err(GatewayError::Error.into())
@ -306,10 +306,10 @@ mod test {
#[async_trait::async_trait] #[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 { impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity { entity_gateway.create_character(NewCharacterEntity {
slot: 1, slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
}) })
.await?; .await?;
Ok(()) Ok(())

4
tests/common.rs

@ -13,7 +13,7 @@ use libpso::packet::login::{Login, Session};
use libpso::{utf8_to_array, utf8_to_utf16_array}; use libpso::{utf8_to_array, utf8_to_utf16_array};
pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, username: &str, password: &str) -> (UserAccountEntity, CharacterEntity) {
pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, username: &str, password: &str, kb_conf_preset: usize) -> (UserAccountEntity, CharacterEntity) {
let new_user = NewUserAccountEntity { let new_user = NewUserAccountEntity {
email: format!("{}@pso.com", username), email: format!("{}@pso.com", username),
username: username.into(), username: username.into(),
@ -26,7 +26,7 @@ pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, user
let user = entity_gateway.create_user(new_user).await.unwrap(); let user = entity_gateway.create_user(new_user).await.unwrap();
let new_settings = NewUserSettingsEntity::new(user.id); let new_settings = NewUserSettingsEntity::new(user.id);
let _settings = entity_gateway.create_user_settings(new_settings).await.unwrap(); let _settings = entity_gateway.create_user_settings(new_settings).await.unwrap();
let new_character = NewCharacterEntity::new(user.id);
let new_character = NewCharacterEntity::new(user.id, kb_conf_preset);
let character = entity_gateway.create_character(new_character).await.unwrap(); let character = entity_gateway.create_character(new_character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, Meseta(0)).await.unwrap(); entity_gateway.set_character_meseta(&character.id, Meseta(0)).await.unwrap();
entity_gateway.set_bank_meseta(&character.id, BankName("".into()), Meseta(0)).await.unwrap(); entity_gateway.set_bank_meseta(&character.id, BankName("".into()), Meseta(0)).await.unwrap();

78
tests/test_bank.rs

@ -15,8 +15,8 @@ use common::*;
async fn test_bank_items_sent_in_character_login() { async fn test_bank_items_sent_in_character_login() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item = entity_gateway.create_item( let item = entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
@ -50,8 +50,8 @@ async fn test_bank_items_sent_in_character_login() {
async fn test_request_bank_items() { async fn test_request_bank_items() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank = Vec::new(); let mut bank = Vec::new();
for _ in 0..3 { for _ in 0..3 {
@ -98,8 +98,8 @@ async fn test_request_bank_items() {
async fn test_request_stacked_bank_items() { async fn test_request_stacked_bank_items() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -141,8 +141,8 @@ async fn test_request_stacked_bank_items() {
async fn test_request_bank_items_sorted() { async fn test_request_bank_items_sorted() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item1 = entity_gateway.create_item( let item1 = entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
@ -207,8 +207,8 @@ async fn test_request_bank_items_sorted() {
async fn test_deposit_individual_item() { async fn test_deposit_individual_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item0 = entity_gateway.create_item( let item0 = entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
@ -280,8 +280,8 @@ async fn test_deposit_individual_item() {
async fn test_deposit_stacked_item() { async fn test_deposit_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -341,8 +341,8 @@ async fn test_deposit_stacked_item() {
async fn test_deposit_partial_stacked_item() { async fn test_deposit_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -411,8 +411,8 @@ async fn test_deposit_partial_stacked_item() {
async fn test_deposit_stacked_item_with_stack_already_in_bank() { async fn test_deposit_stacked_item_with_stack_already_in_bank() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank_monomates = Vec::new(); let mut bank_monomates = Vec::new();
let mut inventory_monomates = Vec::new(); let mut inventory_monomates = Vec::new();
@ -483,7 +483,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
async fn test_deposit_stacked_item_with_full_stack_in_bank() { async fn test_deposit_stacked_item_with_full_stack_in_bank() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut inventory_monomates = Vec::new(); let mut inventory_monomates = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -555,7 +555,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
async fn test_deposit_individual_item_in_full_bank() { async fn test_deposit_individual_item_in_full_bank() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut inventory = Vec::new(); let mut inventory = Vec::new();
inventory.push(entity_gateway.create_item( inventory.push(entity_gateway.create_item(
@ -629,7 +629,7 @@ async fn test_deposit_individual_item_in_full_bank() {
async fn test_deposit_stacked_item_in_full_bank() { async fn test_deposit_stacked_item_in_full_bank() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -702,7 +702,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -785,7 +785,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
async fn test_deposit_meseta() { async fn test_deposit_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
@ -821,7 +821,7 @@ async fn test_deposit_meseta() {
async fn test_deposit_too_much_meseta() { async fn test_deposit_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999980)).await.unwrap(); entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999980)).await.unwrap();
@ -858,7 +858,7 @@ async fn test_deposit_too_much_meseta() {
async fn test_deposit_meseta_when_bank_is_maxed() { async fn test_deposit_meseta_when_bank_is_maxed() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap(); entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap();
@ -896,8 +896,8 @@ async fn test_deposit_meseta_when_bank_is_maxed() {
async fn test_withdraw_individual_item() { async fn test_withdraw_individual_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank = Vec::new(); let mut bank = Vec::new();
bank.push(entity_gateway.create_item( bank.push(entity_gateway.create_item(
@ -958,8 +958,8 @@ async fn test_withdraw_individual_item() {
async fn test_withdraw_stacked_item() { async fn test_withdraw_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -1018,8 +1018,8 @@ async fn test_withdraw_stacked_item() {
async fn test_withdraw_partial_stacked_item() { async fn test_withdraw_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -1084,8 +1084,8 @@ async fn test_withdraw_partial_stacked_item() {
async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut inventory_monomates = Vec::new(); let mut inventory_monomates = Vec::new();
let mut bank_monomates = Vec::new(); let mut bank_monomates = Vec::new();
@ -1158,7 +1158,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank_monomates = Vec::new(); let mut bank_monomates = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -1230,7 +1230,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
async fn test_withdraw_individual_item_in_full_inventory() { async fn test_withdraw_individual_item_in_full_inventory() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank = Vec::new(); let mut bank = Vec::new();
bank.push(entity_gateway.create_item( bank.push(entity_gateway.create_item(
@ -1300,7 +1300,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
async fn test_withdraw_stacked_item_in_full_inventory() { async fn test_withdraw_stacked_item_in_full_inventory() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -1374,7 +1374,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank_item = Vec::new(); let mut bank_item = Vec::new();
for _ in 0..2usize { for _ in 0..2usize {
@ -1390,7 +1390,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), item::BankName("".into())).await.unwrap(); entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), item::BankName("".into())).await.unwrap();
let mut items = Vec::new(); let mut items = Vec::new();
for i in 0..29usize {
for _i in 0..29usize {
items.push(entity_gateway.create_item( items.push(entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
item: item::ItemDetail::Weapon( item: item::ItemDetail::Weapon(
@ -1460,7 +1460,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
async fn test_withdraw_meseta() { async fn test_withdraw_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap(); entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
@ -1496,7 +1496,7 @@ async fn test_withdraw_meseta() {
async fn test_withdraw_too_much_meseta() { async fn test_withdraw_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999980)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999980)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap(); entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
@ -1533,7 +1533,7 @@ async fn test_withdraw_too_much_meseta() {
async fn test_withdraw_meseta_inventory_is_maxed() { async fn test_withdraw_meseta_inventory_is_maxed() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap(); entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();

73
tests/test_character.rs

@ -2,6 +2,7 @@ use elseware::common::serverstate::{ClientId, ServerState};
use elseware::entity::gateway::{EntityGateway, InMemoryGateway}; use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::ship::ship::{ShipServerState, RecvShipPacket}; use elseware::ship::ship::{ShipServerState, RecvShipPacket};
use libpso::character::settings::{DEFAULT_KEYBOARD_CONFIG1, DEFAULT_KEYBOARD_CONFIG2, DEFAULT_KEYBOARD_CONFIG3, DEFAULT_KEYBOARD_CONFIG4};
use libpso::packet::ship::*; use libpso::packet::ship::*;
#[path = "common.rs"] #[path = "common.rs"]
@ -12,7 +13,7 @@ use common::*;
async fn test_save_options() { async fn test_save_options() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -29,3 +30,73 @@ async fn test_save_options() {
assert!(char.option_flags == 12345); assert!(char.option_flags == 12345);
} }
#[async_std::test]
async fn test_default3_keyboard_mappings() {
/*
check if keyboard is set to default3 when specified. this will only occur for things like creating characters from the web page.
normal client behaviour will simply use default1 when creating a character.
gamepad only has 1 default config
*/
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 3).await;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG3);
}
#[async_std::test]
async fn test_invalid_keyboard_preset_value() {
// check if keyboard_config self-corrects to DEFAULT1 if an invalid value (>4) is given
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 10).await;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG1);
}
#[async_std::test]
async fn test_change_keyboard_mappings() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 2).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;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG2);
// update from default2 to default4
// the client simply sends the full 364 bytes...
ship.handle(ClientId(1), &RecvShipPacket::KeyboardConfig(KeyboardConfig{
keyboard_config: [
0, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0,
0, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 115, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0,
0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
0, 0, 0, 0, 94, 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0,
0, 0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 0,
0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0,
0, 0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 0,
0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, 0,
0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0,
0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0,
0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
0, 0, 0, 0, 70, 0, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0,
0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 73, 0, 0, 0,
0, 0, 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, 75, 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, 42, 0, 0, 0,
0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0,
0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0,
0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0,
0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0,
0, 0, 0, 0, 51, 0, 0, 0, 1, 0, 0, 0
],
})).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG4);
}

10
tests/test_exp_gain.rs

@ -15,7 +15,7 @@ use common::*;
async fn test_character_gains_exp() { async fn test_character_gains_exp() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -52,7 +52,7 @@ async fn test_character_gains_exp() {
async fn test_character_levels_up() { async fn test_character_levels_up() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 49; char1.exp = 49;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -92,7 +92,7 @@ async fn test_character_levels_up() {
async fn test_character_levels_up_multiple_times() { async fn test_character_levels_up_multiple_times() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -136,8 +136,8 @@ async fn test_character_levels_up_multiple_times() {
async fn test_one_character_gets_full_exp_and_other_attacker_gets_partial() { async fn test_one_character_gets_full_exp_and_other_attacker_gets_partial() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())

6
tests/test_item_actions.rs

@ -14,7 +14,7 @@ use common::*;
async fn test_equip_unit_from_equip_menu() { async fn test_equip_unit_from_equip_menu() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -91,7 +91,7 @@ async fn test_equip_unit_from_equip_menu() {
async fn test_unequip_armor_with_units() { async fn test_unequip_armor_with_units() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -159,7 +159,7 @@ async fn test_unequip_armor_with_units() {
async fn test_sort_items() { async fn test_sort_items() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(

48
tests/test_item_pickup.rs

@ -14,8 +14,8 @@ use common::*;
async fn test_pick_up_individual_item() { async fn test_pick_up_individual_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -85,8 +85,8 @@ async fn test_pick_up_individual_item() {
async fn test_pick_up_item_stack_of_items_already_in_inventory() { async fn test_pick_up_item_stack_of_items_already_in_inventory() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_monomate = Vec::new(); let mut p1_monomate = Vec::new();
p1_monomate.push(entity_gateway.create_item( p1_monomate.push(entity_gateway.create_item(
@ -99,7 +99,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
}).await.unwrap()); }).await.unwrap());
let mut p2_items = Vec::new(); let mut p2_items = Vec::new();
for (slot, tool) in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter().enumerate() {
for (_slot, tool) in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter().enumerate() {
let mut item = Vec::new(); let mut item = Vec::new();
for _ in 0..5usize { for _ in 0..5usize {
item.push(entity_gateway.create_item( item.push(entity_gateway.create_item(
@ -161,8 +161,8 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
async fn test_pick_up_item_stack_of_items_not_already_held() { async fn test_pick_up_item_stack_of_items_not_already_held() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p2_monomate = Vec::new(); let mut p2_monomate = Vec::new();
p2_monomate.push(entity_gateway.create_item( p2_monomate.push(entity_gateway.create_item(
@ -220,8 +220,8 @@ async fn test_pick_up_item_stack_of_items_not_already_held() {
async fn test_pick_up_meseta_when_inventory_full() { async fn test_pick_up_meseta_when_inventory_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_items = Vec::new(); let mut p1_items = Vec::new();
for _ in 0..30usize { for _ in 0..30usize {
@ -292,11 +292,11 @@ async fn test_pick_up_meseta_when_inventory_full() {
async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for slot in 0..29usize {
for _slot in 0..29usize {
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
item: item::ItemDetail::Weapon( item: item::ItemDetail::Weapon(
@ -375,11 +375,11 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
async fn test_can_not_pick_up_item_when_inventory_full() { async fn test_can_not_pick_up_item_when_inventory_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for slot in 0..30usize {
for _slot in 0..30usize {
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
item: item::ItemDetail::Weapon( item: item::ItemDetail::Weapon(
@ -465,7 +465,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
async fn test_can_not_drop_more_meseta_than_is_held() { async fn test_can_not_drop_more_meseta_than_is_held() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
@ -504,8 +504,8 @@ async fn test_can_not_drop_more_meseta_than_is_held() {
async fn test_pick_up_stack_that_would_exceed_stack_limit() { async fn test_pick_up_stack_that_would_exceed_stack_limit() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_monomates = Vec::new(); let mut p1_monomates = Vec::new();
for _ in 0..6usize { for _ in 0..6usize {
@ -578,8 +578,8 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
async fn test_can_not_pick_up_meseta_when_full() { async fn test_can_not_pick_up_meseta_when_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap();
@ -632,8 +632,8 @@ async fn test_can_not_pick_up_meseta_when_full() {
async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() { async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999998)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999998)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap(); entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap();
@ -685,8 +685,8 @@ async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
async fn test_player_drops_partial_stack_and_other_player_picks_it_up() { async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new(); let mut monomates = Vec::new();
for _ in 0..5usize { for _ in 0..5usize {

10
tests/test_item_use.rs

@ -16,7 +16,7 @@ use common::*;
async fn test_use_monomate() { async fn test_use_monomate() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new(); let mut p1_items = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() { for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -63,7 +63,7 @@ async fn test_use_monomate() {
async fn test_use_monomate_twice() { async fn test_use_monomate_twice() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new(); let mut p1_items = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() { for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -115,7 +115,7 @@ async fn test_use_monomate_twice() {
async fn test_use_last_monomate() { async fn test_use_last_monomate() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() { for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -157,7 +157,7 @@ async fn test_use_last_monomate() {
async fn test_use_nonstackable_tool() { async fn test_use_nonstackable_tool() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new(); let mut p1_items = Vec::new();
p1_items.push(entity_gateway.create_item( p1_items.push(entity_gateway.create_item(
@ -192,7 +192,7 @@ async fn test_use_nonstackable_tool() {
async fn test_use_materials() { async fn test_use_materials() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for tool in vec![item::tool::ToolType::PowerMaterial, item::tool::ToolType::LuckMaterial].into_iter() { for tool in vec![item::tool::ToolType::PowerMaterial, item::tool::ToolType::LuckMaterial].into_iter() {

10
tests/test_mags.rs

@ -1,7 +1,7 @@
use elseware::common::serverstate::{ClientId, ServerState}; use elseware::common::serverstate::{ClientId, ServerState};
use elseware::entity::gateway::{EntityGateway, InMemoryGateway}; use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::entity::item; use elseware::entity::item;
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
use elseware::ship::ship::{ShipServerState, RecvShipPacket};
use elseware::entity::character::{CharacterClass, SectionID}; use elseware::entity::character::{CharacterClass, SectionID};
use libpso::packet::ship::*; use libpso::packet::ship::*;
@ -15,7 +15,7 @@ use common::*;
async fn test_mag_feed() { async fn test_mag_feed() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mag = entity_gateway.create_item( let mag = entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {
@ -87,8 +87,8 @@ async fn test_mag_feed() {
async fn test_mag_change_owner() { async fn test_mag_change_owner() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.char_class = CharacterClass::RAmarl; char1.char_class = CharacterClass::RAmarl;
char1.section_id = SectionID::Redria; char1.section_id = SectionID::Redria;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -152,7 +152,7 @@ async fn test_mag_change_owner() {
async fn test_mag_cell() { async fn test_mag_cell() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mag = entity_gateway.create_item( let mag = entity_gateway.create_item(
item::NewItemEntity { item::NewItemEntity {

8
tests/test_rooms.rs

@ -4,7 +4,7 @@ use elseware::entity::item;
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket}; use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
use libpso::packet::ship::*; use libpso::packet::ship::*;
use libpso::packet::messages::*;
//use libpso::packet::messages::*;
#[path = "common.rs"] #[path = "common.rs"]
mod common; mod common;
@ -15,8 +15,8 @@ use common::*;
async fn test_item_ids_reset_when_rejoining_rooms() { async fn test_item_ids_reset_when_rejoining_rooms() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for _ in 0..3usize { for _ in 0..3usize {
@ -99,7 +99,7 @@ async fn test_item_ids_reset_when_rejoining_rooms() {
#[async_std::test] #[async_std::test]
async fn test_load_rare_monster_default_appear_rates() { async fn test_load_rare_monster_default_appear_rates() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
.build()); .build());

58
tests/test_shops.rs

@ -16,7 +16,7 @@ use common::*;
async fn test_player_opens_weapon_shop() { async fn test_player_opens_weapon_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -46,7 +46,7 @@ async fn test_player_opens_weapon_shop() {
async fn test_player_opens_tool_shop() { async fn test_player_opens_tool_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -76,7 +76,7 @@ async fn test_player_opens_tool_shop() {
async fn test_player_opens_armor_shop() { async fn test_player_opens_armor_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -106,7 +106,7 @@ async fn test_player_opens_armor_shop() {
async fn test_player_buys_from_weapon_shop() { async fn test_player_buys_from_weapon_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -144,7 +144,7 @@ async fn test_player_buys_from_weapon_shop() {
async fn test_player_buys_from_tool_shop() { async fn test_player_buys_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -181,7 +181,7 @@ async fn test_player_buys_from_tool_shop() {
async fn test_player_buys_multiple_from_tool_shop() { async fn test_player_buys_multiple_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -222,7 +222,7 @@ async fn test_player_buys_multiple_from_tool_shop() {
async fn test_player_buys_from_armor_shop() { async fn test_player_buys_from_armor_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -259,7 +259,7 @@ async fn test_player_buys_from_armor_shop() {
async fn test_player_sells_3_attr_weapon_to_shop() { async fn test_player_sells_3_attr_weapon_to_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -303,8 +303,8 @@ async fn test_player_sells_3_attr_weapon_to_shop() {
async fn test_other_clients_see_purchase() { async fn test_other_clients_see_purchase() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
@ -346,8 +346,8 @@ async fn test_other_clients_see_purchase() {
async fn test_other_clients_see_stacked_purchase() { async fn test_other_clients_see_stacked_purchase() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -397,7 +397,7 @@ async fn test_other_clients_see_stacked_purchase() {
async fn test_buying_item_without_enough_mseseta() { async fn test_buying_item_without_enough_mseseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -432,7 +432,7 @@ async fn test_buying_item_without_enough_mseseta() {
async fn test_player_double_buys_from_tool_shop() { async fn test_player_double_buys_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -497,7 +497,7 @@ async fn test_player_double_buys_from_tool_shop() {
async fn test_techs_disappear_from_shop_when_bought() { async fn test_techs_disappear_from_shop_when_bought() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -559,7 +559,7 @@ async fn test_techs_disappear_from_shop_when_bought() {
async fn test_units_disappear_from_shop_when_bought() { async fn test_units_disappear_from_shop_when_bought() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000; char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap(); entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -620,7 +620,7 @@ async fn test_units_disappear_from_shop_when_bought() {
async fn test_player_sells_untekked_weapon() { async fn test_player_sells_untekked_weapon() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -664,7 +664,7 @@ async fn test_player_sells_untekked_weapon() {
async fn test_player_sells_rare_item() { async fn test_player_sells_rare_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -708,7 +708,7 @@ async fn test_player_sells_rare_item() {
async fn test_player_sells_partial_photon_drop_stack() { async fn test_player_sells_partial_photon_drop_stack() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -751,7 +751,7 @@ async fn test_player_sells_partial_photon_drop_stack() {
async fn test_player_sells_basic_frame() { async fn test_player_sells_basic_frame() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -792,7 +792,7 @@ async fn test_player_sells_basic_frame() {
async fn test_player_sells_max_frame() { async fn test_player_sells_max_frame() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -833,7 +833,7 @@ async fn test_player_sells_max_frame() {
async fn test_player_sells_basic_barrier() { async fn test_player_sells_basic_barrier() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -873,7 +873,7 @@ async fn test_player_sells_basic_barrier() {
async fn test_player_sells_max_barrier() { async fn test_player_sells_max_barrier() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -913,7 +913,7 @@ async fn test_player_sells_max_barrier() {
async fn test_player_sells_1_star_minusminus_unit() { async fn test_player_sells_1_star_minusminus_unit() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -952,7 +952,7 @@ async fn test_player_sells_1_star_minusminus_unit() {
async fn test_player_sells_5_star_plusplus_unit() { async fn test_player_sells_5_star_plusplus_unit() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -991,7 +991,7 @@ async fn test_player_sells_5_star_plusplus_unit() {
async fn test_player_sells_rare_frame() { async fn test_player_sells_rare_frame() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -1032,7 +1032,7 @@ async fn test_player_sells_rare_frame() {
async fn test_player_sells_rare_barrier() { async fn test_player_sells_rare_barrier() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -1072,7 +1072,7 @@ async fn test_player_sells_rare_barrier() {
async fn test_player_sells_rare_unit() { async fn test_player_sells_rare_unit() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
@ -1111,7 +1111,7 @@ async fn test_player_sells_rare_unit() {
async fn test_player_cant_sell_if_meseta_would_go_over_max() { async fn test_player_cant_sell_if_meseta_would_go_over_max() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999995)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, item::Meseta(999995)).await.unwrap();
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();

158
tests/test_trade.rs

@ -114,8 +114,8 @@ impl TradeItemBuilder {
async fn test_trade_one_individual_item() { async fn test_trade_one_individual_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -215,8 +215,8 @@ async fn test_trade_one_individual_item() {
async fn test_trade_player2_to_player1() { async fn test_trade_player2_to_player1() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p2_inv = Vec::new(); let mut p2_inv = Vec::new();
p2_inv.push(entity_gateway.create_item( p2_inv.push(entity_gateway.create_item(
@ -316,8 +316,8 @@ async fn test_trade_player2_to_player1() {
async fn test_reverse_trade_ack_order() { async fn test_reverse_trade_ack_order() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -417,8 +417,8 @@ async fn test_reverse_trade_ack_order() {
async fn test_trade_one_stacked_item() { async fn test_trade_one_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -521,8 +521,8 @@ async fn test_trade_one_stacked_item() {
async fn test_trade_partial_stacked_item() { async fn test_trade_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -628,8 +628,8 @@ async fn test_trade_partial_stacked_item() {
async fn test_trade_individual_both() { async fn test_trade_individual_both() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![ let p1_inv = vec![
entity_gateway.create_item( entity_gateway.create_item(
@ -793,8 +793,8 @@ async fn test_trade_individual_both() {
async fn test_trade_stacked_both() { async fn test_trade_stacked_both() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -963,8 +963,8 @@ async fn test_trade_stacked_both() {
async fn test_trade_partial_stack_both() { async fn test_trade_partial_stack_both() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -1139,8 +1139,8 @@ async fn test_trade_partial_stack_both() {
async fn test_trade_same_stacked_item_to_eachother() { async fn test_trade_same_stacked_item_to_eachother() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..3).map(|_| { let p1_stack = futures::future::join_all((0..3).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -1311,8 +1311,8 @@ async fn test_trade_same_stacked_item_to_eachother() {
async fn test_trade_stacked_when_already_have_partial_stack() { async fn test_trade_stacked_when_already_have_partial_stack() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..3).map(|_| { let p1_stack = futures::future::join_all((0..3).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -1451,8 +1451,8 @@ async fn test_trade_stacked_when_already_have_partial_stack() {
async fn test_trade_individual_for_stacked() { async fn test_trade_individual_for_stacked() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![ let p1_inv = vec![
entity_gateway.create_item( entity_gateway.create_item(
@ -1621,8 +1621,8 @@ async fn test_trade_individual_for_stacked() {
async fn test_trade_multiple_individual() { async fn test_trade_multiple_individual() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![ let p1_inv = vec![
entity_gateway.create_item( entity_gateway.create_item(
@ -1879,8 +1879,8 @@ async fn test_trade_multiple_individual() {
async fn test_trade_multiple_stacked() { async fn test_trade_multiple_stacked() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| { let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -2146,8 +2146,8 @@ async fn test_trade_multiple_stacked() {
async fn test_trade_not_enough_inventory_space_individual() { async fn test_trade_not_enough_inventory_space_individual() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..2).map(|_| { let p1_inv = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -2268,8 +2268,8 @@ async fn test_trade_not_enough_inventory_space_individual() {
async fn test_trade_not_enough_inventory_space_stacked() { async fn test_trade_not_enough_inventory_space_stacked() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -2385,8 +2385,8 @@ async fn test_trade_not_enough_inventory_space_stacked() {
async fn test_trade_stack_too_big() { async fn test_trade_stack_too_big() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..8).map(|_| { let p1_stack = futures::future::join_all((0..8).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -2501,8 +2501,8 @@ async fn test_trade_stack_too_big() {
async fn test_trade_meseta() { async fn test_trade_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap();
@ -2582,8 +2582,8 @@ async fn test_trade_meseta() {
async fn test_trade_too_much_meseta() { async fn test_trade_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap(); entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2634,8 +2634,8 @@ async fn test_trade_too_much_meseta() {
async fn test_trade_invalid_amount_of_meseta() { async fn test_trade_invalid_amount_of_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap(); entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2686,8 +2686,8 @@ async fn test_trade_invalid_amount_of_meseta() {
async fn test_trade_meseta_request_and_items_dont_match() { async fn test_trade_meseta_request_and_items_dont_match() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap(); entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2738,8 +2738,8 @@ async fn test_trade_meseta_request_and_items_dont_match() {
async fn test_player_declined_trade() { async fn test_player_declined_trade() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -2769,8 +2769,8 @@ async fn test_player_declined_trade() {
async fn test_back_out_of_trade_last_minute() { async fn test_back_out_of_trade_last_minute() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -2835,8 +2835,8 @@ async fn test_back_out_of_trade_last_minute() {
async fn test_valid_trade_when_both_inventories_are_full() { async fn test_valid_trade_when_both_inventories_are_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..30).map(|_| { let p1_inv = futures::future::join_all((0..30).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -2977,8 +2977,8 @@ async fn test_valid_trade_when_both_inventories_are_full() {
async fn test_invalid_trade_when_both_inventories_are_full() { async fn test_invalid_trade_when_both_inventories_are_full() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..30).map(|_| { let p1_inv = futures::future::join_all((0..30).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -3128,9 +3128,9 @@ async fn test_invalid_trade_when_both_inventories_are_full() {
async fn test_client_tries_to_start_two_trades() { async fn test_client_tries_to_start_two_trades() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -3160,9 +3160,9 @@ async fn test_client_tries_to_start_two_trades() {
async fn test_client_tries_trading_with_client_already_trading() { async fn test_client_tries_trading_with_client_already_trading() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -3199,8 +3199,8 @@ async fn test_client_tries_trading_with_client_already_trading() {
async fn test_add_then_remove_individual_item() { async fn test_add_then_remove_individual_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
for _ in 0..2 { for _ in 0..2 {
@ -3312,8 +3312,8 @@ async fn test_add_then_remove_individual_item() {
async fn test_add_then_remove_stacked_item() { async fn test_add_then_remove_stacked_item() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| { let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -3447,8 +3447,8 @@ async fn test_add_then_remove_stacked_item() {
async fn test_add_then_remove_partial_stack() { async fn test_add_then_remove_partial_stack() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| { let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -3571,8 +3571,8 @@ async fn test_add_then_remove_partial_stack() {
async fn test_add_then_remove_meseta() { async fn test_add_then_remove_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap();
@ -3657,8 +3657,8 @@ async fn test_add_then_remove_meseta() {
async fn test_items_to_trade_data_does_not_match() { async fn test_items_to_trade_data_does_not_match() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -3740,8 +3740,8 @@ async fn test_items_to_trade_data_does_not_match() {
async fn test_items_to_trade_id_does_not_match() { async fn test_items_to_trade_id_does_not_match() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -3811,8 +3811,8 @@ async fn test_items_to_trade_id_does_not_match() {
async fn test_stack_is_same_amount_in_request_and_items_to_trade() { async fn test_stack_is_same_amount_in_request_and_items_to_trade() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -3885,8 +3885,8 @@ async fn test_stack_is_same_amount_in_request_and_items_to_trade() {
async fn test_stack_is_same_amount_in_request_and_items_to_trade2() { async fn test_stack_is_same_amount_in_request_and_items_to_trade2() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| { let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone(); let mut entity_gateway = entity_gateway.clone();
@ -3959,8 +3959,8 @@ async fn test_stack_is_same_amount_in_request_and_items_to_trade2() {
async fn test_items_to_trade_count_less_than() { async fn test_items_to_trade_count_less_than() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![ let p1_inv = vec![
entity_gateway.create_item( entity_gateway.create_item(
@ -4061,8 +4061,8 @@ async fn test_items_to_trade_count_less_than() {
async fn test_items_to_trade_count_greater_than() { async fn test_items_to_trade_count_greater_than() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(23)).await.unwrap(); entity_gateway.set_character_meseta(&char1.id, Meseta(23)).await.unwrap();
@ -4171,8 +4171,8 @@ async fn test_items_to_trade_count_greater_than() {
async fn test_items_to_trade_count_mismatch_with_meseta() { async fn test_items_to_trade_count_mismatch_with_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![ let p1_inv = vec![
entity_gateway.create_item( entity_gateway.create_item(
@ -4273,8 +4273,8 @@ async fn test_items_to_trade_count_mismatch_with_meseta() {
async fn test_dropping_item_after_trade() { async fn test_dropping_item_after_trade() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new(); let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item( p1_inv.push(entity_gateway.create_item(
@ -4364,7 +4364,7 @@ async fn test_dropping_item_after_trade() {
assert!(matches!(ack[3], (ClientId(2), SendShipPacket::TradeSuccessful {..}))); assert!(matches!(ack[3], (ClientId(2), SendShipPacket::TradeSuccessful {..})));
assert!(matches!(ack[4], (ClientId(1), SendShipPacket::TradeSuccessful {..}))); assert!(matches!(ack[4], (ClientId(1), SendShipPacket::TradeSuccessful {..})));
let ack = ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
let _ack = ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
client: 0, client: 0,
target: 0, target: 0,
unknown1: 0, unknown1: 0,

Loading…
Cancel
Save