Skip to content

Commit

Permalink
Merge pull request #2556 from planetarium/release/1.11.0
Browse files Browse the repository at this point in the history
Deploy 1.11.0
  • Loading branch information
U-lis authored Apr 29, 2024
2 parents c6a17ce + 7c90f7d commit c5644af
Show file tree
Hide file tree
Showing 265 changed files with 7,910 additions and 6,969 deletions.
10 changes: 6 additions & 4 deletions .Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Lib9c.Tests.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using Nekoyume;
using Nekoyume.Action;
Expand All @@ -30,7 +31,7 @@ public class CreateOrReplaceAvatarTest

public CreateOrReplaceAvatarTest()
{
_initialStates = new World(new MockWorldState());
_initialStates = new World(MockUtil.MockModernWorldState);

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

var allRuneState = nextStates.GetRuneState(avatarAddr.Value, out _);
foreach (var (runeId, runeLevel) in action.Runes)
{
var runeList = (List)nextStates.GetLegacyState(
RuneState.DeriveAddress(avatarAddr.Value, runeId))!;
Assert.Equal(runeLevel, runeList[1].ToInteger());
var runeState = allRuneState.GetRuneState(runeId);
Assert.NotNull(runeState);
Assert.Equal(runeLevel, runeState.Level);
}

var crystalRandomSkillAddr =
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Lib9c.Tests.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using Nekoyume.Model.State;
using Nekoyume.Module;
Expand Down Expand Up @@ -30,9 +31,8 @@ public FaucetCurrencyTest(ITestOutputHelper outputHelper)
_crystal = Currency.Legacy("CRYSTAL", 18, null);
#pragma warning restore CS0618

_initialState = new World(
new MockWorldState()
.AddBalance(GoldCurrencyState.Address, _ncg * int.MaxValue));
_initialState = new World(MockWorldState.CreateModern()
.SetBalance(GoldCurrencyState.Address, _ncg * int.MaxValue));

var goldCurrencyState = new GoldCurrencyState(_ncg);
_agentAddress = new PrivateKey().Address;
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Xunit;
using Xunit.Abstractions;
using static Lib9c.SerializeKeys;
using Libplanet.Mocks;

namespace Lib9c.DevExtensions.Tests.Action
{
Expand All @@ -33,7 +34,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
.WriteTo.TestOutput(outputHelper)
.CreateLogger();

_initialState = new World(new MockWorldState());
_initialState = new World(MockUtil.MockModernWorldState);
var sheets = TableSheetsImporter.ImportSheets();
foreach (var (key, value) in sheets)
{
Expand All @@ -52,7 +53,6 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
agentAddress,
0,
tableSheets.GetAvatarSheets(),
new GameConfigState(sheets[nameof(GameConfigSheet)]),
new PrivateKey().Address
);
agentState.avatarAddresses.Add(0, _avatarAddress);
Expand Down
67 changes: 0 additions & 67 deletions .Lib9c.Tests/AccountExtensions.cs

This file was deleted.

8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action
using Bencodex.Types;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Nekoyume.Action;
using Nekoyume.Helper;
using Nekoyume.Model.Coupons;
Expand Down Expand Up @@ -34,7 +35,6 @@ public AccountStateDeltaExtensionsTest()
_agentAddress,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);
}
Expand All @@ -46,7 +46,7 @@ public AccountStateDeltaExtensionsTest()
public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrystal, Type exc)
{
var context = new ActionContext();
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
var rewardInfoAddress = new PrivateKey().Address;
var rewardRecord = new WorldBossKillRewardRecord();
for (int i = 0; i < level; i++)
Expand Down Expand Up @@ -106,7 +106,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys
[Fact]
public void SetCouponWallet()
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA");
var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135");
var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B");
Expand Down Expand Up @@ -162,7 +162,7 @@ public void Mead(int agentBalance)
var mead = Currencies.Mead;
var price = RequestPledge.DefaultRefillMead * mead;
ActionContext context = new ActionContext();
IWorld states = new World(new MockWorldState())
IWorld states = new World(MockUtil.MockModernWorldState)
.SetLegacyState(
agentContractAddress,
List.Empty.Add(patron.Serialize()).Add(true.Serialize()))
Expand Down
30 changes: 15 additions & 15 deletions .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Lib9c.Tests.Action
using Lib9c.Tests.Extensions;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using Nekoyume;
using Nekoyume.Action;
Expand Down Expand Up @@ -41,31 +42,30 @@ public AccountStateViewExtensionsTest()
_agentAddress,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);
}

