Skip to content

Commit

Permalink
Merge pull request #2518 from greymistcube/bump/libplanet-to-4.3.0
Browse files Browse the repository at this point in the history
⬆️ Bump libplanet to 4.3.0
  • Loading branch information
greymistcube authored Apr 17, 2024
2 parents 352331f + 0111483 commit ad43d12
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
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
18 changes: 16 additions & 2 deletions .Lib9c.Tests/Action/RewardGoldTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,24 @@ public async Task Genesis_StateRootHash(bool mainnet)
[InlineData(1, 0)]
public void TransferMead(int patronMead, int balance)
{
var agentAddress = new PrivateKey().Address;
var agentKey = new PrivateKey();
var agentAddress = agentKey.Address;
var patronAddress = new PrivateKey().Address;
var contractAddress = agentAddress.GetPledgeAddress();
IActionContext context = new ActionContext();
IActionContext context = new ActionContext()
{
Txs = ImmutableList.Create<ITransaction>(
new Transaction(
new UnsignedTx(
new TxInvoice(
null,
DateTimeOffset.UtcNow,
new TxActionList(new List<IValue>()),
maxGasPrice: Currencies.Mead * 4,
gasLimit: 4),
new TxSigningMetadata(agentKey.PublicKey, 0)),
agentKey)),
};
IWorld states = new World(MockUtil.MockModernWorldState)
.MintAsset(context, patronAddress, patronMead * Currencies.Mead)
.TransferAsset(context, patronAddress, agentAddress, 1 * Currencies.Mead)
Expand Down
23 changes: 21 additions & 2 deletions .Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
namespace Lib9c.Tests.Action.Scenario
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using Bencodex.Types;
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Libplanet.Mocks;
using Libplanet.Types.Assets;
using Libplanet.Types.Tx;
using Nekoyume;
using Nekoyume.Action;
using Nekoyume.Module;
Expand All @@ -20,10 +24,25 @@ public void Contract()
{
Currency mead = Currencies.Mead;
var patron = new PrivateKey().Address;
IActionContext context = new ActionContext();
var agentKey = new PrivateKey();
var agentAddress = agentKey.Address;

IActionContext context = new ActionContext()
{
Txs = ImmutableList.Create<ITransaction>(
new Transaction(
new UnsignedTx(
new TxInvoice(
null,
DateTimeOffset.UtcNow,
new TxActionList(new List<IValue>()),
maxGasPrice: Currencies.Mead * 4,
gasLimit: 4),
new TxSigningMetadata(agentKey.PublicKey, 0)),
agentKey)),
};
IWorld states = new World(MockUtil.MockModernWorldState).MintAsset(context, patron, 10 * mead);

var agentAddress = new PrivateKey().Address;
var requestPledge = new RequestPledge
{
AgentAddress = agentAddress,
Expand Down
2 changes: 1 addition & 1 deletion .Libplanet
Submodule .Libplanet updated 49 files
+40 −0 CHANGES.md
+3 −3 Libplanet.Action.Tests/ActionEvaluationTest.cs
+79 −0 Libplanet.Action.Tests/Common/ContextRecordingAction.cs
+82 −0 Libplanet.Action.Tests/Common/Currencies.cs
+101 −186 Libplanet.Action.Tests/Common/DumbAction.cs
+102 −190 Libplanet.Action.Tests/Common/DumbModernAction.cs
+0 −39 Libplanet.Action.Tests/Common/RandomAction.cs
+4 −4 Libplanet.Action.Tests/Loader/IndexedActionLoaderTest.cs
+1 −1 Libplanet.Action.Tests/Sys/RegistryTest.cs
+12 −2 Libplanet.Action/ActionContext.cs
+33 −40 Libplanet.Action/ActionEvaluator.cs
+9 −0 Libplanet.Action/IActionContext.cs
+0 −98 Libplanet.Action/State/IWorld.cs
+361 −0 Libplanet.Action/State/IWorldExtensions.cs
+0 −33 Libplanet.Action/State/IWorldState.cs
+3 −271 Libplanet.Action/State/World.cs
+0 −37 Libplanet.Action/State/WorldBaseState.cs
+8 −8 Libplanet.Benchmarks/AppendBlock.cs
+8 −8 Libplanet.Benchmarks/ProposeBlock.cs
+0 −1 Libplanet.Explorer.Executable/Program.cs
+0 −18 Libplanet.Mocks/MockWorldState.cs
+23 −77 Libplanet.Net.Tests/Protocols/RoutingTableTest.cs
+9 −9 Libplanet.Net.Tests/SwarmTest.Broadcast.cs
+2 −2 Libplanet.Net.Tests/SwarmTest.Fixtures.cs
+8 −9 Libplanet.Net.Tests/SwarmTest.Preload.cs
+7 −7 Libplanet.Net.Tests/SwarmTest.cs
+32 −58 Libplanet.Store/DefaultStore.cs
+1 −1 Libplanet.Store/Libplanet.Store.csproj
+131 −240 Libplanet.Tests/Action/ActionEvaluatorTest.cs
+204 −116 Libplanet.Tests/Action/WorldTest.cs
+5 −6 Libplanet.Tests/Action/WorldV0Test.cs
+7 −62 Libplanet.Tests/Action/WorldV1Test.cs
+52 −32 Libplanet.Tests/Blockchain/BlockChainTest.Append.cs
+19 −19 Libplanet.Tests/Blockchain/BlockChainTest.ProposeBlock.cs
+5 −4 Libplanet.Tests/Blockchain/BlockChainTest.Stage.cs
+36 −35 Libplanet.Tests/Blockchain/BlockChainTest.cs
+3 −2 Libplanet.Tests/Blocks/BlockTest.cs
+25 −87 Libplanet.Tests/Crypto/PublicKeyTest.cs
+39 −38 Libplanet.Tests/TestUtils.cs
+2 −2 Libplanet.Tests/Tx/TransactionExtensionsTest.cs
+22 −40 Libplanet.Tests/Tx/TransactionTest.cs
+20 −18 Libplanet.Tests/Tx/TxActionListTest.cs
+14 −12 Libplanet.Tests/Tx/TxInvoiceTest.cs
+16 −62 Libplanet.Tests/Tx/TxMarshalerTest.cs
+8 −6 Libplanet.Tests/Tx/UnsignedTxTest.cs
+3 −2 Libplanet/Blockchain/BlockChain.cs
+1 −1 Libplanet/Libplanet.csproj
+2 −2 changes/v0.md
+1 −1 changes/v2.md
8 changes: 3 additions & 5 deletions Lib9c/Action/RewardGold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,9 @@ public IWorld MinerReward(IActionContext ctx, IWorld states)

public static IWorld TransferMead(IActionContext context, IWorld states)
{
#pragma warning disable LAA1002
var targetAddresses = states.TotalUpdatedFungibleAssets
#pragma warning restore LAA1002
.Where(pair => pair.Item2.Equals(Currencies.Mead))
.Select(pair => pair.Item1)
var targetAddresses = context.Txs
.Where(tx => tx.MaxGasPrice is { } price && price.Currency.Equals(Currencies.Mead))
.Select(tx => tx.Signer)
.Distinct();
foreach (var address in targetAddresses)
{
Expand Down
3 changes: 1 addition & 2 deletions Lib9c/Module/LegacyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ params Address[] accounts
context,
accounts[i - 1],
accounts[i],
currency * 1,
true);
currency * 1);
}

return world;
Expand Down

0 comments on commit ad43d12

Please sign in to comment.