1
using System.Security.Cryptography;
2
using Xunit;
3

4
namespace Libplanet.Tests.Store
5
{
6
    public sealed class StateStoreTrackerTest
7
    {
8
        private readonly StoreFixture _fx;
9
        private readonly StateStoreTracker _tracker;
10

11 1
        public StateStoreTrackerTest()
12 1
        {
13 1
            _fx = new DefaultStoreFixture();
14 1
            _tracker = new StateStoreTracker(_fx.StateStore);
15 1
        }
16

17
        [Fact]
18
        public void LogsAreEmptyAtFirst()
19 1
        {
20 1
            Assert.Empty(_tracker.Logs);
21 1
        }
22

23
        [Fact]
24
        public void MethodCallsAreLogged()
25 1
        {
26 1
            _tracker.GetState("stateKey", chainId: _fx.StoreChainId);
27 1
            Assert.Equal(1, _tracker.Logs.Count);
28 1
            Assert.Equal(
29 1
                StoreTrackLog.Create(nameof(_tracker.GetState), "stateKey", null, _fx.StoreChainId),
30 1
                _tracker.Logs[0]);
31

32 1
            var hashDigest =
33 1
                new HashDigest<SHA256>(TestUtils.GetRandomBytes(HashDigest<SHA256>.Size));
34 1
            _tracker.ContainsBlockStates(hashDigest);
35 1
            Assert.Equal(2, _tracker.Logs.Count);
36 1
            Assert.Equal(
37 1
                StoreTrackLog.Create(nameof(_tracker.ContainsBlockStates), hashDigest),
38 1
                _tracker.Logs[1]);
39 1
        }
40

41
        [Fact]
42
        public void ClearLogs()
43 1
        {
44 1
            _tracker.GetState("stateKey", chainId: _fx.StoreChainId);
45 1
            var hashDigest =
46 1
                new HashDigest<SHA256>(TestUtils.GetRandomBytes(HashDigest<SHA256>.Size));
47 1
            _tracker.ContainsBlockStates(hashDigest);
48 1
            Assert.Equal(2, _tracker.Logs.Count);
49

50 1
            _tracker.ClearLogs();
51 1
            Assert.Empty(_tracker.Logs);
52 1
        }
53
    }
54
}

Read our documentation on viewing source code .

Loading