예제 #1
0
        public void CanSaveChain()
        {
            var chain = new ChainIndexer(this.network);

            this.AppendBlock(chain);
            this.AppendBlock(chain);

            ChainedHeader fork = this.AppendBlock(chain);

            this.AppendBlock(chain);

            var chain2 = new ChainIndexer(this.network).Load(chain.ToBytes());

            Assert.True(chain.Tip.HashBlock == chain2.Tip.HashBlock);
        }
예제 #2
0
        public void CanLoadAndSaveConcurrentChain()
        {
            var cchain = new ChainIndexer(this.network);
            var chain  = new ChainIndexer(this.network);

            this.AddBlock(chain);
            this.AddBlock(chain);
            this.AddBlock(chain);

            cchain.SetTip(chain.Tip);

            byte[] bytes = cchain.ToBytes();
            cchain = new ChainIndexer(this.network);
            cchain.Load(bytes);

            Assert.Equal(cchain.Tip, chain.Tip);
            Assert.NotNull(cchain.GetHeader(0));

            cchain = new ChainIndexer(this.networkTest);
            cchain.Load(cchain.ToBytes());
            Assert.NotNull(cchain.GetHeader(0));
        }