Skip to content

Commit

Permalink
Merge pull request #988 from planetarium/bugfix/sweep
Browse files Browse the repository at this point in the history
Bugfix/sweep
  • Loading branch information
hskim committed May 4, 2022
2 parents 0ba1a73 + ef94d59 commit 4eac17f
Show file tree
Hide file tree
Showing 6 changed files with 792 additions and 4 deletions.
42 changes: 40 additions & 2 deletions .Lib9c.Tests/Action/HackAndSlashSweepTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId)
}

[Fact]
public void Execute_InvalidStageException()
public void Execute_StageClearedException()
{
var action = new HackAndSlashSweep
{
Expand All @@ -265,14 +265,52 @@ public void Execute_InvalidStageException()
stageId = 50,
};

Assert.Throws<InvalidStageException>(() => action.Execute(new ActionContext()
Assert.Throws<StageClearedException>(() => action.Execute(new ActionContext()
{
PreviousStates = _initialState,
Signer = _agentAddress,
Random = new TestRandom(),
}));
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void Execute_InvalidStageException(bool backward)
{
var action = new HackAndSlashSweep
{
apStoneCount = 1,
avatarAddress = _avatarAddress,
worldId = 1,
stageId = 50,
};
var worldSheet = _initialState.GetSheet<WorldSheet>();
var worldUnlockSheet = _initialState.GetSheet<WorldUnlockSheet>();

_avatarState.worldInformation.ClearStage(1, 2, 1, worldSheet, worldUnlockSheet);

var state = _initialState;
if (backward)
{
state = _initialState.SetState(_avatarAddress, _avatarState.Serialize());
}
else
{
state = _initialState
.SetState(
_avatarAddress.Derive(LegacyWorldInformationKey),
_avatarState.worldInformation.Serialize());
}

Assert.Throws<InvalidStageException>(() => action.Execute(new ActionContext()
{
PreviousStates = state,
Signer = _agentAddress,
Random = new TestRandom(),
}));
}

[Theory]
[InlineData(GameConfig.MimisbrunnrWorldId, true)]
[InlineData(GameConfig.MimisbrunnrWorldId, false)]
Expand Down
Loading

0 comments on commit 4eac17f

Please sign in to comment.