[Fact]
public void TryGetAvatarStateEmptyAddress()
{
var states = new World(new MockWorldState());
var states = new World(MockUtil.MockModernWorldState);

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

[Fact]
public void TryGetAvatarStateAddressKeyNotFoundException()
{
var states = new World(new MockWorldState()).SetLegacyState(default, Dictionary.Empty);
var states = new World(MockUtil.MockModernWorldState).SetLegacyState(default, Dictionary.Empty);

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

[Fact]
public void TryGetAvatarStateKeyNotFoundException()
{
var states = new World(new MockWorldState())
var states = new World(MockUtil.MockModernWorldState)
.SetLegacyState(
default,
Dictionary.Empty
Expand All @@ -78,23 +78,23 @@ public void TryGetAvatarStateKeyNotFoundException()
[Fact]
public void TryGetAvatarStateInvalidCastException()
{
var states = new World(new MockWorldState()).SetLegacyState(default, default(Text));
var states = new World(MockUtil.MockModernWorldState).SetLegacyState(default, default(Text));

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

[Fact]
public void TryGetAvatarStateInvalidAddress()
{
var states = new World(new MockWorldState()).SetAvatarState(default, _avatarState);
var states = new World(MockUtil.MockModernWorldState).SetAvatarState(default, _avatarState);

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

[Fact]
public void GetAvatarStateV2()
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
states = states
.SetAvatarState(_avatarAddress, _avatarState);

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

IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
states = states
.SetAvatarState(_avatarAddress, _avatarState);
states = states.SetAccount(
accountAddress,
states.GetAccount(accountAddress).SetNull(_avatarAddress));
states.GetAccount(accountAddress).RemoveState(_avatarAddress));
var exc = Assert.Throws<FailedLoadStateException>(() => states.GetAvatarState(_avatarAddress));
Assert.Contains(account, exc.Message);
}
Expand All @@ -133,7 +133,7 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)
[InlineData(false)]
public void TryGetAvatarState(bool backward)
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
if (backward)
{
states = states
Expand All @@ -151,7 +151,7 @@ public void TryGetAvatarState(bool backward)
[Fact]
public void GetStatesAsDict()
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
var dict = new Dictionary<Address, IValue>
{
{ new PrivateKey().Address, Null.Value },
Expand All @@ -178,7 +178,7 @@ public void GetStatesAsDict()
[Fact]
public void GetSheets()
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
SheetsExtensionsTest.InitSheets(
states,
out _,
Expand All @@ -205,7 +205,7 @@ public void GetSheets()
[InlineData(true)]
public void GetCrystalCostState(bool exist)
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
int expectedCount = exist ? 1 : 0;
FungibleAssetValue expectedCrystal = exist
? 100 * CrystalCalculator.CRYSTAL
Expand Down Expand Up @@ -238,7 +238,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist)
Address previousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 1);
Address beforePreviousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 2);
var crystalCostState = new CrystalCostState(default, 100 * CrystalCalculator.CRYSTAL);
IWorld state = new World(new MockWorldState())
IWorld state = new World(MockUtil.MockModernWorldState)
.SetLegacyState(dailyCostAddress, crystalCostState.Serialize())
.SetLegacyState(weeklyCostAddress, crystalCostState.Serialize())
.SetLegacyState(previousCostAddress, crystalCostState.Serialize())
Expand Down Expand Up @@ -268,7 +268,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist)
[Fact]
public void GetCouponWallet()
{
IWorld states = new World(new MockWorldState());
IWorld states = new World(MockUtil.MockModernWorldState);
var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA");
var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135");
var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B");
Expand Down
10 changes: 10 additions & 0 deletions .Lib9c.Tests/Action/ActionContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Lib9c.Tests.Action
{
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Security.Cryptography;
using Libplanet.Action;
using Libplanet.Action.State;
Expand All @@ -14,6 +16,8 @@ public class ActionContext : IActionContext

private IRandom _random = null;

private IReadOnlyList<ITransaction> _txs = null;

public BlockHash? GenesisHash { get; set; }

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

public bool BlockAction { get; }

public IReadOnlyList<ITransaction> Txs
{
get => _txs ?? ImmutableList<ITransaction>.Empty;
set => _txs = value;
}

public void UseGas(long gas)
{
_gasUsed += gas;
Expand Down
3 changes: 2 additions & 1 deletion .Lib9c.Tests/Action/ActionContextExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Lib9c.Tests.Action
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using Nekoyume;
using Nekoyume.Action;
Expand Down Expand Up @@ -143,7 +144,7 @@ public static IEnumerable<object[]> IsPreviewNetTestcases()
[MemberData(nameof(IsMainNetTestcases))]
public void IsMainNet(GoldCurrencyState goldCurrencyState, bool expected)
{
var state = new World(new MockWorldState()).SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize());
var state = new World(MockUtil.MockModernWorldState).SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize());
IActionContext context = new ActionContext
{
PreviousState = state,
Expand Down
3 changes: 2 additions & 1 deletion .Lib9c.Tests/Action/ActionEvaluationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action
using Lib9c.Formatters;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using MessagePack;
using MessagePack.Resolvers;
Expand Down Expand Up @@ -34,7 +35,7 @@ public ActionEvaluationTest()
#pragma warning restore CS0618
_signer = new PrivateKey().Address;
_sender = new PrivateKey().Address;
_states = new World(new MockWorldState())
_states = new World(MockUtil.MockModernWorldState)
.SetLegacyState(_signer, (Text)"ANYTHING")
.SetLegacyState(default, Dictionary.Empty.Add("key", "value"))
.MintAsset(context, _signer, _currency * 10000);
Expand Down
Loading

0 comments on commit c5644af

Please sign in to comment.