Skip to content

Commit c5644af

Browse files
author
ulismoon (hyeon)
authored
Merge pull request #2556 from planetarium/release/1.11.0
Deploy 1.11.0
2 parents c6a17ce + 7c90f7d commit c5644af

File tree

265 files changed

+7910
-6969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+7910
-6969
lines changed

.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Lib9c.Tests.Action;
1010
using Libplanet.Action.State;
1111
using Libplanet.Crypto;
12+
using Libplanet.Mocks;
1213
using Libplanet.Types.Assets;
1314
using Nekoyume;
1415
using Nekoyume.Action;
@@ -30,7 +31,7 @@ public class CreateOrReplaceAvatarTest
3031

3132
public CreateOrReplaceAvatarTest()
3233
{
33-
_initialStates = new World(new MockWorldState());
34+
_initialStates = new World(MockUtil.MockModernWorldState);
3435

3536
#pragma warning disable CS0618
3637
var ncgCurrency = Currency.Legacy("NCG", 2, null);
@@ -549,11 +550,12 @@ private static void Execute(
549550
Assert.Contains(inventoryCostumes, e => e.Id == costumeId);
550551
}
551552

553+
var allRuneState = nextStates.GetRuneState(avatarAddr.Value, out _);
552554
foreach (var (runeId, runeLevel) in action.Runes)
553555
{
554-
var runeList = (List)nextStates.GetLegacyState(
555-
RuneState.DeriveAddress(avatarAddr.Value, runeId))!;
556-
Assert.Equal(runeLevel, runeList[1].ToInteger());
556+
var runeState = allRuneState.GetRuneState(runeId);
557+
Assert.NotNull(runeState);
558+
Assert.Equal(runeLevel, runeState.Level);
557559
}
558560

559561
var crystalRandomSkillAddr =

.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Lib9c.Tests.Action;
33
using Libplanet.Action.State;
44
using Libplanet.Crypto;
5+
using Libplanet.Mocks;
56
using Libplanet.Types.Assets;
67
using Nekoyume.Model.State;
78
using Nekoyume.Module;
@@ -30,9 +31,8 @@ public FaucetCurrencyTest(ITestOutputHelper outputHelper)
3031
_crystal = Currency.Legacy("CRYSTAL", 18, null);
3132
#pragma warning restore CS0618
3233

33-
_initialState = new World(
34-
new MockWorldState()
35-
.AddBalance(GoldCurrencyState.Address, _ncg * int.MaxValue));
34+
_initialState = new World(MockWorldState.CreateModern()
35+
.SetBalance(GoldCurrencyState.Address, _ncg * int.MaxValue));
3636

3737
var goldCurrencyState = new GoldCurrencyState(_ncg);
3838
_agentAddress = new PrivateKey().Address;

.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Xunit;
1818
using Xunit.Abstractions;
1919
using static Lib9c.SerializeKeys;
20+
using Libplanet.Mocks;
2021

2122
namespace Lib9c.DevExtensions.Tests.Action
2223
{
@@ -33,7 +34,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
3334
.WriteTo.TestOutput(outputHelper)
3435
.CreateLogger();
3536

36-
_initialState = new World(new MockWorldState());
37+
_initialState = new World(MockUtil.MockModernWorldState);
3738
var sheets = TableSheetsImporter.ImportSheets();
3839
foreach (var (key, value) in sheets)
3940
{
@@ -52,7 +53,6 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
5253
agentAddress,
5354
0,
5455
tableSheets.GetAvatarSheets(),
55-
new GameConfigState(sheets[nameof(GameConfigSheet)]),
5656
new PrivateKey().Address
5757
);
5858
agentState.avatarAddresses.Add(0, _avatarAddress);

.Lib9c.Tests/AccountExtensions.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action
66
using Bencodex.Types;
77
using Libplanet.Action.State;
88
using Libplanet.Crypto;
9+
using Libplanet.Mocks;
910
using Nekoyume.Action;
1011
using Nekoyume.Helper;
1112
using Nekoyume.Model.Coupons;
@@ -34,7 +35,6 @@ public AccountStateDeltaExtensionsTest()
3435
_agentAddress,
3536
0,
3637
_tableSheets.GetAvatarSheets(),
37-
new GameConfigState(),
3838
default
3939
);
4040
}
@@ -46,7 +46,7 @@ public AccountStateDeltaExtensionsTest()
4646
public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrystal, Type exc)
4747
{
4848
var context = new ActionContext();
49-
IWorld states = new World(new MockWorldState());
49+
IWorld states = new World(MockUtil.MockModernWorldState);
5050
var rewardInfoAddress = new PrivateKey().Address;
5151
var rewardRecord = new WorldBossKillRewardRecord();
5252
for (int i = 0; i < level; i++)
@@ -106,7 +106,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys
106106
[Fact]
107107
public void SetCouponWallet()
108108
{
109-
IWorld states = new World(new MockWorldState());
109+
IWorld states = new World(MockUtil.MockModernWorldState);
110110
var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA");
111111
var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135");
112112
var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B");
@@ -162,7 +162,7 @@ public void Mead(int agentBalance)
162162
var mead = Currencies.Mead;
163163
var price = RequestPledge.DefaultRefillMead * mead;
164164
ActionContext context = new ActionContext();
165-
IWorld states = new World(new MockWorldState())
165+
IWorld states = new World(MockUtil.MockModernWorldState)
166166
.SetLegacyState(
167167
agentContractAddress,
168168
List.Empty.Add(patron.Serialize()).Add(true.Serialize()))

.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Lib9c.Tests.Action
99
using Lib9c.Tests.Extensions;
1010
using Libplanet.Action.State;
1111
using Libplanet.Crypto;
12+
using Libplanet.Mocks;
1213
using Libplanet.Types.Assets;
1314
using Nekoyume;
1415
using Nekoyume.Action;
@@ -41,31 +42,30 @@ public AccountStateViewExtensionsTest()
4142
_agentAddress,
4243
0,
4344
_tableSheets.GetAvatarSheets(),
44-
new GameConfigState(),
4545
default
4646
);
4747
}
4848

