public async Task FinalizedHeightCantBeDecreasedAsync()
        {
            string dir = CreateTestDir(this);

            using (var repo = new FinalizedBlockInfoRepository(dir, this.loggerFactory))
            {
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 777);
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 555);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }

            using (var repo = new FinalizedBlockInfoRepository(dir, this.loggerFactory))
            {
                await repo.LoadFinalizedBlockInfoAsync(this.Network);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }
        }
        public async Task FinalizedHeightCantBeDecreasedAsync()
        {
            string dir       = CreateTestDir(this);
            var    kvRepo    = new LevelDbKeyValueRepository(dir, new DataStoreSerializer(this.Network.Consensus.ConsensusFactory));
            var    asyncMock = new Mock <IAsyncProvider>();

            asyncMock.Setup(a => a.RegisterTask(It.IsAny <string>(), It.IsAny <Task>()));

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, this.loggerFactory, asyncMock.Object))
            {
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 777);
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 555);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, this.loggerFactory, asyncMock.Object))
            {
                await repo.LoadFinalizedBlockInfoAsync(this.Network);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }
        }
        public async Task FinalizedHeightSavedOnDiskAsync()
        {
            string dir    = CreateTestDir(this);
            var    kvRepo = new KeyValueRepository(dir, new DBreezeSerializer(this.Network));

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, this.loggerFactory))
            {
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 777);
            }

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, this.loggerFactory))
            {
                await repo.LoadFinalizedBlockInfoAsync(this.Network);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }
        }
        public async Task FinalizedHeightSavedOnDiskAsync()
        {
            string dir       = CreateTestDir(this);
            var    kvRepo    = new LevelDbKeyValueRepository(dir, new DBreezeSerializer(this.Network.Consensus.ConsensusFactory));
            var    asyncMock = new Mock <IAsyncProvider>();

            asyncMock.Setup(a => a.RegisterTask(It.IsAny <string>(), It.IsAny <Task>()));

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, asyncMock.Object))
            {
                repo.Initialize(new ChainedHeader(this.Network.GetGenesis().Header, this.Network.GetGenesis().GetHash(), 0));
                repo.SaveFinalizedBlockHashAndHeight(uint256.One, 777);
            }

            using (var repo = new FinalizedBlockInfoRepository(kvRepo, asyncMock.Object))
            {
                await repo.LoadFinalizedBlockInfoAsync(this.Network);

                Assert.Equal(777, repo.GetFinalizedBlockInfo().Height);
            }
        }