Ejemplo n.º 1
0
        public void CanSaveChain()
        {
            var             stream = new StreamObjectStream <ChainChange>();
            PersistantChain chain  = new PersistantChain(Network.Main, stream);

            AppendBlock(chain);
            AppendBlock(chain);
            var fork = AppendBlock(chain);

            AppendBlock(chain);


            stream.Rewind();

            var chain2 = new PersistantChain(stream);

            Assert.True(chain.SameTip(chain2));

            stream.WriteNext(new ChainChange()
            {
                ChangeType       = ChainChangeType.BackStep,
                HeightOrBackstep = 1
            });
            stream.Rewind();

            var chain3 = new PersistantChain(stream);

            AssertHeight(stream, 3);
            var actualFork = chain3.FindFork(chain);

            Assert.Equal(fork.HashBlock, actualFork.HashBlock);
        }
Ejemplo n.º 2
0
 public void AssertHeight(StreamObjectStream <ChainChange> changes, int height)
 {
     changes.Rewind();
     Assert.Equal(height, new PersistantChain(changes).Height);
 }
Ejemplo n.º 3
0
 private void AssertLength(StreamObjectStream <ChainChange> changes, int count)
 {
     changes.Rewind();
     Assert.Equal(count, changes.Enumerate().Count());
 }
Ejemplo n.º 4
0
 private void AssertLength(StreamObjectStream<ChainChange> changes, int count)
 {
     changes.Rewind();
     Assert.Equal(count, changes.Enumerate().Count());
 }
Ejemplo n.º 5
0
        public void CanSaveChain()
        {
            var stream = new StreamObjectStream<ChainChange>();
            Chain chain = new Chain(Network.Main, stream);
            AppendBlock(chain);
            AppendBlock(chain);
            var fork = AppendBlock(chain);
            AppendBlock(chain);

            stream.Rewind();

            var chain2 = new Chain(stream);
            Assert.True(chain.SameTip(chain2));

            stream.WriteNext(new ChainChange()
            {
                Add = false,
                HeightOrBackstep = 1
            });
            stream.Rewind();

            var chain3 = new Chain(stream);
            AssertHeight(stream, 3);
            var actualFork = chain3.FindFork(chain);
            Assert.Equal(fork.HashBlock, actualFork.HashBlock);
        }
Ejemplo n.º 6
0
 public void AssertHeight(StreamObjectStream<ChainChange> changes, int height)
 {
     changes.Rewind();
     Assert.Equal(height, new Chain(changes).Height);
 }