Пример #1
0
        public void RunFullBlockTest()
        {
            var generator = new FullBlockTestGenerator(Network.Main);

            ValidationState validation = new ValidationState(Network.Main);

            validation.CheckMerkleRoot  = false;
            validation.CheckProofOfWork = false;

            var scan =
                new ScanState(new PubKeyHashScanner(generator.CoinbaseKey.PubKey.ID),
                              new Chain(),
                              new Account(),
                              0);

            scan.CheckDoubleSpend = true;

            var mainChain = new Chain(Network.Main);
            var indexed   = new IndexedBlockStore(new InMemoryNoSqlRepository(), CreateBlockStore());

            indexed.Put(Network.Main.GetGenesis());
            foreach (var test in generator.GetBlocksToTest(true, true).list.OfType <BlockAndValidity>())
            {
                indexed.Put(test.block);
                mainChain.TrySetTip(test.block.Header);
                Assert.True(scan.Process(mainChain, indexed) == test.connects);
                //if(!)
                //{
                //	Assert.True(test.throwsException);
                //}
                Assert.Equal(test.heightAfterBlock, scan.Chain.Height);
                Assert.Equal(test.hashChainTipAfterBlock, scan.Chain.Tip.HashBlock);
                mainChain.SetTip(scan.Chain.Tip);
            }
        }
Пример #2
0
        public void RunFullBlockTest()
        {
            var generator = new FullBlockTestGenerator(Network.Main);

            ValidationState validation = new ValidationState(Network.Main);
            validation.CheckMerkleRoot = false;
            validation.CheckProofOfWork = false;

            var scan =
                new ScanState(new PubKeyHashScanner(generator.CoinbaseKey.PubKey.ID),
                        new Chain(),
                        new Account(),
                        0);
            scan.CheckDoubleSpend = true;

            var mainChain = new Chain(Network.Main);
            var indexed = new IndexedBlockStore(new InMemoryNoSqlRepository(), CreateBlockStore());
            indexed.Put(Network.Main.GetGenesis());
            foreach(var test in generator.GetBlocksToTest(true, true).list.OfType<BlockAndValidity>())
            {
                indexed.Put(test.block);
                mainChain.GetOrAdd(test.block.Header);
                Assert.True(scan.Process(mainChain, indexed) == test.connects);
                //if(!)
                //{
                //	Assert.True(test.throwsException);
                //}
                Assert.Equal(test.heightAfterBlock, scan.Chain.Height);
                Assert.Equal(test.hashChainTipAfterBlock, scan.Chain.Tip.HashBlock);
                mainChain.SetTip(scan.Chain.Tip);
            }
        }