示例#1
0
        public async Task TransferTwoSymbolParallelTest()
        {
            var symbol  = "TELF";
            var keyPair = CryptoHelper.GenerateKeyPair();
            var address = Address.FromPublicKey(keyPair.PublicKey);
            await _parallelTestHelper.CreateAndIssueTokenAsync(symbol, address);

            var transactionList = new List <Transaction>();
            var accountAddress  = await _accountService.GetAccountAsync();

            var transferTransaction = await _parallelTestHelper.GenerateTransferTransaction(address, _parallelTestHelper.PrimaryTokenSymbol,
                                                                                            100_00000000);

            transactionList.Add(transferTransaction);
            await _parallelTestHelper.BroadcastTransactions(transactionList);

            var block = await _parallelTestHelper.MinedOneBlock();

            var codeRemark =
                await _contractRemarksService.GetCodeRemarkAsync(
                    new ChainContext { BlockHash = block.GetHash(), BlockHeight = block.Height }, transferTransaction.To,
                    Hash.FromRawBytes(_parallelTestHelper.TokenContractCode));

            codeRemark.CodeHash.ShouldBe(Hash.FromRawBytes(_parallelTestHelper.TokenContractCode));
            codeRemark.NonParallelizable.ShouldBeFalse();

            transactionList.Clear();
            transferTransaction = _parallelTestHelper.GenerateTransferTransaction(keyPair, accountAddress, symbol, 10);
            transactionList.Add(transferTransaction);
            transferTransaction = await _parallelTestHelper.GenerateTransferTransaction(address,
                                                                                        _parallelTestHelper.PrimaryTokenSymbol, 10);

            transactionList.Add(transferTransaction);
            await _parallelTestHelper.BroadcastTransactions(transactionList);

            block = _parallelTestHelper.GenerateBlock(block.GetHash(), block.Height, transactionList);
            block = await _blockExecutingService.ExecuteBlockAsync(block.Header, transactionList);

            await _blockchainService.AddBlockAsync(block);

            await _blockAttachService.AttachBlockAsync(block);

            var transactionResults = await GetTransactionResultsAsync(block.Body.TransactionIds.ToList(), block.Header);

            transactionResults.Count.ShouldBe(2);
            transactionResults.Count(t => t.Status == TransactionResultStatus.Mined).ShouldBe(2);

            codeRemark =
                await _contractRemarksService.GetCodeRemarkAsync(
                    new ChainContext { BlockHash = block.GetHash(), BlockHeight = block.Height }, transferTransaction.To,
                    Hash.FromRawBytes(_parallelTestHelper.TokenContractCode));

            codeRemark.CodeHash.ShouldBe(Hash.FromRawBytes(_parallelTestHelper.TokenContractCode));
            codeRemark.NonParallelizable.ShouldBeFalse();
        }