Esempio n. 1
0
        public async Task SentTransaction_Token_Check_Test()
        {
            //user without token - NotExisted
            {
                var keyPair      = CryptoHelper.GenerateKeyPair();
                var tokenAddress = GetTokenContractAddress();

                //approve transaction
                var transaction = await GenerateTransaction(keyPair, tokenAddress, "Approve", new ApproveInput
                {
                    Amount  = 100,
                    Spender = Address.FromPublicKey(CryptoHelper.GenerateKeyPair().PublicKey),
                    Symbol  = "Check user without token whether can sent transaction"
                });

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.NotExisted);
            }

            //bp user with token - Mined
            {
                var transaction = await _osTestHelper.GenerateTransferTransaction();

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.Mined);
            }
        }
        public async Task SentTransaction_ContractAddress_Check_Test()
        {
            //prepare token
            var(transactions, keyPairs) = await _osTestHelper.PrepareTokenForParallel(2, 100);
            await SendTransactionAsync(transactions[0]);

            var fakeContract = Address.FromPublicKey(keyPairs[1].PublicKey);
            var transaction  = await GenerateTransaction(keyPairs[0], fakeContract, "ContractTest", new Empty());

            var transactionId = await SendTransactionAsync(transaction);

            var transactionResult = await QueryTransactionResultAsync(transactionId);

            Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
            status.ShouldBe(TransactionResultStatus.Failed);
        }
Esempio n. 3
0
        public async Task SentTransaction_SystemContract_Check_Test()
        {
            //prepare token
            var(transactions, keyPairs) = await _osTestHelper.PrepareTokenForParallel(1, 100);
            await SendTransactionAsync(transactions[0]);

            //send consensus transaction
            var consensusContract = GetConsensusContractAddress();
            var transaction       = await GenerateTransaction(keyPairs[0], consensusContract, "FirstRound", new Round());

            var transactionId = await SendTransactionAsync(transaction);

            var transactionResult = await QueryTransactionResultAsync(transactionId);

            Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
            status.ShouldBe(TransactionResultStatus.Failed);
        }
        public async Task SentTransaction_Token_Check_Test()
        {
            //user without token - NotExisted
            {
                var keyPair      = CryptoHelper.GenerateKeyPair();
                var tokenAddress =
                    await _smartContractAddressService.GetAddressByContractNameAsync(await _osTestHelper.GetChainContextAsync(),
                                                                                     TokenSmartContractAddressNameProvider.StringName);

                //approve transaction
                var transaction = await GenerateTransaction(keyPair, tokenAddress, "Approve", new ApproveInput
                {
                    Amount  = 100,
                    Spender = Address.FromPublicKey(CryptoHelper.GenerateKeyPair().PublicKey),
                    // TODO: valid symbol needed for a test case not related to token symbol
                    Symbol = "Check user without token whether can sent transaction"
                });

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.Failed);
            }

            //bp user with token - Mined
            {
                var transaction = await _osTestHelper.GenerateTransferTransaction();

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.Mined);
            }
        }
Esempio n. 5
0
        public async Task SentTransaction_Token_Check_Test()
        {
            //user without token - NotExisted
            {
                var keyPair      = CryptoHelper.GenerateKeyPair();
                var tokenAddress = GetTokenContractAddress();

                //approve transaction
                var transaction = await GenerateTransaction(keyPair, tokenAddress, "Approve", new ApproveInput
                {
                    Amount  = 100,
                    Spender = Address.FromPublicKey(CryptoHelper.GenerateKeyPair().PublicKey),
                    // TODO: valid symbol needed for a test case not related to token symbol
                    Symbol = "Check user without token whether can sent transaction"
                });

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.Failed);
                // transactionResult.Error.ShouldBe(ExecutionStatus.ExecutionStoppedByPrePlugin.ToString());
            }

            //bp user with token - Mined
            {
                var transaction = await _osTestHelper.GenerateTransferTransaction();

                var transactionId = await SendTransactionAsync(transaction);

                var transactionResult = await QueryTransactionResultAsync(transactionId);

                Enum.TryParse <TransactionResultStatus>(transactionResult.Status, true, out var status);
                status.ShouldBe(TransactionResultStatus.Mined);
            }
        }