Skip to content
Permalink
Browse files

Remove FileStore

  • Loading branch information...
longfin committed Aug 19, 2019
1 parent 7375170 commit 50361074e4ac6067ca5b305224f88c5cf26075f0
@@ -32,6 +32,7 @@ To be released.
- Added `IActionContext.NewGuId()` method. [[#371], [#439]]
- `Address(byte[])` became to throw `ArgumentNullException`
instead of `NullReferenceException`. [[#443]]
- Removed `FileStore` class. [[#446]]

### Added interfaces

@@ -157,6 +158,7 @@ To be released.
[#442]: https://github.com/planetarium/libplanet/issues/442
[#443]: https://github.com/planetarium/libplanet/pull/443
[#445]: https://github.com/planetarium/libplanet/pull/445
[#446]: https://github.com/planetarium/libplanet/pull/446
[LiteDB #1268]: https://github.com/mbdavid/LiteDB/issues/1268
[floating-point determinism]: https://wp.me/p1fTCO-kT

@@ -10,12 +10,12 @@ namespace Libplanet.Benchmarks
{
public class MineBlock
{
private FileStoreFixture _fx;
private StoreFixture _fx;
private BlockChain<DumbAction> _blockChain;

public MineBlock()
{
_fx = new FileStoreFixture();
_fx = new LiteDBStoreFixture();
_blockChain = new BlockChain<DumbAction>(
new NullPolicy<DumbAction>(),
_fx.Store
@@ -18,12 +18,12 @@ namespace Libplanet.Tests.Blockchain
{
public class BlockChainTest : IDisposable
{
private FileStoreFixture _fx;
private StoreFixture _fx;
private BlockChain<DumbAction> _blockChain;

public BlockChainTest()
{
_fx = new FileStoreFixture();
_fx = new LiteDBStoreFixture();
_blockChain = new BlockChain<DumbAction>(
new BlockPolicy<DumbAction>(new MinerReward(1)),
_fx.Store
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using Libplanet.Blockchain;
using Libplanet.Blockchain.Policies;
using Libplanet.Blocks;
using Libplanet.Tests.Common.Action;
@@ -13,7 +12,7 @@

namespace Libplanet.Tests.Blockchain.Policies
{
public class BlockPolicyTest : IClassFixture<FileStoreFixture>
public class BlockPolicyTest : IClassFixture<LiteDBStoreFixture>
{
private static readonly DateTimeOffset FixtureEpoch =
new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero);
@@ -31,10 +31,9 @@ public class SwarmTest : IDisposable
private const int DisposeTimeout = 5 * 1000;

private readonly ITestOutputHelper _output;

private readonly FileStoreFixture _fx1;
private readonly FileStoreFixture _fx2;
private readonly FileStoreFixture _fx3;
private readonly StoreFixture _fx1;
private readonly StoreFixture _fx2;
private readonly StoreFixture _fx3;

private readonly List<BlockChain<DumbAction>> _blockchains;
private readonly List<Swarm<DumbAction>> _swarms;
@@ -53,9 +52,9 @@ public SwarmTest(ITestOutputHelper output)
_output = output;

var policy = new BlockPolicy<DumbAction>(new MinerReward(1));
_fx1 = new FileStoreFixture();
_fx2 = new FileStoreFixture();
_fx3 = new FileStoreFixture();
_fx1 = new LiteDBStoreFixture();
_fx2 = new LiteDBStoreFixture();
_fx3 = new LiteDBStoreFixture();

_blockchains = new List<BlockChain<DumbAction>>
{
@@ -341,7 +340,7 @@ public async Task DetectAppProtocolVersion()
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 2);
var d = new Swarm<DumbAction>(
new BlockChain<DumbAction>(_blockchains[0].Policy, new FileStoreFixture().Store),
new BlockChain<DumbAction>(_blockchains[0].Policy, new LiteDBStoreFixture().Store),
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 3);
@@ -10,12 +10,12 @@ namespace Libplanet.Tests.Store
{
public class BlockSetTest : IDisposable
{
private readonly FileStoreFixture _fx;
private readonly StoreFixture _fx;
private readonly BlockSet<DumbAction> _set;

public BlockSetTest()
{
_fx = new FileStoreFixture();
_fx = new LiteDBStoreFixture();
_set = new BlockSet<DumbAction>(_fx.Store);
}

This file was deleted.

This file was deleted.

@@ -16,7 +16,7 @@ public LiteDBStoreFixture()

public string Path { get; }

public void Dispose()
public override void Dispose()
{
(Store as LiteDBStore)?.Dispose();
File.Delete(Path);
@@ -20,7 +20,6 @@ public static IEnumerable<object[]> StoreFixtures
{
get
{
yield return new object[] { new FileStoreFixture() };
yield return new object[] { new LiteDBStoreFixture() };
}
}
@@ -10,7 +10,7 @@

namespace Libplanet.Tests.Store
{
public abstract class StoreFixture
public abstract class StoreFixture : IDisposable
{
public StoreFixture()
{
@@ -107,6 +107,8 @@ public StoreFixture()

public IStore Store { get; set; }

public abstract void Dispose();

public Transaction<DumbAction> MakeTransaction(
IEnumerable<DumbAction> actions = null,
ImmutableHashSet<Address> updatedAddresses = null,
@@ -5,12 +5,12 @@ namespace Libplanet.Tests.Store
{
public sealed class StoreTrackerTest
{
private readonly FileStoreFixture _fx;
private readonly StoreFixture _fx;
private readonly StoreTracker _tracker;

public StoreTrackerTest()
{
_fx = new FileStoreFixture();
_fx = new LiteDBStoreFixture();
_tracker = new StoreTracker(_fx.Store);
}

@@ -9,12 +9,12 @@ namespace Libplanet.Tests.Store
{
public class TransactionSetTest : IDisposable
{
private readonly FileStoreFixture _fx;
private readonly StoreFixture _fx;
private readonly TransactionSet<DumbAction> _set;

public TransactionSetTest()
{
_fx = new FileStoreFixture();
_fx = new LiteDBStoreFixture();
_set = new TransactionSet<DumbAction>(_fx.Store);
}

0 comments on commit 5036107

Please sign in to comment.
You can’t perform that action at this time.