4949
[Fact]
5050
public void TryGetAvatarStateEmptyAddress()
5151
{
52-
var states = new World(new MockWorldState());
52+
var states = new World(MockUtil.MockModernWorldState);
5353

5454
Assert.False(states.TryGetAvatarState(default, default, out _));
5555
}
5656

5757
[Fact]
5858
public void TryGetAvatarStateAddressKeyNotFoundException()
5959
{
60-
var states = new World(new MockWorldState()).SetLegacyState(default, Dictionary.Empty);
60+
var states = new World(MockUtil.MockModernWorldState).SetLegacyState(default, Dictionary.Empty);
6161

6262
Assert.False(states.TryGetAvatarState(default, default, out _));
6363
}
6464

6565
[Fact]
6666
public void TryGetAvatarStateKeyNotFoundException()
6767
{
68-
var states = new World(new MockWorldState())
68+
var states = new World(MockUtil.MockModernWorldState)
6969
.SetLegacyState(
7070
default,
7171
Dictionary.Empty
@@ -78,23 +78,23 @@ public void TryGetAvatarStateKeyNotFoundException()
7878
[Fact]
7979
public void TryGetAvatarStateInvalidCastException()
8080
{
81-
var states = new World(new MockWorldState()).SetLegacyState(default, default(Text));
81+
var states = new World(MockUtil.MockModernWorldState).SetLegacyState(default, default(Text));
8282

8383
Assert.False(states.TryGetAvatarState(default, default, out _));
8484
}
8585

8686
[Fact]
8787
public void TryGetAvatarStateInvalidAddress()
8888
{
89-
var states = new World(new MockWorldState()).SetAvatarState(default, _avatarState);
89+
var states = new World(MockUtil.MockModernWorldState).SetAvatarState(default, _avatarState);
9090

9191
Assert.False(states.TryGetAvatarState(Addresses.GameConfig, _avatarAddress, out _));
9292
}
9393

9494
[Fact]
9595
public void GetAvatarStateV2()
9696
{
97-
IWorld states = new World(new MockWorldState());
97+
IWorld states = new World(MockUtil.MockModernWorldState);
9898
states = states
9999
.SetAvatarState(_avatarAddress, _avatarState);
100100

@@ -118,12 +118,12 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)
118118
_ => throw new ArgumentException(),
119119
};
120120

121-
IWorld states = new World(new MockWorldState());
121+
IWorld states = new World(MockUtil.MockModernWorldState);
122122
states = states
123123
.SetAvatarState(_avatarAddress, _avatarState);
124124
states = states.SetAccount(
125125
accountAddress,
126-
states.GetAccount(accountAddress).SetNull(_avatarAddress));
126+
states.GetAccount(accountAddress).RemoveState(_avatarAddress));
127127
var exc = Assert.Throws<FailedLoadStateException>(() => states.GetAvatarState(_avatarAddress));
128128
Assert.Contains(account, exc.Message);
129129
}
@@ -133,7 +133,7 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)
133133
[InlineData(false)]
134134
public void TryGetAvatarState(bool backward)
135135
{
136-
IWorld states = new World(new MockWorldState());
136+
IWorld states = new World(MockUtil.MockModernWorldState);
137137
if (backward)
138138
{
139139
states = states
@@ -151,7 +151,7 @@ public void TryGetAvatarState(bool backward)
151151
[Fact]
152152
public void GetStatesAsDict()
153153
{
154-
IWorld states = new World(new MockWorldState());
154+
IWorld states = new World(MockUtil.MockModernWorldState);
155155
var dict = new Dictionary<Address, IValue>
156156
{
157157
{ new PrivateKey().Address, Null.Value },
@@ -178,7 +178,7 @@ public void GetStatesAsDict()
178178
[Fact]
179179
public void GetSheets()
180180
{
181-
IWorld states = new World(new MockWorldState());
181+
IWorld states = new World(MockUtil.MockModernWorldState);
182182
SheetsExtensionsTest.InitSheets(
183183
states,
184184
out _,
@@ -205,7 +205,7 @@ public void GetSheets()
205205
[InlineData(true)]
206206
public void GetCrystalCostState(bool exist)
207207
{
208-
IWorld states = new World(new MockWorldState());
208+
IWorld states = new World(MockUtil.MockModernWorldState);
209209
int expectedCount = exist ? 1 : 0;
210210
FungibleAssetValue expectedCrystal = exist
211211
? 100 * CrystalCalculator.CRYSTAL
@@ -238,7 +238,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist)
238238
Address previousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 1);
239239
Address beforePreviousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 2);
240240
var crystalCostState = new CrystalCostState(default, 100 * CrystalCalculator.CRYSTAL);
241-
IWorld state = new World(new MockWorldState())
241+
IWorld state = new World(MockUtil.MockModernWorldState)
242242
.SetLegacyState(dailyCostAddress, crystalCostState.Serialize())
243243
.SetLegacyState(weeklyCostAddress, crystalCostState.Serialize())
244244
.SetLegacyState(previousCostAddress, crystalCostState.Serialize())
@@ -268,7 +268,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist)
268268
[Fact]
269269
public void GetCouponWallet()
270270
{
271-
IWorld states = new World(new MockWorldState());
271+
IWorld states = new World(MockUtil.MockModernWorldState);
272272
var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA");
273273
var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135");
274274
var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B");

.Lib9c.Tests/Action/ActionContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Lib9c.Tests.Action
22
{
3+
using System.Collections.Generic;
4+
using System.Collections.Immutable;
35
using System.Security.Cryptography;
46
using Libplanet.Action;
57
using Libplanet.Action.State;
@@ -14,6 +16,8 @@ public class ActionContext : IActionContext
1416

1517
private IRandom _random = null;
1618

19+
private IReadOnlyList<ITransaction> _txs = null;
20+
1721
public BlockHash? GenesisHash { get; set; }
1822

1923
public Address Signer { get; set; }
@@ -36,6 +40,12 @@ public class ActionContext : IActionContext
3640

3741
public bool BlockAction { get; }
3842

43+
public IReadOnlyList<ITransaction> Txs
44+
{
45+
get => _txs ?? ImmutableList<ITransaction>.Empty;
46+
set => _txs = value;
47+
}
48+
3949
public void UseGas(long gas)
4050
{
4151
_gasUsed += gas;

.Lib9c.Tests/Action/ActionContextExtensionsTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Lib9c.Tests.Action
44
using Libplanet.Action;
55
using Libplanet.Action.State;
66
using Libplanet.Crypto;
7+
using Libplanet.Mocks;
78
using Libplanet.Types.Assets;
89
using Nekoyume;
910
using Nekoyume.Action;
@@ -143,7 +144,7 @@ public static IEnumerable<object[]> IsPreviewNetTestcases()
143144
[MemberData(nameof(IsMainNetTestcases))]
144145
public void IsMainNet(GoldCurrencyState goldCurrencyState, bool expected)
145146
{
146-
var state = new World(new MockWorldState()).SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize());
147+
var state = new World(MockUtil.MockModernWorldState).SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize());
147148
IActionContext context = new ActionContext
148149
{
149150
PreviousState = state,

.Lib9c.Tests/Action/ActionEvaluationTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action
66
using Lib9c.Formatters;
77
using Libplanet.Action.State;
88
using Libplanet.Crypto;
9+
using Libplanet.Mocks;
910
using Libplanet.Types.Assets;
1011
using MessagePack;
1112
using MessagePack.Resolvers;
@@ -34,7 +35,7 @@ public ActionEvaluationTest()
3435
#pragma warning restore CS0618
3536
_signer = new PrivateKey().Address;
3637
_sender = new PrivateKey().Address;
37-
_states = new World(new MockWorldState())
38+
_states = new World(MockUtil.MockModernWorldState)
3839
.SetLegacyState(_signer, (Text)"ANYTHING")
3940
.SetLegacyState(default, Dictionary.Empty.Add("key", "value"))
4041
.MintAsset(context, _signer, _currency * 10000);

0 commit comments

Comments
 (0)