Beispiel #1
0
 public FullBlockchainExecutingServiceValidateAfterFailedTests()
 {
     _fullBlockchainExecutingService = GetRequiredService <FullBlockchainExecutingService>();
     _blockchainService = GetRequiredService <IBlockchainService>();
     _chainManager      = GetRequiredService <IChainManager>();
     _kernelTestHelper  = GetRequiredService <KernelTestHelper>();
 }
Beispiel #2
0
 public FullBlockchainServiceTests()
 {
     _fullBlockchainService = GetRequiredService <FullBlockchainService>();
     _transactionManager    = GetRequiredService <ITransactionManager>();
     _chainManager          = GetRequiredService <IChainManager>();
     _kernelTestHelper      = GetRequiredService <KernelTestHelper>();
 }
Beispiel #3
0
        public void Setup(BenchmarkContext context)
        {
            _blockchainService          = GetRequiredService <IBlockchainService>();
            _blockchainExecutingService = GetRequiredService <IBlockchainExecutingService>();
            _chainManager = GetRequiredService <IChainManager>();
            _osTestHelper = GetRequiredService <OSTestHelper>();

            _counter = context.GetCounter("TestCounter");

            AsyncHelper.RunSync(async() =>
            {
                var chain = await _blockchainService.GetChainAsync();

                var transactions = await _osTestHelper.GenerateTransferTransactions(1000);

                _block = _osTestHelper.GenerateBlock(chain.BestChainHash, chain.BestChainHeight, transactions);

                await _blockchainService.AddTransactionsAsync(transactions);
                await _blockchainService.AddBlockAsync(_block);

                chain = await _blockchainService.GetChainAsync();

                await _blockchainService.AttachBlockToChainAsync(chain, _block);
            });
        }
        public async Task GlobalSetup()
        {
            _chains = GetRequiredService <IBlockchainStore <Chain> >();
            _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >();
            _blockchainStateService   = GetRequiredService <IBlockchainStateService>();
            _blockStateSetManger      = GetRequiredService <IBlockStateSetManger>();
            _blockchainService        = GetRequiredService <IBlockchainService>();
            _osTestHelper             = GetRequiredService <OSTestHelper>();
            _chainManager             = GetRequiredService <IChainManager>();
            _blockManager             = GetRequiredService <IBlockManager>();
            _transactionManager       = GetRequiredService <ITransactionManager>();
            _transactionPoolService   = GetRequiredService <ITransactionPoolService>();


            _blockStateSets = new List <BlockStateSet>();
            _blocks         = new List <Block>();

            _chain = await _blockchainService.GetChainAsync();

            var blockHash = _chain.BestChainHash;

            while (true)
            {
                var blockState = await _blockStateSetManger.GetBlockStateSetAsync(blockHash);

                _blockStateSets.Add(blockState);

                var blockHeader = await _blockchainService.GetBlockHeaderByHashAsync(blockHash);

                blockHash = blockHeader.PreviousBlockHash;
                if (blockHash == _chain.LastIrreversibleBlockHash)
                {
                    break;
                }
            }

            await _blockchainStateService.MergeBlockStateAsync(_chain.BestChainHeight, _chain.BestChainHash);

            for (var i = 0; i < BlockCount; i++)
            {
                var transactions = await _osTestHelper.GenerateTransferTransactions(TransactionCount);

                await _osTestHelper.BroadcastTransactions(transactions);

                var block = await _osTestHelper.MinedOneBlock();

                _blocks.Add(block);

                var blockState = await _blockStateSetManger.GetBlockStateSetAsync(block.GetHash());

                _blockStateSets.Add(blockState);
            }

            var chain = await _blockchainService.GetChainAsync();

            await _chainManager.SetIrreversibleBlockAsync(chain, chain.BestChainHash);

            _chainStateInfo = await _chainStateInfoCollection.GetAsync(chain.Id.ToStorageKey());
        }
 public BlockExecutionResultProcessingServiceTests()
 {
     _blockExecutionResultProcessingService = GetRequiredService <IBlockExecutionResultProcessingService>();
     _blockchainService     = GetRequiredService <IBlockchainService>();
     _kernelTestHelper      = GetRequiredService <KernelTestHelper>();
     _chainManager          = GetRequiredService <IChainManager>();
     _chainBlockLinkService = GetRequiredService <IChainBlockLinkService>();
 }
