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); }
public void AssertHeight(StreamObjectStream <ChainChange> changes, int height) { changes.Rewind(); Assert.Equal(height, new PersistantChain(changes).Height); }
private void AssertLength(StreamObjectStream <ChainChange> changes, int count) { changes.Rewind(); Assert.Equal(count, changes.Enumerate().Count()); }
private void AssertLength(StreamObjectStream<ChainChange> changes, int count) { changes.Rewind(); Assert.Equal(count, changes.Enumerate().Count()); }
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); }
public void AssertHeight(StreamObjectStream<ChainChange> changes, int height) { changes.Rewind(); Assert.Equal(height, new Chain(changes).Height); }