From c445f1699a916d380b0112db2f87deb56966e171 Mon Sep 17 00:00:00 2001 From: ilgyu Date: Fri, 17 Nov 2023 01:53:39 +0900 Subject: [PATCH] test: Replace with IActionLoader param --- .../Queries/TransactionQueryTest.cs | 5 +- .../ConsensusContextNonProposerTest.cs | 4 ++ .../Consensus/ConsensusContextProposerTest.cs | 1 + .../Consensus/ConsensusContextTest.cs | 9 ++++ .../Consensus/ContextNonProposerTest.cs | 4 +- Libplanet.Net.Tests/Consensus/ContextTest.cs | 6 ++- .../Messages/NetMQMessageCodecTest.cs | 6 ++- Libplanet.Net.Tests/SwarmTest.Broadcast.cs | 12 +++-- Libplanet.Net.Tests/SwarmTest.Fixtures.cs | 10 +++- Libplanet.Net.Tests/SwarmTest.Preload.cs | 46 ++++++++++++------- Libplanet.Net.Tests/SwarmTest.cs | 46 +++++++++++++------ Libplanet.Net.Tests/TestUtils.cs | 13 +++++- .../Transports/BoundPeerExtensionsTest.cs | 4 +- Libplanet.Tests/Action/AccountTest.cs | 4 +- Libplanet.Tests/Action/ActionEvaluatorTest.cs | 44 +++++++++++------- .../Blockchain/BlockChainTest.Append.cs | 10 ++-- .../BlockChainTest.ValidateNextBlock.cs | 3 +- Libplanet.Tests/Blockchain/BlockChainTest.cs | 18 +++++--- .../Blockchain/Policies/BlockPolicyTest.cs | 9 ++-- Libplanet.Tests/TestUtils.cs | 15 +++--- 20 files changed, 186 insertions(+), 83 deletions(-) diff --git a/Libplanet.Explorer.Tests/Queries/TransactionQueryTest.cs b/Libplanet.Explorer.Tests/Queries/TransactionQueryTest.cs index 3caab136c52..a44d928054e 100644 --- a/Libplanet.Explorer.Tests/Queries/TransactionQueryTest.cs +++ b/Libplanet.Explorer.Tests/Queries/TransactionQueryTest.cs @@ -15,12 +15,12 @@ using Libplanet.Types.Assets; using Libplanet.Types.Consensus; using Libplanet.Types.Tx; -using Libplanet.Consensus; using Libplanet.Explorer.Queries; using Libplanet.Store; using Libplanet.Store.Trie; using Xunit; using static Libplanet.Explorer.Tests.GraphQLTestUtils; +using Libplanet.Action.Loader; namespace Libplanet.Explorer.Tests.Queries; @@ -32,10 +32,11 @@ public class TransactionQueryTest public TransactionQueryTest() { - Chain = Libplanet.Tests.TestUtils.MakeBlockChain( + Chain = Libplanet.Tests.TestUtils.MakeBlockChain( new BlockPolicy(), new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(NullAction)), privateKey: new PrivateKey(), timestamp: DateTimeOffset.UtcNow ); diff --git a/Libplanet.Net.Tests/Consensus/ConsensusContextNonProposerTest.cs b/Libplanet.Net.Tests/Consensus/ConsensusContextNonProposerTest.cs index 6d88ea247e2..fb1caf88646 100644 --- a/Libplanet.Net.Tests/Consensus/ConsensusContextNonProposerTest.cs +++ b/Libplanet.Net.Tests/Consensus/ConsensusContextNonProposerTest.cs @@ -44,6 +44,7 @@ public async void NewHeightWithLastCommit() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[2]); blockChain.TipChanged += (_, __) => tipChanged.Set(); consensusContext.MessagePublished += (_, eventArgs) => @@ -119,6 +120,7 @@ public async void HandleMessageFromHigherHeight() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( newHeightDelay, TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[2]); consensusContext.StateChanged += (_, eventArgs) => @@ -247,6 +249,7 @@ public async void UseLastCommitCacheIfHeightContextIsEmpty() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[2]); consensusContext.MessageConsumed += (_, eventArgs) => @@ -287,6 +290,7 @@ public async void NewHeightDelay() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( newHeightDelay, TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[2]); consensusContext.StateChanged += (_, eventArgs) => { diff --git a/Libplanet.Net.Tests/Consensus/ConsensusContextProposerTest.cs b/Libplanet.Net.Tests/Consensus/ConsensusContextProposerTest.cs index 9c447b933b3..9b93e649317 100644 --- a/Libplanet.Net.Tests/Consensus/ConsensusContextProposerTest.cs +++ b/Libplanet.Net.Tests/Consensus/ConsensusContextProposerTest.cs @@ -32,6 +32,7 @@ public async void IncreaseRoundWhenTimeout() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); var timeoutProcessed = new AsyncAutoResetEvent(); diff --git a/Libplanet.Net.Tests/Consensus/ConsensusContextTest.cs b/Libplanet.Net.Tests/Consensus/ConsensusContextTest.cs index f8e1678bf3f..97bc84ff827 100644 --- a/Libplanet.Net.Tests/Consensus/ConsensusContextTest.cs +++ b/Libplanet.Net.Tests/Consensus/ConsensusContextTest.cs @@ -43,6 +43,7 @@ public async void NewHeightIncreasing() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[3]); AsyncAutoResetEvent heightThreeStepChangedToPropose = new AsyncAutoResetEvent(); @@ -113,6 +114,7 @@ public void Ctor() var (_, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); Assert.Equal(ConsensusStep.Null, consensusContext.Step); @@ -126,6 +128,7 @@ public async void NewHeightWhenTipChanged() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( newHeightDelay, TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); Assert.Equal(-1, consensusContext.Height); @@ -142,6 +145,7 @@ public void IgnoreMessagesFromLowerHeight() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); consensusContext.NewHeight(blockChain.Tip.Index + 1); @@ -159,6 +163,7 @@ public void RemoveOldContexts() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); // Create context of index 1. @@ -197,6 +202,7 @@ public async void VoteSetGetOnlyProposeCommitHash() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[1]); consensusContext.StateChanged += (sender, tuple) => @@ -264,6 +270,7 @@ public async void GetVoteSetBits() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[0]); consensusContext.NewHeight(1); var block = blockChain.ProposeBlock(proposer); @@ -336,6 +343,7 @@ public async void HandleVoteSetBits() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[0]); consensusContext.NewHeight(1); consensusContext.StateChanged += (_, eventArgs) => @@ -405,6 +413,7 @@ public async void HandleProposalClaim() var (blockChain, consensusContext) = TestUtils.CreateDummyConsensusContext( TimeSpan.FromSeconds(1), TestUtils.Policy, + TestUtils.ActionLoader, TestUtils.PrivateKeys[0]); consensusContext.NewHeight(1); consensusContext.StateChanged += (_, eventArgs) => diff --git a/Libplanet.Net.Tests/Consensus/ContextNonProposerTest.cs b/Libplanet.Net.Tests/Consensus/ContextNonProposerTest.cs index 57f9dd6599c..73af67e8449 100644 --- a/Libplanet.Net.Tests/Consensus/ContextNonProposerTest.cs +++ b/Libplanet.Net.Tests/Consensus/ContextNonProposerTest.cs @@ -4,6 +4,7 @@ using System.Text.Json; using System.Threading.Tasks; using Bencodex.Types; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; using Libplanet.Blockchain.Policies; @@ -295,7 +296,8 @@ public async Task EnterPreVoteNilOnInvalidBlockContent() using var fx = new MemoryStoreFixture(policy.BlockAction); var diffPolicyBlockChain = - TestUtils.CreateDummyBlockChain(fx, policy, blockChain.Genesis); + TestUtils.CreateDummyBlockChain( + fx, policy, new SingleActionLoader(typeof(DumbAction)), blockChain.Genesis); var invalidTx = diffPolicyBlockChain.MakeTransaction(invalidKey, new DumbAction[] { }); diff --git a/Libplanet.Net.Tests/Consensus/ContextTest.cs b/Libplanet.Net.Tests/Consensus/ContextTest.cs index c93f8942014..7021512259a 100644 --- a/Libplanet.Net.Tests/Consensus/ContextTest.cs +++ b/Libplanet.Net.Tests/Consensus/ContextTest.cs @@ -5,6 +5,7 @@ using Bencodex; using Bencodex.Types; using Libplanet.Action; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain.Policies; using Libplanet.Consensus; @@ -292,10 +293,11 @@ public async Task CanPreCommitOnEndCommit() blockAction: new MinerReward(1), getMaxTransactionsBytes: _ => 50 * 1024); var fx = new MemoryStoreFixture(policy.BlockAction); - var blockChain = Libplanet.Tests.TestUtils.MakeBlockChain( + var blockChain = Libplanet.Tests.TestUtils.MakeBlockChain( policy, fx.Store, - new TrieStateStore(new MemoryKeyValueStore())); + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DelayAction))); Context? context = null; diff --git a/Libplanet.Net.Tests/Messages/NetMQMessageCodecTest.cs b/Libplanet.Net.Tests/Messages/NetMQMessageCodecTest.cs index eb452a3bb3c..11eec0dd9ca 100644 --- a/Libplanet.Net.Tests/Messages/NetMQMessageCodecTest.cs +++ b/Libplanet.Net.Tests/Messages/NetMQMessageCodecTest.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Net; using Bencodex; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; using Libplanet.Blockchain.Policies; @@ -78,10 +79,11 @@ private MessageContent CreateMessage(MessageContent.MessageType type) var privateKey = new PrivateKey(); var boundPeer = new BoundPeer(privateKey.PublicKey, new DnsEndPoint("127.0.0.1", 1000)); IBlockPolicy policy = new BlockPolicy(); - BlockChain chain = MakeBlockChain( + BlockChain chain = MakeBlockChain( policy, new MemoryStore(), - new TrieStateStore(new MemoryKeyValueStore()) + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)) ); var codec = new Codec(); Block genesis = chain.Genesis; diff --git a/Libplanet.Net.Tests/SwarmTest.Broadcast.cs b/Libplanet.Net.Tests/SwarmTest.Broadcast.cs index d6b496bfbe1..b7ee8e04ef5 100644 --- a/Libplanet.Net.Tests/SwarmTest.Broadcast.cs +++ b/Libplanet.Net.Tests/SwarmTest.Broadcast.cs @@ -94,7 +94,8 @@ public async Task BroadcastBlockToReconnectedPeer() var miner = new PrivateKey(); var policy = new NullBlockPolicy(); var fx = new MemoryStoreFixture(policy.BlockAction); - var minerChain = MakeBlockChain(policy, fx.Store, fx.StateStore); + var minerChain = MakeBlockChain( + policy, fx.Store, fx.StateStore, new SingleActionLoader(typeof(DumbAction))); foreach (int i in Enumerable.Range(0, 10)) { Block block = minerChain.ProposeBlock( @@ -183,10 +184,11 @@ public async Task BroadcastIgnoreFromDifferentGenesisHash() BlockChain receiverChain = receiverSwarm.BlockChain; var seedStateStore = new TrieStateStore(new MemoryKeyValueStore()); IBlockPolicy policy = receiverChain.Policy; - BlockChain seedChain = MakeBlockChain( + BlockChain seedChain = MakeBlockChain( policy, new MemoryStore(), seedStateStore, + new SingleActionLoader(typeof(DumbAction)), privateKey: receiverKey); var seedMiner = new PrivateKey(); Swarm seedSwarm = @@ -700,7 +702,8 @@ public async Task BroadcastBlockWithSkip() { var policy = new BlockPolicy(new MinerReward(1)); var fx1 = new MemoryStoreFixture(); - var blockChain = MakeBlockChain(policy, fx1.Store, fx1.StateStore); + var blockChain = MakeBlockChain( + policy, fx1.Store, fx1.StateStore, new SingleActionLoader(typeof(DumbAction))); var privateKey = new PrivateKey(); var minerSwarm = await CreateSwarm(blockChain, privateKey).ConfigureAwait(false); @@ -709,10 +712,11 @@ public async Task BroadcastBlockWithSkip() var loggedRenderer = new LoggedActionRenderer( receiverRenderer, _logger); - var receiverChain = MakeBlockChain( + var receiverChain = MakeBlockChain( policy, fx2.Store, fx2.StateStore, + new SingleActionLoader(typeof(DumbAction)), renderers: new[] { loggedRenderer }); Swarm receiverSwarm = await CreateSwarm(receiverChain).ConfigureAwait(false); diff --git a/Libplanet.Net.Tests/SwarmTest.Fixtures.cs b/Libplanet.Net.Tests/SwarmTest.Fixtures.cs index 1bd32a0bb47..b44f77fb5a2 100644 --- a/Libplanet.Net.Tests/SwarmTest.Fixtures.cs +++ b/Libplanet.Net.Tests/SwarmTest.Fixtures.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; using Libplanet.Blockchain.Policies; @@ -36,7 +37,11 @@ private static (Address, Block[]) using (var storeFx = new MemoryStoreFixture()) { var chain = - MakeBlockChain(policy, storeFx.Store, storeFx.StateStore); + MakeBlockChain( + policy, + storeFx.Store, + storeFx.StateStore, + new SingleActionLoader(typeof(DumbAction))); var miner = new PrivateKey(); var signer = new PrivateKey(); Address address = signer.Address; @@ -113,10 +118,11 @@ private async Task CreateSwarm( { policy = policy ?? new BlockPolicy(new MinerReward(1)); var fx = new MemoryStoreFixture(policy.BlockAction); - var blockchain = MakeBlockChain( + var blockchain = MakeBlockChain( policy, fx.Store, fx.StateStore, + new SingleActionLoader(typeof(DumbAction)), genesisBlock: genesis ); appProtocolVersionOptions ??= new AppProtocolVersionOptions(); diff --git a/Libplanet.Net.Tests/SwarmTest.Preload.cs b/Libplanet.Net.Tests/SwarmTest.Preload.cs index b3d7b736e71..9c6071b868d 100644 --- a/Libplanet.Net.Tests/SwarmTest.Preload.cs +++ b/Libplanet.Net.Tests/SwarmTest.Preload.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Bencodex.Types; using Libplanet.Action; +using Libplanet.Action.Loader; using Libplanet.Action.State; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; @@ -378,20 +379,22 @@ public async Task NoRenderInPreload() { var policy = new BlockPolicy(new MinerReward(1)); var renderer = new RecordingActionRenderer(); - var chain = MakeBlockChain( + var chain = MakeBlockChain( policy, new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), renderers: new[] { renderer }); var senderKey = new PrivateKey(); var receiver = await CreateSwarm(chain).ConfigureAwait(false); var sender = await CreateSwarm( - MakeBlockChain( + MakeBlockChain( policy, new MemoryStore(), - new TrieStateStore(new MemoryKeyValueStore()) + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)) ), senderKey ).ConfigureAwait(false); @@ -434,8 +437,10 @@ public async Task PreloadWithFailedActions() var policy = new BlockPolicy(); var fx1 = new MemoryStoreFixture(); var fx2 = new MemoryStoreFixture(); - var minerChain = MakeBlockChain(policy, fx1.Store, fx1.StateStore); - var receiverChain = MakeBlockChain(policy, fx2.Store, fx2.StateStore); + var minerChain = MakeBlockChain( + policy, fx1.Store, fx1.StateStore, new SingleActionLoader(typeof(ThrowException))); + var receiverChain = MakeBlockChain( + policy, fx2.Store, fx2.StateStore, new SingleActionLoader(typeof(ThrowException))); var minerKey = new PrivateKey(); @@ -500,14 +505,16 @@ public async Task PreloadFromNominer() fxForNominers[1] = new MemoryStoreFixture(policy.BlockAction); var blockChainsForNominers = new[] { - MakeBlockChain( + MakeBlockChain( policy, fxForNominers[0].Store, - fxForNominers[0].StateStore), - MakeBlockChain( + fxForNominers[0].StateStore, + new SingleActionLoader(typeof(DumbAction))), + MakeBlockChain( policy, fxForNominers[1].Store, - fxForNominers[1].StateStore), + fxForNominers[1].StateStore, + new SingleActionLoader(typeof(DumbAction))), }; var nominerSwarm0 = await CreateSwarm(blockChainsForNominers[0]).ConfigureAwait(false); @@ -1005,21 +1012,24 @@ public async Task PreloadIgnorePeerWithDifferentGenesisBlock() var key2 = new PrivateKey(); var policy = new BlockPolicy(); - BlockChain receiverChain = MakeBlockChain( + BlockChain receiverChain = MakeBlockChain( policy, new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), privateKey: key1); - BlockChain validSeedChain = MakeBlockChain( + BlockChain validSeedChain = MakeBlockChain( policy, new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), privateKey: key1, genesisBlock: receiverChain.Genesis); - BlockChain invalidSeedChain = MakeBlockChain( + BlockChain invalidSeedChain = MakeBlockChain( policy, new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), privateKey: key2); Swarm receiverSwarm = await CreateSwarm(receiverChain).ConfigureAwait(false); @@ -1071,8 +1081,10 @@ public async Task ActionExecutionWithBranchpoint() var policy = new BlockPolicy(new MinerReward(1)); var fx1 = new MemoryStoreFixture(policy.BlockAction); var fx2 = new MemoryStoreFixture(policy.BlockAction); - var seedChain = MakeBlockChain(policy, fx1.Store, fx1.StateStore); - var receiverChain = MakeBlockChain(policy, fx2.Store, fx2.StateStore); + var seedChain = MakeBlockChain( + policy, fx1.Store, fx1.StateStore, new SingleActionLoader(typeof(DumbAction))); + var receiverChain = MakeBlockChain( + policy, fx2.Store, fx2.StateStore, new SingleActionLoader(typeof(DumbAction))); var seedKey = new PrivateKey(); @@ -1132,8 +1144,10 @@ public async Task UpdateTxExecution() var policy = new BlockPolicy(new MinerReward(1)); var fx1 = new MemoryStoreFixture(policy.BlockAction); var fx2 = new MemoryStoreFixture(policy.BlockAction); - var seedChain = MakeBlockChain(policy, fx1.Store, fx1.StateStore); - var receiverChain = MakeBlockChain(policy, fx2.Store, fx2.StateStore); + var seedChain = MakeBlockChain( + policy, fx1.Store, fx1.StateStore, new SingleActionLoader(typeof(DumbAction))); + var receiverChain = MakeBlockChain( + policy, fx2.Store, fx2.StateStore, new SingleActionLoader(typeof(DumbAction))); Swarm seed = await CreateSwarm(seedChain).ConfigureAwait(false); diff --git a/Libplanet.Net.Tests/SwarmTest.cs b/Libplanet.Net.Tests/SwarmTest.cs index 8ee5f11e290..8cee7d251c9 100644 --- a/Libplanet.Net.Tests/SwarmTest.cs +++ b/Libplanet.Net.Tests/SwarmTest.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Bencodex.Types; using Libplanet.Action; +using Libplanet.Action.Loader; using Libplanet.Action.State; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; @@ -679,7 +680,8 @@ public async Task ThrowArgumentExceptionInConstructor() { var fx = new MemoryStoreFixture(); var policy = new BlockPolicy(); - var blockchain = MakeBlockChain(policy, fx.Store, fx.StateStore); + var blockchain = MakeBlockChain( + policy, fx.Store, fx.StateStore, new SingleActionLoader(typeof(DumbAction))); var key = new PrivateKey(); var apv = AppProtocolVersion.Sign(key, 1); var apvOptions = new AppProtocolVersionOptions() { AppProtocolVersion = apv }; @@ -877,10 +879,11 @@ public async Task RenderInFork() { var policy = new BlockPolicy(new MinerReward(1)); var renderer = new RecordingActionRenderer(); - var chain = MakeBlockChain( + var chain = MakeBlockChain( policy, new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), renderers: new[] { renderer } ); @@ -889,10 +892,11 @@ public async Task RenderInFork() var miner1 = await CreateSwarm(chain, key1).ConfigureAwait(false); var miner2 = await CreateSwarm( - MakeBlockChain( + MakeBlockChain( policy, new MemoryStore(), - new TrieStateStore(new MemoryKeyValueStore()) + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)) ), key2 ).ConfigureAwait(false); @@ -946,10 +950,11 @@ public async Task HandleReorgInSynchronizing() async Task MakeSwarm(PrivateKey key = null) => await CreateSwarm( - MakeBlockChain( + MakeBlockChain( policy, new MemoryStore(), - new TrieStateStore(new MemoryKeyValueStore()) + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(Sleep)) ), key ); @@ -1122,10 +1127,20 @@ TxPolicyViolationException IsSignerValid( var fx2 = new MemoryStoreFixture(); var swarmA = await CreateSwarm( - MakeBlockChain(policy, fx1.Store, fx1.StateStore, privateKey: validKey)) + MakeBlockChain( + policy, + fx1.Store, + fx1.StateStore, + new SingleActionLoader(typeof(DumbAction)), + privateKey: validKey)) .ConfigureAwait(false); var swarmB = await CreateSwarm( - MakeBlockChain(policy, fx2.Store, fx2.StateStore, privateKey: validKey)) + MakeBlockChain( + policy, + fx2.Store, + fx2.StateStore, + new SingleActionLoader(typeof(DumbAction)), + privateKey: validKey)) .ConfigureAwait(false); var invalidKey = new PrivateKey(); @@ -1181,17 +1196,19 @@ TxPolicyViolationException IsSignerValid( var fx2 = new MemoryStoreFixture(); var swarmA = await CreateSwarm( - MakeBlockChain( + MakeBlockChain( policy, fx1.Store, fx1.StateStore, + new SingleActionLoader(typeof(DumbAction)), privateKey: validKey, timestamp: DateTimeOffset.MinValue)).ConfigureAwait(false); var swarmB = await CreateSwarm( - MakeBlockChain( + MakeBlockChain( policy, fx2.Store, fx2.StateStore, + new SingleActionLoader(typeof(DumbAction)), privateKey: validKey, timestamp: DateTimeOffset.MinValue.AddSeconds(1))).ConfigureAwait(false); @@ -1350,25 +1367,28 @@ public async Task DoNotReceiveBlockFromNodeHavingDifferenceGenesisBlock() var actionsA = new[] { new DumbAction(signerAddress, "1") }; var actionsB = new[] { new DumbAction(signerAddress, "2") }; - var genesisChainA = MakeBlockChain( + var genesisChainA = MakeBlockChain( new BlockPolicy(), new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), actionsA, null, privateKeyA); var genesisBlockA = genesisChainA.Genesis; - var genesisChainB = MakeBlockChain( + var genesisChainB = MakeBlockChain( new BlockPolicy(), new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), actionsB, null, privateKeyB); - var genesisChainC = MakeBlockChain( + var genesisChainC = MakeBlockChain( new BlockPolicy(), new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), genesisBlock: genesisBlockA); var swarmA = diff --git a/Libplanet.Net.Tests/TestUtils.cs b/Libplanet.Net.Tests/TestUtils.cs index a9013fa7791..40e0c92ea62 100644 --- a/Libplanet.Net.Tests/TestUtils.cs +++ b/Libplanet.Net.Tests/TestUtils.cs @@ -5,6 +5,7 @@ using System.Net; using System.Threading.Tasks; using Bencodex; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain; using Libplanet.Blockchain.Policies; @@ -47,6 +48,9 @@ public static class TestUtils blockAction: new MinerReward(1), getMaxTransactionsBytes: _ => 50 * 1024); + public static readonly IActionLoader ActionLoader = new SingleActionLoader( + typeof(DumbAction)); + public static AppProtocolVersion AppProtocolVersion = AppProtocolVersion.FromToken( "1/54684Ac4ee5B933e72144C4968BEa26056880d71/MEQCICGonYW" + ".X8y4JpPIyccPYWGrsCXWA95sBfextucz3lOyAiBUoY5t8aYNPT0lwYwC0MSkK3HT7T" + @@ -84,12 +88,14 @@ public static PrivateKey GeneratePrivateKeyOfBucketIndex(Address tableAddress, i public static BlockChain CreateDummyBlockChain( MemoryStoreFixture fx, IBlockPolicy? policy = null, + IActionLoader? actionLoader = null, Block? genesisBlock = null) { - var blockChain = Libplanet.Tests.TestUtils.MakeBlockChain( + var blockChain = Libplanet.Tests.TestUtils.MakeBlockChain( policy ?? Policy, fx.Store, new TrieStateStore(new MemoryKeyValueStore()), + actionLoader ?? ActionLoader, genesisBlock: genesisBlock); return blockChain; @@ -222,12 +228,13 @@ public static (BlockChain BlockChain, ConsensusContext ConsensusContext) CreateDummyConsensusContext( TimeSpan newHeightDelay, IBlockPolicy? policy = null, + IActionLoader? actionLoader = null, PrivateKey? privateKey = null, ContextTimeoutOption? contextTimeoutOptions = null) { policy ??= Policy; var fx = new MemoryStoreFixture(policy.BlockAction); - var blockChain = CreateDummyBlockChain(fx, policy); + var blockChain = CreateDummyBlockChain(fx, policy, actionLoader); ConsensusContext? consensusContext = null; privateKey ??= PrivateKeys[1]; @@ -253,6 +260,7 @@ public static (BlockChain BlockChain, Context Context) CreateDummyContext( long height = 1, IBlockPolicy? policy = null, + IActionLoader? actionLoader = null, PrivateKey? privateKey = null, ContextTimeoutOption? contextTimeoutOptions = null, ValidatorSet? validatorSet = null) @@ -270,6 +278,7 @@ void BroadcastMessage(ConsensusMsg message) => var (blockChain, consensusContext) = CreateDummyConsensusContext( TimeSpan.FromSeconds(1), policy, + actionLoader, PrivateKeys[1]); context = new Context( diff --git a/Libplanet.Net.Tests/Transports/BoundPeerExtensionsTest.cs b/Libplanet.Net.Tests/Transports/BoundPeerExtensionsTest.cs index 29f496ee1d9..187fbd85341 100644 --- a/Libplanet.Net.Tests/Transports/BoundPeerExtensionsTest.cs +++ b/Libplanet.Net.Tests/Transports/BoundPeerExtensionsTest.cs @@ -3,6 +3,7 @@ using System.Net; using System.Net.Sockets; using System.Threading.Tasks; +using Libplanet.Action.Loader; using Libplanet.Action.Tests.Common; using Libplanet.Blockchain.Policies; using Libplanet.Crypto; @@ -29,7 +30,8 @@ public async Task QueryAppProtocolVersion() { var fx = new MemoryStoreFixture(); var policy = new BlockPolicy(); - var blockchain = MakeBlockChain(policy, fx.Store, fx.StateStore); + var blockchain = MakeBlockChain( + policy, fx.Store, fx.StateStore, new SingleActionLoader(typeof(DumbAction))); var swarmKey = new PrivateKey(); var consensusKey = new PrivateKey(); var validators = new List() diff --git a/Libplanet.Tests/Action/AccountTest.cs b/Libplanet.Tests/Action/AccountTest.cs index 1ab2fa4d235..c86dae011a6 100644 --- a/Libplanet.Tests/Action/AccountTest.cs +++ b/Libplanet.Tests/Action/AccountTest.cs @@ -4,6 +4,7 @@ using System.Numerics; using Bencodex.Types; using Libplanet.Action; +using Libplanet.Action.Loader; using Libplanet.Action.State; using Libplanet.Action.Tests.Common; using Libplanet.Action.Tests.Mocks; @@ -204,10 +205,11 @@ public virtual BlockChain TransferAssetInBlock() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); var privateKey = new PrivateKey(); - BlockChain chain = TestUtils.MakeBlockChain( + BlockChain chain = TestUtils.MakeBlockChain( new NullBlockPolicy(), store, stateStore, + new SingleActionLoader(typeof(DumbAction)), protocolVersion: ProtocolVersion, privateKey: privateKey ); diff --git a/Libplanet.Tests/Action/ActionEvaluatorTest.cs b/Libplanet.Tests/Action/ActionEvaluatorTest.cs index d880354e682..c7c205e4336 100644 --- a/Libplanet.Tests/Action/ActionEvaluatorTest.cs +++ b/Libplanet.Tests/Action/ActionEvaluatorTest.cs @@ -137,10 +137,11 @@ public void Evaluate() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(EvaluateTestAction))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -181,10 +182,11 @@ public void EvaluateWithException() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(ThrowException))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -222,10 +224,11 @@ public void EvaluateWithCriticalException() var stateStore = new TrieStateStore(new MemoryKeyValueStore()); var (chain, actionEvaluator) = - TestUtils.MakeBlockChainAndActionEvaluator( + TestUtils.MakeBlockChainAndActionEvaluator( policy: new BlockPolicy(), store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(ThrowException))); var genesis = chain.Genesis; // Evaluation is run with rehearsal true to get updated addresses on tx creation. var tx = Transaction.Create( @@ -813,10 +816,11 @@ public void EvaluateActions() [Fact] public void EvaluatePolicyBlockAction() { - var (chain, actionEvaluator) = MakeBlockChainAndActionEvaluator( + var (chain, actionEvaluator) = MakeBlockChainAndActionEvaluator( policy: _policy, store: _storeFx.Store, stateStore: _storeFx.StateStore, + actionLoader: new SingleActionLoader(typeof(DumbAction)), genesisBlock: _storeFx.GenesisBlock, privateKey: ChainPrivateKey); (_, Transaction[] txs) = MakeFixturesForAppendTests(); @@ -958,10 +962,11 @@ public void OrderTxsForEvaluation( [Fact] public void TotalUpdatedFungibleAssets() { - var (chain, actionEvaluator) = MakeBlockChainAndActionEvaluator( + var (chain, actionEvaluator) = MakeBlockChainAndActionEvaluator( policy: _policy, store: _storeFx.Store, stateStore: _storeFx.StateStore, + actionLoader: new SingleActionLoader(typeof(MintAction)), genesisBlock: _storeFx.GenesisBlock, privateKey: ChainPrivateKey); var privateKeys = Enumerable.Range(0, 3).Select(_ => new PrivateKey()).ToList(); @@ -1036,11 +1041,12 @@ public void EvaluateActionAndCollectFee() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), actions: new[] { freeGasAction, }, store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(UseGasAction))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -1101,14 +1107,15 @@ public void EvaluateThrowingExceedGasLimit() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), actions: new[] { freeGasAction, }, store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(UseGasAction))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -1175,14 +1182,15 @@ public void EvaluateThrowingInsufficientBalanceForGasFee() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), actions: new[] { freeGasAction, }, store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(UseGasAction))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -1237,14 +1245,15 @@ public void EvaluateMinusGasFee() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( + var chain = TestUtils.MakeBlockChain( policy: new BlockPolicy(), actions: new[] { freeGasAction, }, store: store, - stateStore: stateStore); + stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(UseGasAction))); var tx = Transaction.Create( nonce: 0, privateKey: privateKey, @@ -1387,10 +1396,11 @@ private void MigrateStates() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); Log.Debug("Test Start."); - var chain = MakeBlockChain( + var chain = MakeBlockChain( policy: new BlockPolicy(), store: store, stateStore: stateStore, + actionLoader: new SingleActionLoader(typeof(ModernAction)), protocolVersion: BlockMetadata.LegacyStateVersion); Assert.True(chain.GetWorldState().Legacy); var miner = new PrivateKey(); diff --git a/Libplanet.Tests/Blockchain/BlockChainTest.Append.cs b/Libplanet.Tests/Blockchain/BlockChainTest.Append.cs index c00e9218fad..169e4518e89 100644 --- a/Libplanet.Tests/Blockchain/BlockChainTest.Append.cs +++ b/Libplanet.Tests/Blockchain/BlockChainTest.Append.cs @@ -283,10 +283,11 @@ Func getTxExecution [SkippableFact] public void AppendModern() { - _blockChain = TestUtils.MakeBlockChain( + _blockChain = TestUtils.MakeBlockChain( new NullBlockPolicy(), new MemoryStore(), - new TrieStateStore(new MemoryKeyValueStore())); + new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbModernAction))); var genesis = _blockChain.Genesis; var address1 = new Address(TestUtils.GetRandomBytes(20)); var address2 = new Address(TestUtils.GetRandomBytes(20)); @@ -390,10 +391,11 @@ public void AppendWhenActionEvaluationFailed() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(ThrowException)); var renderer = new RecordingActionRenderer(); BlockChain blockChain = - TestUtils.MakeBlockChain( - policy, store, stateStore, renderers: new[] { renderer }); + TestUtils.MakeBlockChain( + policy, store, stateStore, actionLoader, renderers: new[] { renderer }); var privateKey = new PrivateKey(); var action = new ThrowException { ThrowOnExecution = true }; diff --git a/Libplanet.Tests/Blockchain/BlockChainTest.ValidateNextBlock.cs b/Libplanet.Tests/Blockchain/BlockChainTest.ValidateNextBlock.cs index cda6721c0ca..ddffc608fae 100644 --- a/Libplanet.Tests/Blockchain/BlockChainTest.ValidateNextBlock.cs +++ b/Libplanet.Tests/Blockchain/BlockChainTest.ValidateNextBlock.cs @@ -486,10 +486,11 @@ public void ValidateBlockCommitFailsInsufficientPower() var validator4 = new Validator(privateKey4.PublicKey, 1); var validatorSet = new ValidatorSet( new[] { validator1, validator2, validator3, validator4 }.ToList()); - BlockChain blockChain = TestUtils.MakeBlockChain( + BlockChain blockChain = TestUtils.MakeBlockChain( new NullBlockPolicy(), new MemoryStore(), new TrieStateStore(new MemoryKeyValueStore()), + new SingleActionLoader(typeof(DumbAction)), validatorSet: validatorSet); Block validNextBlock = blockChain.EvaluateAndSign( new BlockContent( diff --git a/Libplanet.Tests/Blockchain/BlockChainTest.cs b/Libplanet.Tests/Blockchain/BlockChainTest.cs index e750413db10..5c5bf1fb9ec 100644 --- a/Libplanet.Tests/Blockchain/BlockChainTest.cs +++ b/Libplanet.Tests/Blockchain/BlockChainTest.cs @@ -307,6 +307,7 @@ public void ActionRenderersHaveDistinctContexts() var policy = new NullBlockPolicy(); var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); var generatedRandomValueLogs = new List(); IActionRenderer[] renderers = Enumerable.Range(0, 2).Select(i => new LoggedActionRenderer( @@ -320,10 +321,11 @@ public void ActionRenderersHaveDistinctContexts() Log.Logger.ForContext("RendererIndex", i) ) ).ToArray(); - BlockChain blockChain = MakeBlockChain( + BlockChain blockChain = MakeBlockChain( policy, store, stateStore, + actionLoader, renderers: renderers ); var privateKey = new PrivateKey(); @@ -345,10 +347,11 @@ public void RenderActionsAfterBlockIsRendered() var policy = new NullBlockPolicy(); var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); var recordingRenderer = new RecordingActionRenderer(); var renderer = new LoggedActionRenderer(recordingRenderer, Log.Logger); - BlockChain blockChain = MakeBlockChain( - policy, store, stateStore, renderers: new[] { renderer }); + BlockChain blockChain = MakeBlockChain( + policy, store, stateStore, actionLoader, renderers: new[] { renderer }); var privateKey = new PrivateKey(); var action = new DumbAction(default, string.Empty); @@ -380,6 +383,7 @@ public void RenderActionsAfterAppendComplete() var policy = new NullBlockPolicy(); var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); IActionRenderer renderer = new AnonymousActionRenderer { @@ -394,8 +398,8 @@ public void RenderActionsAfterAppendComplete() }, }; renderer = new LoggedActionRenderer(renderer, Log.Logger); - BlockChain blockChain = MakeBlockChain( - policy, store, stateStore, renderers: new[] { renderer }); + BlockChain blockChain = MakeBlockChain( + policy, store, stateStore, actionLoader, renderers: new[] { renderer }); var privateKey = new PrivateKey(); var action = new DumbAction(default, string.Empty); @@ -1212,10 +1216,12 @@ public void GetStateReturnsValidStateAfterFork() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = MakeBlockChain( + var actionLoader = new SingleActionLoader(typeof(DumbAction)); + var chain = MakeBlockChain( new NullBlockPolicy(), store, stateStore, + actionLoader, new[] { new DumbAction(_fx.Address1, "item0.0", idempotent: true) }); Assert.Equal("item0.0", (Text)chain.GetWorldState().GetAccount( ReservedAddresses.LegacyAccount).GetState(_fx.Address1)); diff --git a/Libplanet.Tests/Blockchain/Policies/BlockPolicyTest.cs b/Libplanet.Tests/Blockchain/Policies/BlockPolicyTest.cs index 3a6e2eb9650..4b498ab2237 100644 --- a/Libplanet.Tests/Blockchain/Policies/BlockPolicyTest.cs +++ b/Libplanet.Tests/Blockchain/Policies/BlockPolicyTest.cs @@ -155,11 +155,12 @@ public void GetMinTransactionsPerBlock() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); var policy = new BlockPolicy( blockAction: new MinerReward(1), getMinTransactionsPerBlock: index => index == 0 ? 0 : policyLimit); var privateKey = new PrivateKey(); - var chain = TestUtils.MakeBlockChain(policy, store, stateStore); + var chain = TestUtils.MakeBlockChain(policy, store, stateStore, actionLoader); _ = chain.MakeTransaction(privateKey, new DumbAction[] { }); Assert.Single(chain.ListStagedTransactions()); @@ -178,10 +179,11 @@ public void GetMaxTransactionsPerBlock() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); var policy = new BlockPolicy( getMaxTransactionsPerBlock: _ => policyLimit); var privateKey = new PrivateKey(); - var chain = TestUtils.MakeBlockChain(policy, store, stateStore); + var chain = TestUtils.MakeBlockChain(policy, store, stateStore, actionLoader); _ = Enumerable .Range(0, generatedTxCount) @@ -202,11 +204,12 @@ public void GetMaxTransactionsPerSignerPerBlock() var store = new MemoryStore(); var stateStore = new TrieStateStore(new MemoryKeyValueStore()); + var actionLoader = new SingleActionLoader(typeof(DumbAction)); var policy = new BlockPolicy( getMaxTransactionsPerSignerPerBlock: _ => policyLimit); var privateKeys = Enumerable.Range(0, keyCount).Select(_ => new PrivateKey()).ToList(); var minerKey = privateKeys.First(); - var chain = TestUtils.MakeBlockChain(policy, store, stateStore); + var chain = TestUtils.MakeBlockChain(policy, store, stateStore, actionLoader); privateKeys.ForEach( key => _ = Enumerable diff --git a/Libplanet.Tests/TestUtils.cs b/Libplanet.Tests/TestUtils.cs index e7f3e458197..5455f3cefdd 100644 --- a/Libplanet.Tests/TestUtils.cs +++ b/Libplanet.Tests/TestUtils.cs @@ -535,6 +535,8 @@ public static Block ProposeNextBlock( /// A of the chain. /// An instance to store blocks and txs. /// An instance to store states. + /// An instance to load actions. + /// /// s to be included in genesis block. /// Works only if is null. /// to be included in genesis block. @@ -550,10 +552,11 @@ public static Block ProposeNextBlock( /// Block protocol version of genesis block. /// An type. /// A instance. - public static BlockChain MakeBlockChain( + public static BlockChain MakeBlockChain( IBlockPolicy policy, IStore store, IStateStore stateStore, + IActionLoader actionLoader, IEnumerable actions = null, ValidatorSet validatorSet = null, PrivateKey privateKey = null, @@ -562,12 +565,12 @@ public static BlockChain MakeBlockChain( Block genesisBlock = null, int protocolVersion = Block.CurrentProtocolVersion ) - where T : IAction, new() { - return MakeBlockChainAndActionEvaluator( + return MakeBlockChainAndActionEvaluator( policy, store, stateStore, + actionLoader, actions, validatorSet, privateKey, @@ -579,10 +582,11 @@ public static BlockChain MakeBlockChain( } public static (BlockChain BlockChain, ActionEvaluator ActionEvaluator) - MakeBlockChainAndActionEvaluator( + MakeBlockChainAndActionEvaluator( IBlockPolicy policy, IStore store, IStateStore stateStore, + IActionLoader actionLoader, IEnumerable actions = null, ValidatorSet validatorSet = null, PrivateKey privateKey = null, @@ -591,7 +595,6 @@ public static (BlockChain BlockChain, ActionEvaluator ActionEvaluator) Block genesisBlock = null, int protocolVersion = Block.CurrentProtocolVersion ) - where T : IAction, new() { actions = actions ?? ImmutableArray.Empty; privateKey = privateKey ?? ChainPrivateKey; @@ -610,7 +613,7 @@ public static (BlockChain BlockChain, ActionEvaluator ActionEvaluator) var actionEvaluator = new ActionEvaluator( _ => policy.BlockAction, stateStore: stateStore, - actionTypeLoader: new SingleActionLoader(typeof(T))); + actionTypeLoader: actionLoader); if (genesisBlock is null) {