Skip to content

Commit

Permalink
Merge pull request #2403 from planetarium/main
Browse files Browse the repository at this point in the history
Backmerge main to development
  • Loading branch information
U-lis authored Feb 19, 2024
2 parents 4e2f5d9 + 9bd7fed commit 8d17d6e
Show file tree
Hide file tree
Showing 140 changed files with 318 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Nekoyume.Model;
using Nekoyume.Module;
using Xunit;
using static Lib9c.SerializeKeys;

namespace Lib9c.DevExtensions.Tests.Action.Craft
{
Expand All @@ -21,13 +20,11 @@ public class UnlockCraftActionTest
private readonly Address _agentAddress;
private readonly Address _avatarAddress;
private readonly IWorld _initialStateV2;
private readonly Address _worldInformationAddress;

public UnlockCraftActionTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
_worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey);
}

[Theory]
Expand Down Expand Up @@ -58,8 +55,8 @@ public void StageUnlockTest(string typeIdentifier, int expectedStage)
BlockIndex = 0L
});

var worldInformation =
new WorldInformation((Dictionary)state.GetLegacyState(_worldInformationAddress));
var avatarState = state.GetAvatarState(_avatarAddress);
var worldInformation = avatarState.worldInformation;
Assert.True(worldInformation.IsStageCleared(expectedStage));
}
}
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)

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

[Theory]
Expand Down
2 changes: 2 additions & 0 deletions .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ public void SetInventoryState(Inventory targetInventory)
[MemberData(nameof(FetchWorldInfo))]
public void SetWorldInformation(int lastClearedStage, WorldInformation targetInfo)
{
// FIXME: The test now writes worldInformation in LegacyAccount,
// which should be moved to Addresses.WorldInformation
var state = Manipulate(
_initialStateV2,
new List<(Address, Address, IValue)>
Expand Down
2 changes: 0 additions & 2 deletions .Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public class ClearStageTest
private readonly Address _agentAddress;
private readonly Address _avatarAddress;
private readonly IWorld _initialStateV2;
private readonly Address _worldInfoAddress;

public ClearStageTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
_worldInfoAddress = _avatarAddress.Derive(SerializeKeys.LegacyWorldInformationKey);
}

[Fact]
Expand Down
9 changes: 4 additions & 5 deletions .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public void TryGetAvatarStateInvalidCastException()
[Fact]
public void TryGetAvatarStateInvalidAddress()
{
var states = new World(new MockWorldState()).SetAvatarState(
default, _avatarState, true, true, true, true);
var states = new World(new MockWorldState()).SetAvatarState(default, _avatarState);

Assert.False(states.TryGetAvatarState(Addresses.GameConfig, _avatarAddress, out _));
}
Expand All @@ -97,7 +96,7 @@ public void GetAvatarStateV2()
{
IWorld states = new World(new MockWorldState());
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);

var v2 = states.GetAvatarState(_avatarAddress);
Assert.NotNull(v2.inventory);
Expand All @@ -121,7 +120,7 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)

IWorld states = new World(new MockWorldState());
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);
states = states.SetAccount(
accountAddress,
states.GetAccount(accountAddress).SetNull(_avatarAddress));
Expand All @@ -143,7 +142,7 @@ public void TryGetAvatarState(bool backward)
else
{
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);
}

Assert.True(states.TryGetAvatarState(_agentAddress, _avatarAddress, out _));
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ArenahelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ArenaHelperTest(ITestOutputHelper outputHelper)
_state = _state
.SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize())
.SetAgentState(_agent1Address, agent1State)
.SetAvatarState(_avatar1Address, _avatar1, true, true, true, true)
.SetAvatarState(_avatar1Address, _avatar1)
.SetLegacyState(Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize());

