public void SaveChainToDisk()
        {
            string dir   = CreateTestDir(this);
            var    chain = new ChainIndexer(this.Network);

            this.AppendBlock(chain);

            using (var repo = new ChainRepository(new RocksDbChainStore(chain.Network, new DataFolder(dir), chain)))
            {
                repo.SaveAsync(chain).GetAwaiter().GetResult();
            }

            using (var engine = RocksDb.Open(new DbOptions().SetCreateIfMissing(), new DataFolder(dir).ChainPath))
            {
                ChainedHeader tip = null;
                var           itr = engine.NewIterator();
                itr.SeekToFirst();
                while (itr.Valid())
                {
                    if (itr.Key()[0] == 1)
                    {
                        var data = new ChainRepository.ChainRepositoryData();
                        data.FromBytes(itr.Value().ToArray(), this.Network.Consensus.ConsensusFactory);

                        tip = new ChainedHeader(data.Hash, data.Work, tip);

                        if (tip.Height == 0)
                        {
                            tip.SetChainStore(new ChainStore());
                        }
                    }

                    itr.Next();
                }

                Assert.Equal(tip, chain.Tip);
            }
        }
        public void SaveChainToDisk()
        {
            string dir   = CreateTestDir(this);
            var    chain = new ChainIndexer(KnownNetworks.StraxRegTest);

            this.AppendBlock(chain);

            using (var repo = new ChainRepository(new LevelDbChainStore(chain.Network, new DataFolder(dir), chain)))
            {
                repo.SaveAsync(chain).GetAwaiter().GetResult();
            }

            using (var engine = new DB(new Options {
                CreateIfMissing = true
            }, new DataFolder(dir).ChainPath))
            {
                ChainedHeader tip = null;
                var           itr = engine.GetEnumerator();
                while (itr.MoveNext())
                {
                    if (itr.Current.Key[0] == 1)
                    {
                        var data = new ChainRepository.ChainRepositoryData();
                        data.FromBytes(itr.Current.Value.ToArray(), this.Network.Consensus.ConsensusFactory);

                        tip = new ChainedHeader(data.Hash, data.Work, tip);

                        if (tip.Height == 0)
                        {
                            tip.SetChainStore(new ChainStore());
                        }
                    }
                }

                Assert.Equal(tip, chain.Tip);
            }
        }