public async void TestBalanceInvalidAddress() { AccountCallBuilder builder = new AccountCallBuilder(horizon_url); builder.accountId("not existing address"); await Assert.ThrowsAsync <ResourceNotFoundException>(() => builder.Call()); }
public async void TestBalance() { AccountCallBuilder builder = new AccountCallBuilder(horizon_url); builder.accountId("GBLQWS2KU3GW67KXQKAWWAML33465ZDVOWCEVV5TU2PHXMZUA3PFQM5C"); var t = await builder.Call(); Console.WriteLine(t.Balances[0].Balance); }
public async Task <AccountDetails> GetAccountDetails(string address) { try { var builder = new AccountCallBuilder(_horizonUrl); builder.accountId(address); var accountDetails = await builder.Call(); return(accountDetails); } catch (ResourceNotFoundException) { // address not found return(null); } }
public async void TestSubmitTransactionMissingAmount() { StellarBase.Network.CurrentNetwork = network_passphrase; AccountCallBuilder accountBuilder = new AccountCallBuilder(horizon_url); accountBuilder.accountId("GBAB45XKXEGB74QALBHWP7HATWSWXVHWJKO7W6R3ETWJVCZN5FTASVHL"); var t = await accountBuilder.Call(); var sourceKeyPair = KeyPair.FromSeed("SAEBUXJNNNZPMX3NDG4TTTV2OGUQIMFPPAHZG4FO4FQECKWK4BOSN5GZ"); Account sourceAccount = new Account(sourceKeyPair, long.Parse(t.Sequence)); var destinationKeyPair = KeyPair.FromAddress("GDGUDD3WNMAZD6GQXXJXZMJKMCADEZJDA74TAQJSEEPTLNL4PYHZVM4T"); // make payment with amount > source balance double amount = double.Parse(t.Balances[0].Balance); var operation = new PaymentOperation.Builder(destinationKeyPair, new Asset(), (long)(amount * StellarBase.One.Value) + 10) .SetSourceAccount(sourceKeyPair) .Build(); sourceAccount.IncrementSequenceNumber(); var transaction = new StellarBase.Transaction.Builder(sourceAccount) .AddOperation(operation) .Build(); transaction.Sign(sourceAccount.KeyPair); var txSigned = transaction.ToEnvelopeXdrBase64(); TransactionCallBuilder txBuilder = new TransactionCallBuilder(horizon_url); txBuilder.submitTransaction(txSigned); try { var tx = await txBuilder.Call(); Assert.Equal("Expected BadRequestException", null); } catch (BadRequestException e) { Assert.Equal(400, e.ErrorDetails.Status); Assert.Equal("tx_failed", e.ErrorDetails.Extras.ResultCodes.Transaction); Assert.Equal("op_underfunded", e.ErrorDetails.Extras.ResultCodes.Operations[0]); } }