public NewIrreversibleBlockFoundEventHandler(ITaskQueueManager taskQueueManager, IBlockchainStateMergingService blockchainStateMergingService) { _taskQueueManager = taskQueueManager; _blockchainStateMergingService = blockchainStateMergingService; Logger = NullLogger <NewIrreversibleBlockFoundEventHandler> .Instance; }
public async Task GlobalSetup() { _chains = GetRequiredService <IBlockchainStore <Chain> >(); _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >(); _blockchainStateManager = GetRequiredService <IBlockchainStateManager>(); _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>(); _blockchainService = GetRequiredService <IBlockchainService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _chainManager = GetRequiredService <IChainManager>(); _blockManager = GetRequiredService <IBlockManager>(); _transactionManager = GetRequiredService <ITransactionManager>(); _transactionResultManager = GetRequiredService <ITransactionResultManager>(); _txHub = GetRequiredService <ITxHub>(); _blockStateSets = new List <BlockStateSet>(); _blocks = new List <Block>(); _chain = await _blockchainService.GetChainAsync(); var blockHash = _chain.BestChainHash; while (true) { var blockState = await _blockchainStateManager.GetBlockStateSetAsync(blockHash); _blockStateSets.Add(blockState); var blockHeader = await _blockchainService.GetBlockHeaderByHashAsync(blockHash); blockHash = blockHeader.PreviousBlockHash; if (blockHash == _chain.LastIrreversibleBlockHash) { break; } } await _blockchainStateMergingService.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 _blockchainStateManager.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 BlockChainAppServiceTest(ITestOutputHelper outputHelper) : base(outputHelper) { _blockchainService = GetRequiredService <IBlockchainService>(); _smartContractAddressService = GetRequiredService <ISmartContractAddressService>(); _txHub = GetRequiredService <ITxHub>(); _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>(); _blockchainStateManager = GetRequiredService <IBlockchainStateManager>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _accountService = GetRequiredService <IAccountService>(); }
public void Setup(BenchmarkContext context) { _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>(); _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); }); }
public BlockchainStateMergingServiceTests() { _blockchainStateManager = GetRequiredService <IBlockchainStateManager>(); _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>(); }