Beispiel #6
0
 public FullBlockchainService(IChainManager chainManager, IBlockManager blockManager,
                              ITransactionManager transactionManager)
 {
     Logger              = NullLogger <FullBlockchainService> .Instance;
     _chainManager       = chainManager;
     _blockManager       = blockManager;
     _transactionManager = transactionManager;
     LocalEventBus       = NullLocalEventBus.Instance;
 }
Beispiel #7
0
        public FullBlockchainExecutingService(IChainManager chainManager,
                                              IBlockchainService blockchainService, IBlockValidationService blockValidationService,
                                              IBlockExecutingService blockExecutingService, IBlockchainStateManager blockchainStateManager)
        {
            _chainManager           = chainManager;
            _blockchainService      = blockchainService;
            _blockValidationService = blockValidationService;
            _blockExecutingService  = blockExecutingService;
            _blockchainStateManager = blockchainStateManager;

            LocalEventBus = NullLocalEventBus.Instance;
        }
Beispiel #8
0
        public async Task GlobalSetup()
        {
            _chains                 = GetRequiredService <IBlockchainStore <Chain> >();
            _chainBlockLinks        = GetRequiredService <IBlockchainStore <ChainBlockLink> >();
            _chainManager           = GetRequiredService <IChainManager>();
            _blockManager           = GetRequiredService <IBlockManager>();
            _transactionManager     = GetRequiredService <ITransactionManager>();
            _transactionPoolService = GetRequiredService <ITransactionPoolService>();
            _blockchainService      = GetRequiredService <IBlockchainService>();
            _osTestHelper           = GetRequiredService <OSTestHelper>();

            _chain = await _blockchainService.GetChainAsync();
        }
Beispiel #9
0
        public KernelTestHelper(IBlockchainService blockchainService,
                                ITransactionResultService transactionResultService,
                                IChainManager chainManager)
        {
            BestBranchBlockList     = new List <Block>();
            LongestBranchBlockList  = new List <Block>();
            ForkBranchBlockList     = new List <Block>();
            UnlinkedBranchBlockList = new List <Block>();

            _blockchainService        = blockchainService;
            _transactionResultService = transactionResultService;
            _chainManager             = chainManager;
        }
Beispiel #10
0
        public async Task GlobalSetup()
        {
            _chains             = GetRequiredService <IBlockchainStore <Chain> >();
            _blockStateSets     = GetRequiredService <INotModifiedCachedStateStore <BlockStateSet> >();
            _chainManager       = GetRequiredService <IChainManager>();
            _blockManager       = GetRequiredService <IBlockManager>();
            _blockchainService  = GetRequiredService <IBlockchainService>();
            _blockAttachService = GetRequiredService <IBlockAttachService>();
            _transactionManager = GetRequiredService <ITransactionManager>();
            _osTestHelper       = GetRequiredService <OSTestHelper>();

            _chain = await _blockchainService.GetChainAsync();
        }
        public FullBlockchainExecutingService(IChainManager chainManager,
                                              IBlockchainService blockchainService, IBlockValidationService blockValidationService,
                                              IBlockExecutingService blockExecutingService,
                                              ITransactionResultService transactionResultService, IBlockStateSetManger blockStateSetManger)
        {
            _chainManager             = chainManager;
            _blockchainService        = blockchainService;
            _blockValidationService   = blockValidationService;
            _blockExecutingService    = blockExecutingService;
            _transactionResultService = transactionResultService;
            _blockStateSetManger      = blockStateSetManger;

            LocalEventBus = NullLocalEventBus.Instance;
        }
        public void Setup(BenchmarkContext context)
        {
            _blockchainStateService = GetRequiredService <IBlockchainStateService>();
            _blockchainService      = GetRequiredService <IBlockchainService>();
            _osTestHelper           = GetRequiredService <OSTestHelper>();
            _chainManager           = GetRequiredService <IChainManager>();

            _counter = context.GetCounter("TestCounter");

            AsyncHelper.RunSync(async() =>
            {
                var transactions = await _osTestHelper.GenerateTransferTransactions(1000);
                await _osTestHelper.BroadcastTransactions(transactions);
                await _osTestHelper.MinedOneBlock();

                var chain = await _blockchainService.GetChainAsync();
                await _chainManager.SetIrreversibleBlockAsync(chain, chain.BestChainHash);
            });
        }
Beispiel #13
0
 public ChainBlockLinkService(IChainManager chainManager)
 {
     _chainManager = chainManager;
 }