public TransactionToHubTests(ITestOutputHelper outputHelper) : base(outputHelper)
 {
     _blockchainService           = GetRequiredService <IBlockchainService>();
     _smartContractAddressService = GetRequiredService <ISmartContractAddressService>();
     _osTestHelper = GetRequiredService <OSTestHelper>();
 }
Exemple #2
0
        public async Task GlobalSetup()
        {
            _chains = GetRequiredService <IBlockchainStore <Chain> >();
            _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >();
            _blockchainStateManager   = GetRequiredService <IBlockchainStateManager>();
            _blockchainStateService   = GetRequiredService <IBlockchainStateService>();
            _blockStateSetManger      = GetRequiredService <IBlockStateSetManger>();
            _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 _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());
        }
Exemple #3
0
 public BlockSyncAttachServiceAbnormalPeerTests()
 {
     _blockSyncAttachService = GetRequiredService <IBlockSyncAttachService>();
     _osTestHelper           = GetRequiredService <OSTestHelper>();
     _networkService         = GetRequiredService <INetworkService>();
 }
        public async Task GlobalSetup()
        {
            _osTestHelper = GetRequiredService <OSTestHelper>();

            _transaction = await _osTestHelper.GenerateTransferTransaction();
        }
 public BlockSyncValidationServiceInvalidBlockTests()
 {
     _blockSyncValidationService = GetRequiredService <IBlockSyncValidationService>();
     _osTestHelper = GetRequiredService <OSTestHelper>();
 }