public void PruneRepository_PruneAndCompact_OnShutDown()
        {
            var posBlocks        = CreatePosBlocks(50);
            var chainedHeaderTip = BuildProvenHeaderChainFromBlocks(posBlocks);

            var dataFolderPath = CreateTestDir(this);
            var dataFolder     = new DataFolder(dataFolderPath);

            var dBreezeSerializer = new DataStoreSerializer(this.Network.Consensus.ConsensusFactory);

            var blockRepository = new BlockRepository(this.Network, dataFolder, this.LoggerFactory.Object, dBreezeSerializer);

            blockRepository.PutBlocks(new HashHeightPair(posBlocks.Last().GetHash(), 50), posBlocks);

            var storeSettings = new StoreSettings(NodeSettings.Default(this.Network))
            {
                AmountOfBlocksToKeep = 10
            };

            var prunedBlockRepository = new PrunedBlockRepository(blockRepository, dBreezeSerializer, this.LoggerFactory.Object, storeSettings);

            prunedBlockRepository.Initialize();

            // Delete blocks 30 to 0 from the repo, this would have been done by the service before shutdown was initiated.
            blockRepository.DeleteBlocks(posBlocks.Take(30).Select(b => b.GetHash()).ToList());
            prunedBlockRepository.UpdatePrunedTip(chainedHeaderTip.GetAncestor(30));
            // Ensure that the block has been deleted from disk.
            Assert.Null(blockRepository.GetBlock(chainedHeaderTip.GetAncestor(29).HashBlock));

            // On shutdown the database will only be compacted.
            prunedBlockRepository.PruneAndCompactDatabase(chainedHeaderTip.GetAncestor(50), this.Network, false);
            Assert.Equal(chainedHeaderTip.GetAncestor(30).HashBlock, prunedBlockRepository.PrunedTip.Hash);
            Assert.Equal(chainedHeaderTip.GetAncestor(30).Height, prunedBlockRepository.PrunedTip.Height);
            Assert.Null(blockRepository.GetBlock(chainedHeaderTip.GetAncestor(29).HashBlock));
        }