Log.Logger = new LoggerConfiguration()
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/BattleArenaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public BattleArenaTest(ITestOutputHelper outputHelper)
_initialStates = _initialStates
.SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize())
.SetAgentState(_agent1Address, agent1State)
.SetAvatarState(_avatar1Address, avatar1State, true, true, true, true)
.SetAvatarState(_avatar1Address, avatar1State)
.SetAgentState(_agent2Address, agent2State)
.SetAvatarState(_avatar2Address, avatar2State, true, true, true, true)
.SetAvatarState(_avatar2Address, avatar2State)
.SetAgentState(_agent3Address, agent3State)
.SetAvatarState(_avatar3Address, avatar3State, true, true, true, true)
.SetAvatarState(_avatar3Address, avatar3State)
.SetAgentState(_agent4Address, agent4State)
.SetAvatarState(_avatar4Address, avatar4State, true, true, true, true)
.SetAvatarState(_avatar4Address, avatar4State)
.SetLegacyState(
Addresses.GameConfig,
new GameConfigState(_sheets[nameof(GameConfigSheet)]).Serialize());
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/Buy7Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ out _
purchaseInfos.Add(purchaseInfo);

_initialState = _initialState
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(Addresses.Shop, legacyShopState.Serialize());
}
Expand Down Expand Up @@ -462,7 +462,7 @@ public void Execute_Throw_NotEnoughClearedStageLevel()
0
),
};
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);

PurchaseInfo0 purchaseInfo0 = new PurchaseInfo0(
default,
Expand Down Expand Up @@ -904,7 +904,7 @@ public void Execute_ErrorCode_InvalidPrice(int shopPrice, int price)

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
10 changes: 5 additions & 5 deletions .Lib9c.Tests/Action/BuyMultipleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public BuyMultipleTest(ITestOutputHelper outputHelper)
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetLegacyState(Addresses.Shop, shopState.Serialize())
.SetAgentState(_buyerAgentAddress, buyerAgentState)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState)
.MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100);
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public void Execute(params ShopItemData[] productDatas)
Assert.Equal(3, shopState.Products.Count);

_initialState = _initialState
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetLegacyState(Addresses.Shop, shopState.Serialize());

var priceData = new PriceData(goldCurrency);
Expand All @@ -305,7 +305,7 @@ public void Execute(params ShopItemData[] productDatas)
priceData.TaxedPriceSum[agentState.address] = new FungibleAssetValue(goldCurrency, 0, 0);

_initialState = _initialState
.SetAvatarState(avatarState.address, avatarState, true, true, true, true);
.SetAvatarState(avatarState.address, avatarState);
}

IWorld previousStates = _initialState;
Expand Down Expand Up @@ -444,7 +444,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException()
0
),
};
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);

var action = new BuyMultiple
{
Expand Down Expand Up @@ -631,7 +631,7 @@ public void ExecuteThrowShopItemExpiredError()

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/BuyProduct2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public BuyProduct2Test(ITestOutputHelper outputHelper)
_initialState = _initialState
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(SellerAgentAddress, sellerAgentState)
.SetAvatarState(SellerAvatarAddress, sellerAvatarState, true, true, true, true)
.SetAvatarState(SellerAvatarAddress, sellerAvatarState)
.SetAgentState(_sellerAgentAddress2, agentState2)
.SetAvatarState(_sellerAvatarAddress2, sellerAvatarState2, true, true, true, true)
.SetAvatarState(_sellerAvatarAddress2, sellerAvatarState2)
.SetAgentState(BuyerAgentAddress, buyerAgentState)
.SetAvatarState(BuyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(BuyerAvatarAddress, _buyerAvatarState)
.MintAsset(context, BuyerAgentAddress, _goldCurrencyState.Currency * 1);
}

Expand Down
23 changes: 10 additions & 13 deletions .Lib9c.Tests/Action/BuyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public BuyTest(ITestOutputHelper outputHelper)
_initialState = _initialState
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(_sellerAgentAddress, sellerAgentState)
.SetAvatarState(_sellerAvatarAddress, sellerAvatarState, true, true, true, true)
.SetAvatarState(_sellerAvatarAddress, sellerAvatarState)
.SetAgentState(_buyerAgentAddress, buyerAgentState)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState)
.SetLegacyState(Addresses.Shop, new ShopState().Serialize())
.MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100);
}
Expand Down Expand Up @@ -332,8 +332,8 @@ public void Execute(params OrderData[] orderDataList)

