Beispiel #1
0
        public void FindHeaderAndVerifyBlockIntegrityCalledForBogusBlock_ExceptionShouldBeThrown()
        {
            // Chain header tree setup. Initial chain has 4 headers.
            // Example: h1=h2=h3=h4.
            const int         initialChainSize   = 4;
            const int         extensionChainSize = 2;
            TestContext       ctx             = new TestContextBuilder().WithInitialChain(initialChainSize).UseCheckpoints().Build();
            ChainedHeaderTree cht             = ctx.ChainedHeaderTree;
            ChainedHeader     initialChainTip = ctx.InitialChainTip;

            // Extend chain with 2 more headers.
            // Example: h1=h2=h3=h4=h5=h6.
            initialChainTip = ctx.ExtendAChain(extensionChainSize, initialChainTip);

            // Call FindHeaderAndVerifyBlockIntegrity on the block from header 6.
            // BlockDownloadedForMissingChainedHeaderException should be thrown.
            Action verificationAction = () => cht.FindHeaderAndVerifyBlockIntegrity(initialChainTip.Block);

            verificationAction.Should().Throw <BlockDownloadedForMissingChainedHeaderException>();
        }