Esempio n. 1
0
        public void TestSameBlock()
        {
            var walker = new BlockchainWalker();

            var path = walker.GetBlockchainPath(this.chainedHeaderA2, this.chainedHeaderA2, this.getChainedHeader);

            Assert.AreEqual(this.chainedHeaderA2, path.FromBlock);
            Assert.AreEqual(this.chainedHeaderA2, path.ToBlock);
            Assert.AreEqual(this.chainedHeaderA2, path.LastCommonBlock);

            Assert.AreEqual(0, path.RewindBlocks.Count);
            Assert.AreEqual(0, path.AdvanceBlocks.Count);
        }
Esempio n. 2
0
        public void TestAdvanceFromGenesis()
        {
            var walker = new BlockchainWalker();

            var path = walker.GetBlockchainPath(this.chainedHeader0, this.chainedHeaderA4, this.getChainedHeader);

            Assert.AreEqual(this.chainedHeader0, path.FromBlock);
            Assert.AreEqual(this.chainedHeaderA4, path.ToBlock);
            Assert.AreEqual(this.chainedHeader0, path.LastCommonBlock);

            Assert.AreEqual(0, path.RewindBlocks.Count);

            Assert.AreEqual(4, path.AdvanceBlocks.Count);
            Assert.AreEqual(this.chainedHeader1, path.AdvanceBlocks[0]);
            Assert.AreEqual(this.chainedHeaderA2, path.AdvanceBlocks[1]);
            Assert.AreEqual(this.chainedHeaderA3, path.AdvanceBlocks[2]);
            Assert.AreEqual(this.chainedHeaderA4, path.AdvanceBlocks[3]);
        }
Esempio n. 3
0
        public void TestChainMismatch()
        {
            var walker = new BlockchainWalker();

            walker.GetBlockchainPath(this.chainedHeaderA4, this.chainedHeaderX0, this.getChainedHeader);
        }
Esempio n. 4
0
        public void TestRewindAndAdvanceSameHeight()
        {
            var walker = new BlockchainWalker();

            var path = walker.GetBlockchainPath(this.chainedHeaderA4, this.chainedHeaderB4, this.getChainedHeader);

            Assert.AreEqual(this.chainedHeaderA4, path.FromBlock);
            Assert.AreEqual(this.chainedHeaderB4, path.ToBlock);
            Assert.AreEqual(this.chainedHeader1, path.LastCommonBlock);

            Assert.AreEqual(3, path.RewindBlocks.Count);
            Assert.AreEqual(this.chainedHeaderA4, path.RewindBlocks[0]);
            Assert.AreEqual(this.chainedHeaderA3, path.RewindBlocks[1]);
            Assert.AreEqual(this.chainedHeaderA2, path.RewindBlocks[2]);

            Assert.AreEqual(3, path.AdvanceBlocks.Count);
            Assert.AreEqual(this.chainedHeaderB2, path.AdvanceBlocks[0]);
            Assert.AreEqual(this.chainedHeaderB3, path.AdvanceBlocks[1]);
            Assert.AreEqual(this.chainedHeaderB4, path.AdvanceBlocks[2]);
        }