Skip to content

Commit

Permalink
Merge pull request #2583 from planetarium/bugfix/200/build-failure
Browse files Browse the repository at this point in the history
Fix broken tests
  • Loading branch information
U-lis authored Sep 13, 2024
2 parents 6ec7c59 + c39f473 commit b4ee381
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
39 changes: 33 additions & 6 deletions NineChronicles.Headless.Tests/ArenaParticipantsWorkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using Libplanet.Mocks;
using Nekoyume;
using Nekoyume.Action;
using Nekoyume.Model;
using Nekoyume.Model.Arena;
using Nekoyume.Model.EnumType;
using Nekoyume.Model.Item;
using Nekoyume.Model.Quest;
using Nekoyume.Model.State;
using Nekoyume.Module;
using Nekoyume.TableData;
Expand Down Expand Up @@ -92,7 +94,8 @@ public void AvatarAddrAndScoresWithRank()
.SetLegacyState(sheetAddress, csv.Serialize())
.SetLegacyState(participantsAddr, participants.Serialize())
.SetLegacyState(arenaScore.Address, arenaScore.Serialize());
var actual = ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state);
var actual =
ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state);
Assert.Equal(2, actual.Count);
var first = actual.First();
Assert.Equal(avatarAddress, first.avatarAddr);
Expand All @@ -114,7 +117,16 @@ public void GetArenaParticipants()
avatarAddress,
agentAddress,
0,
tableSheets.GetAvatarSheets(),
new QuestList(
tableSheets.QuestSheet,
tableSheets.QuestRewardSheet,
tableSheets.QuestItemRewardSheet,
tableSheets.EquipmentItemRecipeSheet,
tableSheets.EquipmentItemSubRecipeSheet
),
new WorldInformation(
0, tableSheets.WorldSheet, GameConfig.IsEditor, "test"
),
new Address(),
"avatar_state"
);
Expand All @@ -123,15 +135,26 @@ public void GetArenaParticipants()
avatar2Address,
agentAddress,
0,
tableSheets.GetAvatarSheets(),
new QuestList(
tableSheets.QuestSheet,
tableSheets.QuestRewardSheet,
tableSheets.QuestItemRewardSheet,
tableSheets.EquipmentItemRecipeSheet,
tableSheets.EquipmentItemSubRecipeSheet
),
new WorldInformation(
0, tableSheets.WorldSheet, GameConfig.IsEditor, "test"
),
new Address(),
"avatar_state2"
);

// equipment
var equipmentSheet = tableSheets.EquipmentItemSheet;
var random = new Random(0);
var equipment = (Equipment)ItemFactory.CreateItem(equipmentSheet.Values.First(r => r.ItemSubType == ItemSubType.Armor), random);
var equipment =
(Equipment)ItemFactory.CreateItem(equipmentSheet.Values.First(r => r.ItemSubType == ItemSubType.Armor),
random);
equipment.equipped = true;
avatarState.inventory.AddItem(equipment);
avatarState2.inventory.AddItem(equipment);
Expand Down Expand Up @@ -182,8 +205,12 @@ public void GetArenaParticipants()
{
state = state.SetLegacyState(Addresses.GetSheetAddress(key), s.Serialize());
}
var avatarAddrAndScoresWithRank = ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state);
var actual = ArenaParticipantsWorker.GetArenaParticipants(state, participants.AvatarAddresses, avatarAddrAndScoresWithRank);

var avatarAddrAndScoresWithRank =
ArenaParticipantsWorker.AvatarAddrAndScoresWithRank(participants.AvatarAddresses, currentRoundData, state);
var actual =
ArenaParticipantsWorker.GetArenaParticipants(state, participants.AvatarAddresses,
avatarAddrAndScoresWithRank);
Assert.Equal(2, actual.Count);
var first = actual.First();
Assert.Equal(avatarAddress, first.AvatarAddr);
Expand Down
16 changes: 14 additions & 2 deletions NineChronicles.Headless.Tests/Common/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
using Libplanet.Common;
using Libplanet.Crypto;
using Libplanet.Types.Assets;
using Nekoyume;
using Nekoyume.Model;
using Nekoyume.Model.Item;
using Nekoyume.Model.Quest;
using Nekoyume.Model.State;

namespace NineChronicles.Headless.Tests
Expand All @@ -30,7 +33,15 @@ public static class Fixtures
AvatarAddress,
UserAddress,
0,
TableSheetsFX.GetAvatarSheets(),
new QuestList(
TableSheetsFX.GetAvatarSheets().QuestSheet,
TableSheetsFX.GetAvatarSheets().QuestRewardSheet,
TableSheetsFX.GetAvatarSheets().QuestItemRewardSheet,
TableSheetsFX.GetAvatarSheets().EquipmentItemRecipeSheet,
TableSheetsFX.GetAvatarSheets().EquipmentItemSubRecipeSheet
),
new WorldInformation(0, TableSheetsFX.GetAvatarSheets().WorldSheet,
GameConfig.IsEditor, "test"),
new Address(),
"avatar_state_fx"
);
Expand All @@ -54,7 +65,8 @@ public static ShopState ShopStateFX()
var equipment = ItemFactory.CreateItemUsable(row, Guid.Empty, 0);
if (equipment is ITradableItem tradableItem)
{
var shopItem = new ShopItem(UserAddress, AvatarAddress, Guid.NewGuid(), index * CurrencyFX, tradableItem);
var shopItem = new ShopItem(UserAddress, AvatarAddress, Guid.NewGuid(), index * CurrencyFX,
tradableItem);
shopState.Register(shopItem);
}
}
Expand Down

0 comments on commit b4ee381

Please sign in to comment.