diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index d69271af8b..4e23dedd97 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -544,5 +544,46 @@ public void Execute_With_Hammer(bool oldStart) Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(expectedCost, slotResult.gold); } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Execute_Throw_InvalidItemTypeException(bool withMaterials) + { + var types = ItemEnhancement.HammerBannedTypes; + foreach (var itemSubType in types) + { + var row = + _tableSheets.EquipmentItemSheet.Values.First(r => r.ItemSubType == itemSubType); + var equipment = ItemFactory.CreateItemUsable(row, Guid.NewGuid(), 0); + _avatarState.inventory.AddItem(equipment); + _initialState = _initialState.SetAvatarState(_avatarAddress, _avatarState); + var materialIds = new List(); + if (withMaterials) + { + materialIds.Add(Guid.NewGuid()); + materialIds.Add(Guid.NewGuid()); + } + + var action = new ItemEnhancement + { + itemId = equipment.ItemId, + materialIds = materialIds, + avatarAddress = _avatarAddress, + slotIndex = 0, + hammers = new Dictionary + { + [600301] = 3, + }, + }; + Assert.Throws(() => action.Execute(new ActionContext + { + BlockIndex = 1, + PreviousState = _initialState, + RandomSeed = 0, + Signer = _agentAddress, + })); + } + } } } diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index a757d58560..773c4b3783 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -220,7 +220,8 @@ public override IWorld Execute(IActionContext context) // Validate enhancement materials var uniqueMaterialIds = materialIds.Distinct().ToList(); - if (!uniqueMaterialIds.Any()) + // Validate hammer without materials count + if (hammers.Any()) { if (HammerBannedTypes.Contains(enhancementEquipment.ItemSubType)) {