Skip to content

Commit

Permalink
Merge pull request #2595 from greymistcube/bump/libplanet-to-4.6.0
Browse files Browse the repository at this point in the history
⬆️ Bump libplanet to 4.6.0
  • Loading branch information
greymistcube authored May 28, 2024
2 parents 5300e99 + 982fed3 commit f3596a6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 83 deletions.
82 changes: 0 additions & 82 deletions .Lib9c.Tests/Action/RewardGoldTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,88 +491,6 @@ void AssertMinerReward(int blockIndex, string expected)
AssertMinerReward(50457601, "0");
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task Genesis_StateRootHash(bool mainnet)
{
BlockPolicySource blockPolicySource = new BlockPolicySource();
NCStagePolicy stagePolicy = new NCStagePolicy(default, 2);
IBlockPolicy policy = blockPolicySource.GetPolicy();
Block genesis;
if (mainnet)
{
const string genesisBlockPath = "https://release.nine-chronicles.com/genesis-block-9c-main";
var uri = new Uri(genesisBlockPath);
using var client = new HttpClient();
var rawBlock = await client.GetByteArrayAsync(uri);
var blockDict = (Bencodex.Types.Dictionary)new Codec().Decode(rawBlock);
genesis = BlockMarshaler.UnmarshalBlock(blockDict);
}
else
{
var adminPrivateKey = new PrivateKey();
var adminAddress = adminPrivateKey.Address;
var activatedAccounts = ImmutableHashSet<Address>.Empty;
var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 };
var privateKey = new PrivateKey();
(ActivationKey activationKey, PendingActivationState pendingActivation) =
ActivationKey.Create(privateKey, nonce);
var pendingActivationStates = new List<PendingActivationState>
{
pendingActivation,
};
var initializeStates = new InitializeStates(
rankingState: new RankingState0(),
shopState: new ShopState(),
gameConfigState: new GameConfigState(),
redeemCodeState: new RedeemCodeState(Bencodex.Types.Dictionary.Empty
.Add("address", RedeemCodeState.Address.Serialize())
.Add("map", Bencodex.Types.Dictionary.Empty)
),
adminAddressState: new AdminState(adminAddress, 1500000),
activatedAccountsState: new ActivatedAccountsState(activatedAccounts),
#pragma warning disable CS0618
// Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319
goldCurrencyState: new GoldCurrencyState(Currency.Legacy("NCG", 2, null)),
#pragma warning restore CS0618
goldDistributions: new GoldDistribution[0],
tableSheets: TableSheetsImporter.ImportSheets(),
pendingActivationStates: pendingActivationStates.ToArray()
);
var tempActionEvaluator = new ActionEvaluator(
policyBlockActionGetter: _ => policy.BlockAction,
stateStore: new TrieStateStore(new MemoryKeyValueStore()),
actionTypeLoader: new NCActionLoader());
genesis = BlockChain.ProposeGenesisBlock(
tempActionEvaluator,
transactions: ImmutableList<Transaction>.Empty
.Add(Transaction.Create(
0,
new PrivateKey(),
null,
new ActionBase[] { initializeStates }.ToPlainValues()))
);
}

var store = new DefaultStore(null);
var stateStore = new TrieStateStore(new DefaultKeyValueStore(null));
var blockChain = BlockChain.Create(
policy: policy,
store: store,
stagePolicy: stagePolicy,
stateStore: stateStore,
genesisBlock: genesis,
actionEvaluator: new ActionEvaluator(
policyBlockActionGetter: _ => policy.BlockAction,
stateStore: stateStore,
actionTypeLoader: new NCActionLoader()
),
renderers: new IRenderer[] { new ActionRenderer(), new BlockRenderer() }
);
Assert.Equal(genesis.StateRootHash, blockChain.Genesis.StateRootHash);
}

[Theory]
[InlineData(5, 4)]
[InlineData(101, 100)]
Expand Down
2 changes: 1 addition & 1 deletion .Libplanet
Submodule .Libplanet updated 41 files
+55 −0 CHANGES.md
+26 −0 Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs
+10 −0 Libplanet.Action/ActionEvaluator.cs
+52 −0 Libplanet.Action/BlockProtocolVersionNotSupportedException.cs
+4 −0 Libplanet.Action/IActionEvaluator.cs
+0 −130 Libplanet.Common/Nonce.cs
+0 −4 Libplanet.Explorer.Executable/Options.cs
+0 −8 Libplanet.Explorer.Executable/Program.cs
+80 −0 Libplanet.Explorer.Tests/Fixtures/BlockChainStatesFixture.cs
+18 −31 Libplanet.Explorer.Tests/Queries/RawStateQueryTest.cs
+213 −159 Libplanet.Explorer.Tests/Queries/StateQueryTest.Legacy.cs
+0 −77 Libplanet.Explorer.Tests/Queries/StateQueryTest.Mocks.cs
+142 −149 Libplanet.Explorer.Tests/Queries/StateQueryTest.cs
+4 −0 Libplanet.Explorer/GraphTypes/AccountStateType.cs
+41 −0 Libplanet.Explorer/GraphTypes/WorldStateType.cs
+0 −9 Libplanet.Explorer/Queries/StateQuery.cs
+80 −0 Libplanet.Mocks/MockBlockChainStates.cs
+1 −2 Libplanet.Net.Tests/Consensus/ContextNonProposerTest.cs
+13 −0 Libplanet.Tests/Action/ActionEvaluatorTest.cs
+92 −110 Libplanet.Tests/Action/WorldTest.cs
+15 −0 Libplanet.Tests/Action/WorldV0Test.cs
+15 −0 Libplanet.Tests/Action/WorldV1Test.cs
+1 −2 Libplanet.Tests/Blockchain/BlockChainTest.Append.cs
+0 −89 Libplanet.Tests/Blockchain/Renderers/AtomicActionRendererTest.cs
+65 −0 Libplanet.Tests/Blocks/BlockMarshalerTest.Legacy.cs
+1 −1 Libplanet.Tests/Blocks/BlockMarshalerTest.cs
+11 −71 Libplanet.Tests/Blocks/BlockMetadataTest.cs
+13 −13 Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs
+109 −0 Libplanet.Tests/Fixtures/LegacyBlocks.cs
+0 −58 Libplanet.Tests/NonceTest.cs
+0 −6 Libplanet.Tests/TestUtils.cs
+3 −5 Libplanet.Types/Blocks/BlockContent.cs
+19 −48 Libplanet.Types/Blocks/BlockMarshaler.cs
+17 −9 Libplanet.Types/Blocks/BlockMetadata.cs
+1 −2 Libplanet.Types/Blocks/IBlockHeader.cs
+3 −4 Libplanet.Types/Blocks/IPreEvaluationBlockHeader.cs
+2 −2 Libplanet.Types/Blocks/PreEvaluationBlockHeader.cs
+1 −2 Libplanet/Blockchain/BlockChain.cs
+0 −123 Libplanet/Blockchain/Renderers/AtomicActionRenderer.cs
+0 −3 Libplanet/Blockchain/Renderers/IActionRenderer.cs
+1 −1 Libplanet/Libplanet.csproj

0 comments on commit f3596a6

Please sign in to comment.