示例#1
0
        public async Task <MessageEnvelope> MakePayment(KeyPair destination, long amount, ConstellationInfo.Asset asset, bool waitForFinalize = true)
        {
            var paymentMessage = new PaymentRequest {
                Amount = amount, Destination = destination, Asset = asset.Id
            };
            var response = (CentaurusResponse)await connection.SendMessage(paymentMessage.CreateEnvelope());

            var result = await(waitForFinalize ? response.ResponseTask : response.AcknowledgmentTask);

            return(result);
        }
        public async Task PaymentQuantumTest(long amount, bool useFakeSigner, Type excpectedException)
        {
            var account = context.AccountStorage.GetAccount(TestEnvironment.Client1KeyPair);

            var withdrawal = new PaymentRequest
            {
                Account        = account.Account.Id,
                RequestId      = 1,
                Asset          = 0,
                Destination    = TestEnvironment.Client2KeyPair,
                Amount         = amount,
                AccountWrapper = account
            };

            var envelope = withdrawal.CreateEnvelope();

            envelope.Sign(useFakeSigner ? TestEnvironment.Client2KeyPair : TestEnvironment.Client1KeyPair);

            if (!context.IsAlpha)
            {
                var quantum = new RequestQuantum {
                    Apex = context.QuantumStorage.CurrentApex + 1, RequestEnvelope = envelope, Timestamp = DateTime.UtcNow.Ticks
                };
                envelope = quantum.CreateEnvelope();
                envelope.Sign(TestEnvironment.AlphaKeyPair);
            }

            var expextedBalance = account.Account.GetBalance(0).Amount - amount;

            await AssertQuantumHandling(envelope, excpectedException);

            if (excpectedException == null)
            {
                Assert.AreEqual(account.Account.GetBalance(0).Amount, expextedBalance);
            }
        }