diff --git a/.Lib9c.Tests/Action/BattleArenaTest.cs b/.Lib9c.Tests/Action/BattleArenaTest.cs index d427263f8e..41dcf9aaf8 100644 --- a/.Lib9c.Tests/Action/BattleArenaTest.cs +++ b/.Lib9c.Tests/Action/BattleArenaTest.cs @@ -1119,6 +1119,70 @@ public void Execute_ValidateDuplicateTicketPurchaseException() })); } + [Fact] + public void ExecuteRuneNotFoundException() + { + var previousStates = _initialStates; + var context = new ActionContext(); + Assert.True( + previousStates.GetSheet().TryGetValue( + 1, + out var row)); + + if (!row.TryGetRound(1, out var roundData)) + { + throw new RoundNotFoundException( + $"[{nameof(BattleArena)}] ChampionshipId({row.ChampionshipId}) - round({1})"); + } + + if (roundData.ArenaType != ArenaType.OffSeason) + { + throw new InvalidSeasonException( + $"[{nameof(BattleArena)}] This test is only for OffSeason. ArenaType : {roundData.ArenaType}"); + } + + var random = new TestRandom(); + previousStates = JoinArena( + context, + previousStates, + _agent1Address, + _avatar1Address, + roundData.StartBlockIndex, + 1, + 1, + random); + previousStates = JoinArena( + context, + previousStates, + _agent2Address, + _avatar2Address, + roundData.StartBlockIndex, + 1, + 1, + random); + + var action = new BattleArena + { + myAvatarAddress = _avatar1Address, + enemyAvatarAddress = _avatar2Address, + championshipId = 1, + round = 1, + ticket = 1, + costumes = new List(), + equipments = new List(), + runeInfos = new List { new (0, 10035), }, + }; + Assert.Throws( + () => action.Execute( + new ActionContext + { + BlockIndex = roundData.StartBlockIndex + 1, + PreviousState = previousStates, + Signer = _agent1Address, + RandomSeed = 0, + })); + } + [Theory] [InlineData(8, null)] [InlineData(100, null)] diff --git a/Lib9c/Action/BattleArena.cs b/Lib9c/Action/BattleArena.cs index c3bbf7bee3..c413843398 100644 --- a/Lib9c/Action/BattleArena.cs +++ b/Lib9c/Action/BattleArena.cs @@ -354,6 +354,12 @@ public override IWorld Execute(IActionContext context) states = states.SetRuneState(myAvatarAddress, myRuneStates); } + // just validate + foreach (var runeSlotInfo in runeInfos) + { + myRuneStates.GetRuneState(runeSlotInfo.RuneId); + } + // get enemy equipped items var enemyItemSlotStateAddress = ItemSlotState.DeriveAddress(enemyAvatarAddress, BattleType.Arena); var enemyItemSlotState = states.TryGetLegacyState(enemyItemSlotStateAddress, out List rawEnemyItemSlotState)