public async Task GetAccountBalancesAsync_ValidAccount_ReturnsXRPBalance()
        {
            var r = await client.GetAccountBalancesAsync(account1);

            Assert.IsTrue(r.Success);
            Assert.IsTrue(r.Balances.Length > 0);

            // response should contain XRP balance
            var xrpBalance = r.Balances.FirstOrDefault(b => b.Currency == "XRP");

            Assert.IsNotNull(xrpBalance, "XRP balance is missing");
            Assert.IsTrue(String.IsNullOrWhiteSpace(xrpBalance.Counterparty));
            Assert.IsTrue(xrpBalance.Value > 0);
        }
Ejemplo n.º 2
0
        public async Task SendXrpFromAccount1ToAccount2()
        {
            // get initial XRP balance for account1 and account2
            var r1 = await _client.GetAccountBalancesAsync(account1);

            decimal initialXrpBalanceAccount1 = r1.Balances.Single(b => b.Currency == "XRP").Value;

            r1 = await _client.GetAccountBalancesAsync(account2);

            decimal initialXrpBalanceAccount2 = r1.Balances.Single(b => b.Currency == "XRP").Value;

            // prepare payment
            var r2 = await _client.PreparePaymentAsync(account1, account2, new Amount(amountToSend));

            var payment = r2.Payments[0];

            // generate client resource id
            var rid = await _client.CreateClientResourceIdAsync();

            var clientResourceId = rid.Uuid;

            // submit payment
            var r3 = await _client.SubmitPaymentAndWaitUntilValidatedAsync(payment, clientResourceId, secret1);

            // get final balance for both accounts
            r1 = await _client.GetAccountBalancesAsync(account1);

            decimal finalXrpBalanceAccount1 = r1.Balances.Single(b => b.Currency == "XRP").Value;

            r1 = await _client.GetAccountBalancesAsync(account2);

            decimal finalXrpBalanceAccount2 = r1.Balances.Single(b => b.Currency == "XRP").Value;

            // verify final account balances
            Assert.AreEqual(finalXrpBalanceAccount1, initialXrpBalanceAccount1 - amountToSend - fee, "finalXrpBalanceAccount1 is wrong");
            Assert.AreEqual(finalXrpBalanceAccount2, initialXrpBalanceAccount2 + amountToSend, "finalXrpBalanceAccount2 is wrong");
        }