_initialState = _initialState
.SetLegacyState(Order.DeriveAddress(orderId), order.Serialize())
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(orderDigestListState.Address, orderDigestListState.Serialize());
}
Expand Down Expand Up @@ -476,8 +476,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty
0
),
};
_initialState = _initialState.SetAvatarState(
_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);
}

var avatarAddress = equalAvatarAddress ? _buyerAvatarAddress : default;
Expand Down Expand Up @@ -575,8 +574,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember)

var digest = order.Digest(sellerAvatarState, _tableSheets.CostumeStatSheet);
shopState.Add(digest, 0);
_initialState = _initialState.SetAvatarState(
sellerAvatarAddress, sellerAvatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(sellerAvatarAddress, sellerAvatarState);
}

_initialState = _initialState.SetLegacyState(Order.DeriveAddress(_orderId), order.Serialize());
Expand Down Expand Up @@ -717,8 +715,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)
itemSubType,
orderData.ItemCount
);
_initialState.SetAvatarState(
orderData.SellerAvatarAddress, sellerAvatarState, false, true, false, false);
_initialState.SetAvatarState(orderData.SellerAvatarAddress, sellerAvatarState);

var sellItem = order.Sell3(sellerAvatarState);
var orderDigest = order.Digest(sellerAvatarState, _tableSheets.CostumeStatSheet);
Expand Down Expand Up @@ -757,8 +754,8 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)

_initialState = _initialState
.SetLegacyState(Order.DeriveAddress(orderId), order.Serialize())
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(orderDigestListState.Address, orderDigestListState.Serialize());
}
Expand Down Expand Up @@ -985,7 +982,7 @@ public void Execute_With_Testbed()

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/CancelProductRegistration0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public CancelProductRegistration0Test(ITestOutputHelper outputHelper)
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(_agentAddress, agentState)
.SetLegacyState(Addresses.Shop, new ShopState().Serialize())
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);
}

[Theory]
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ChargeActionPoint0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void Execute()
var state = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(agentAddress, agent)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/ChargeActionPoint2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ChargeActionPoint2Test()
_initialState = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(_agentAddress, agent)
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public void Execute(bool useTradable)

Assert.Equal(0, avatarState.actionPoint);

var state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
var state = _initialState.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public void Execute_Throw_NotEnoughMaterialException(bool useTradable)

Assert.Equal(0, avatarState.actionPoint);

var state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
var state = _initialState.SetAvatarState(_avatarAddress, avatarState);

var action = new ChargeActionPoint2()
{
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/ChargeActionPointTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ChargeActionPointTest()
_initialState = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(_agentAddress, agent)
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -78,7 +78,7 @@ public void Execute(bool useTradable)
Assert.Equal(0, avatarState.actionPoint);

IWorld state;
state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = _initialState.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -131,13 +131,13 @@ public void Execute_Throw_Exception(bool useAvatarAddress, bool useTradable, boo
if (enough)
{
avatarState.inventory.AddItem(apStone);
state = state.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = state.SetAvatarState(_avatarAddress, avatarState);
}

if (charge)
{
avatarState.actionPoint = state.GetGameConfigState().ActionPointMax;
state = state.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = state.SetAvatarState(_avatarAddress, avatarState);
}

var action = new ChargeActionPoint()
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ClaimItemsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private IWorld GenerateAvatar(IWorld state, out Address avatarAddress, out Addre

state = state
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);

return state;
}
Expand Down
Loading

0 comments on commit 8d17d6e

Please sign in to comment.