diff --git a/Libplanet.Action.Tests/ActionContextTest.cs b/Libplanet.Action.Tests/ActionContextTest.cs index 58344f4fe63..555fcd3e0da 100644 --- a/Libplanet.Action.Tests/ActionContextTest.cs +++ b/Libplanet.Action.Tests/ActionContextTest.cs @@ -36,7 +36,7 @@ public void RandomShouldBeDeterministic() miner: _address, blockIndex: 1, blockProtocolVersion: Block.CurrentProtocolVersion, - previousState: World.Create(new MockWorldState()), + previousState: new World(new MockWorldState()), randomSeed: seed, gasLimit: 0 ); @@ -54,7 +54,7 @@ public void GuidShouldBeDeterministic() miner: _address, blockIndex: 1, blockProtocolVersion: Block.CurrentProtocolVersion, - previousState: World.Create(new MockWorldState()), + previousState: new World(new MockWorldState()), randomSeed: 0, gasLimit: 0 ); @@ -65,7 +65,7 @@ public void GuidShouldBeDeterministic() miner: _address, blockIndex: 1, blockProtocolVersion: Block.CurrentProtocolVersion, - previousState: World.Create(new MockWorldState()), + previousState: new World(new MockWorldState()), randomSeed: 0, gasLimit: 0 ); @@ -76,7 +76,7 @@ public void GuidShouldBeDeterministic() miner: _address, blockIndex: 1, blockProtocolVersion: Block.CurrentProtocolVersion, - previousState: World.Create(new MockWorldState()), + previousState: new World(new MockWorldState()), randomSeed: 1, gasLimit: 0 ); @@ -115,7 +115,7 @@ public void GuidVersionAndVariant() miner: _address, blockIndex: 1, blockProtocolVersion: Block.CurrentProtocolVersion, - previousState: World.Create(new MockWorldState()), + previousState: new World(new MockWorldState()), randomSeed: i, gasLimit: 0 ); diff --git a/Libplanet.Action.Tests/ActionEvaluationTest.cs b/Libplanet.Action.Tests/ActionEvaluationTest.cs index 663b2740a5f..fe799e5030d 100644 --- a/Libplanet.Action.Tests/ActionEvaluationTest.cs +++ b/Libplanet.Action.Tests/ActionEvaluationTest.cs @@ -37,11 +37,11 @@ public void Constructor() address, 1, Block.CurrentProtocolVersion, - World.Create(new MockWorldState()), + new World(new MockWorldState()), 123, 0, false), - World.Create( + new World( new MockWorldState().SetAccount( ReservedAddresses.LegacyAccount, new Account(MockAccountState.Empty.SetState(address, (Text)"item")))) diff --git a/Libplanet.Action.Tests/Sys/InitializeTest.cs b/Libplanet.Action.Tests/Sys/InitializeTest.cs index 4bba35ae0ed..bc9f302e936 100644 --- a/Libplanet.Action.Tests/Sys/InitializeTest.cs +++ b/Libplanet.Action.Tests/Sys/InitializeTest.cs @@ -47,7 +47,7 @@ public void Execute() { var random = new System.Random(); Address signer = random.NextAddress(); - var prevState = World.Create(new MockWorldState()); + var prevState = new World(new MockWorldState()); BlockHash genesisHash = random.NextBlockHash(); var context = new ActionContext( signer: signer, @@ -79,7 +79,7 @@ public void ExecuteInNonGenesis() { var random = new System.Random(); Address signer = random.NextAddress(); - var prevState = World.Create(new MockWorldState()); + var prevState = new World(new MockWorldState()); BlockHash genesisHash = random.NextBlockHash(); var context = new ActionContext( signer: signer, diff --git a/Libplanet.Action/State/World.cs b/Libplanet.Action/State/World.cs index 7d0d93faff1..220a6938887 100644 --- a/Libplanet.Action/State/World.cs +++ b/Libplanet.Action/State/World.cs @@ -23,7 +23,7 @@ public World(IWorldState baseState, IWorldDelta delta) { _baseState = baseState; Delta = delta; - Legacy = true; + Legacy = baseState.Legacy; } /// @@ -38,16 +38,6 @@ public World(IWorldState baseState, IWorldDelta delta) [Pure] public bool Legacy { get; private set; } - /// - /// Creates a new World from given . - /// - /// The previous to initialize - /// new World. - /// A null world using as its base state. - /// - public static IWorld Create(IWorldState previousWorld) => - new World(previousWorld) { Legacy = previousWorld.Legacy }; - /// /// Creates a null worlds from given . /// diff --git a/Libplanet.Tests/Action/AccountV0Test.cs b/Libplanet.Tests/Action/AccountV0Test.cs index 02425711b55..b2de5edc7fc 100644 --- a/Libplanet.Tests/Action/AccountV0Test.cs +++ b/Libplanet.Tests/Action/AccountV0Test.cs @@ -26,7 +26,7 @@ public AccountV0Test(ITestOutputHelper output) public override IActionContext CreateContext( IAccount delta, Address signer) { - IWorld world = World.Create(new MockWorldState()); + IWorld world = new World(new MockWorldState()); world = world.SetAccount(_accountAddress, delta); return new ActionContext( signer, diff --git a/Libplanet.Tests/Action/AccountV1Test.cs b/Libplanet.Tests/Action/AccountV1Test.cs index af2e6ac6b78..25c31e782d1 100644 --- a/Libplanet.Tests/Action/AccountV1Test.cs +++ b/Libplanet.Tests/Action/AccountV1Test.cs @@ -28,7 +28,7 @@ public AccountV1Test(ITestOutputHelper output) public override IActionContext CreateContext(IAccount delta, Address signer) { - IWorld world = World.Create(new MockWorldState()); + IWorld world = new World(new MockWorldState()); world = world.SetAccount(_accountAddress, delta); return new ActionContext( signer, diff --git a/Libplanet.Tests/Blockchain/Renderers/AnonymousActionRendererTest.cs b/Libplanet.Tests/Blockchain/Renderers/AnonymousActionRendererTest.cs index 06dd9aa4770..12a7b9883c8 100644 --- a/Libplanet.Tests/Blockchain/Renderers/AnonymousActionRendererTest.cs +++ b/Libplanet.Tests/Blockchain/Renderers/AnonymousActionRendererTest.cs @@ -16,7 +16,7 @@ public class AnonymousActionRendererTest { private static IValue _action = new DumbAction().PlainValue; - private static IWorld _world = World.Create(new MockWorldState()); + private static IWorld _world = new World(new MockWorldState()); private static ICommittedActionContext _actionContext = new CommittedActionContext(new ActionContext( diff --git a/Libplanet.Tests/Blockchain/Renderers/LoggedActionRendererTest.cs b/Libplanet.Tests/Blockchain/Renderers/LoggedActionRendererTest.cs index 1af3c2c745a..c2893af9b56 100644 --- a/Libplanet.Tests/Blockchain/Renderers/LoggedActionRendererTest.cs +++ b/Libplanet.Tests/Blockchain/Renderers/LoggedActionRendererTest.cs @@ -23,7 +23,7 @@ public class LoggedActionRendererTest : IDisposable { private static IValue _action = new DumbAction().PlainValue; - private static IWorld _world = World.Create(new MockWorldState()); + private static IWorld _world = new World(new MockWorldState()); private static Block _genesis = TestUtils.ProposeGenesisBlock(TestUtils.GenesisProposer); diff --git a/Libplanet.Tests/Fixtures/IntegerSet.cs b/Libplanet.Tests/Fixtures/IntegerSet.cs index 03e3a2e8b10..99966d63b4b 100644 --- a/Libplanet.Tests/Fixtures/IntegerSet.cs +++ b/Libplanet.Tests/Fixtures/IntegerSet.cs @@ -180,7 +180,7 @@ public void Append(Block block) => Chain.Append(block, TestUtils.CreateBlockCommit(block)); public IWorld CreateWorld(BlockHash? offset = null) - => World.Create(Chain.GetWorldState(offset ?? Tip.Hash)); + => new World(Chain.GetWorldState(offset ?? Tip.Hash)); public ITrie GetTrie(BlockHash? blockHash) {