Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code sweep dev extensions #3033

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Bencodex.Types;
using Lib9c.DevExtensions.Action.Craft;
using Lib9c.Tests;
using Lib9c.Tests.Action;
Expand All @@ -7,8 +6,6 @@
using Libplanet.Action.State;
using Libplanet.Crypto;
using Nekoyume;
using Nekoyume.Action;
using Nekoyume.Model;
using Nekoyume.Module;
using Xunit;

Expand Down Expand Up @@ -45,14 +42,14 @@ public void StageUnlockTest(string typeIdentifier, int expectedStage)
var action = new UnlockCraftAction
{
AvatarAddress = _avatarAddress,
ActionType = new ActionTypeAttribute(typeIdentifier)
ActionType = new ActionTypeAttribute(typeIdentifier),
};

var state = action.Execute(new ActionContext
{
PreviousState = _initialStateV2,
Signer = _agentAddress,
BlockIndex = 0L
BlockIndex = 0L,
});

var avatarState = state.GetAvatarState(_avatarAddress);
Expand Down
12 changes: 7 additions & 5 deletions .Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public CreateOrReplaceAvatarTest()
(200000, 1),
(201010, 2),
},
new[] { 40100000 },
new[] { 40100000, },
new[]
{
(10001, 0),
(20001, 1),
(30001, 10),
},
(1, new[] { 1, 2, 3 }),
(1, new[] { 1, 2, 3, }),
};
}

Expand Down Expand Up @@ -221,7 +221,7 @@ public static IEnumerable<object?[]>
0, 0, "AB", 0, 0, 0, 0, 1,
null,
null,
new[] { -1 },
new[] { -1, },
null,
null,
};
Expand Down Expand Up @@ -273,7 +273,7 @@ public static IEnumerable<object?[]>
null,
null,
null,
(0, new[] { -1 }),
(0, new[] { -1, }),
};
}

Expand Down Expand Up @@ -304,6 +304,7 @@ public void Serialize(
equipments.Add((row.ResultEquipmentId, data.level));
}
}

var action = new CreateOrReplaceAvatar(
avatarIndex,
name,
Expand Down Expand Up @@ -371,6 +372,7 @@ public void Execute_Success(
equipments.Add((row.ResultEquipmentId, data.level));
}
}

var agentAddr = new PrivateKey().Address;
Execute(
_initialStates,
Expand Down Expand Up @@ -521,7 +523,7 @@ private static void Execute(
Assert.Contains(
equipment.StatsMap.GetAdditionalStats(false),
stat => stat.statType == statOption.Key &&
stat.additionalValue == statOption.Value);
stat.additionalValue == statOption.Value);
}

var skillOptions = options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ namespace Lib9c.DevExtensions.Tests.Action.Factory
{
public class CreateOrReplaceAvatarFactoryTest
{
private readonly TableSheets _tableSheets;

public CreateOrReplaceAvatarFactoryTest()
{
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
}
private readonly TableSheets _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());

[Theory]
[MemberData(
Expand Down Expand Up @@ -50,9 +45,7 @@ public void TryGetByBlockIndex_Success(
}

var (e, r) = CreateOrReplaceAvatarFactory
.TryGetByBlockIndex(
blockIndex,
avatarIndex,
.TryGetByBlockIndex(avatarIndex,
name,
hair,
lens,
Expand All @@ -73,14 +66,7 @@ public void TryGetByBlockIndex_Success(
Assert.Equal(ear, r.Ear);
Assert.Equal(tail, r.Tail);
Assert.Equal(level, r.Level);
if (equipments is null)
{
Assert.Empty(r.Equipments);
}
else
{
Assert.True(equipments.SequenceEqual(r.Equipments));
}
Assert.True(equipments.SequenceEqual(r.Equipments));

if (foods is null)
{
Expand Down Expand Up @@ -142,9 +128,7 @@ public void TryGetByBlockIndex_Failure(
(int stageId, int[] crystalRandomBuffIds)? crystalRandomBuff)
{
var (e, r) = CreateOrReplaceAvatarFactory
.TryGetByBlockIndex(
blockIndex,
avatarIndex,
.TryGetByBlockIndex(avatarIndex,
name,
hair,
lens,
Expand Down
12 changes: 6 additions & 6 deletions .Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ int expectedCrystal
FaucetNcg = faucetNcg,
FaucetCrystal = faucetCrystal,
};
var state = action.Execute(new ActionContext { PreviousState = _initialState });
AgentState agentState = state.GetAgentState(_agentAddress);
FungibleAssetValue expectedNcgAsset =
var state = action.Execute(new ActionContext { PreviousState = _initialState, });
var agentState = state.GetAgentState(_agentAddress);
var expectedNcgAsset =
new FungibleAssetValue(_ncg, expectedNcg, 0);
FungibleAssetValue ncg = state.GetBalance(_agentAddress, state.GetGoldCurrency());
var ncg = state.GetBalance(_agentAddress, state.GetGoldCurrency());
Assert.Equal(expectedNcgAsset, ncg);

FungibleAssetValue expectedCrystalAsset =
var expectedCrystalAsset =
new FungibleAssetValue(_crystal, expectedCrystal, 0);
FungibleAssetValue crystal = state.GetBalance(_agentAddress, _crystal);
var crystal = state.GetBalance(_agentAddress, _crystal);
Assert.Equal(expectedCrystalAsset, crystal);
}
}
Expand Down
18 changes: 12 additions & 6 deletions .Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
var tableSheets = new TableSheets(sheets);
_runeSheet = _initialState.GetSheet<RuneSheet>();

Address agentAddress = new PrivateKey().Address;
var agentAddress = new PrivateKey().Address;
_avatarAddress = new PrivateKey().Address;
var agentState = new AgentState(agentAddress);
var avatarState = AvatarState.Create(
Expand All @@ -58,8 +58,8 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
agentState.avatarAddresses.Add(0, _avatarAddress);

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(_avatarAddress, avatarState);
.SetAgentState(agentAddress, agentState)
.SetAvatarState(_avatarAddress, avatarState);
}

[Theory]
Expand All @@ -71,7 +71,7 @@ public void Execute_FaucetRune(List<FaucetRuneInfo> faucetRuneInfos)
AvatarAddress = _avatarAddress,
FaucetRuneInfos = faucetRuneInfos,
};
var states = action.Execute(new ActionContext { PreviousState = _initialState });
var states = action.Execute(new ActionContext { PreviousState = _initialState, });
foreach (var rune in faucetRuneInfos)
{
var expectedRune = RuneHelper.ToCurrency(
Expand Down Expand Up @@ -113,9 +113,15 @@ private class FaucetRuneInfoGenerator : IEnumerable<object[]>
},
};

public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
public IEnumerator<object[]> GetEnumerator()
{
return _data.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
}
Loading
Loading