public static TxSubmitModel ToModel(this SubmitTransactionResponse accountResponse) { if (accountResponse == null) { return(null); } return(new TxSubmitModel { Hash = accountResponse.Hash, IsSuccess = accountResponse.IsSuccess(), ResultXdr = accountResponse.ResultXdr }); }
public async Task TestSubmitTransactionSuccess() { var json = File.ReadAllText(Path.Combine("responses", "testdata", "serverSuccess.json")); When().Returns(ResponseMessage(HttpOk, json)); SubmitTransactionResponse response = await _server.SubmitTransaction(BuildTransaction()); Assert.IsTrue(response.IsSuccess()); Assert.AreEqual(response.Ledger, 826150L); Assert.AreEqual(response.Hash, "2634d2cf5adcbd3487d1df042166eef53830115844fdde1588828667bf93ff42"); Assert.IsNull(response.SubmitTransactionResponseExtras); }
public async Task TestSubmitTransactionFail() { var json = File.ReadAllText(Path.Combine("responses", "testdata", "serverFailure.json")); When().Returns(ResponseMessage(HttpBadRequest, json)); SubmitTransactionResponse response = await _server.SubmitTransaction(BuildTransaction()); Assert.IsFalse(response.IsSuccess()); Assert.IsNull(response.Ledger); Assert.IsNull(response.Hash); Assert.AreEqual(response.SubmitTransactionResponseExtras.EnvelopeXdr, "AAAAAK4Pg4OEkjGmSN0AN37K/dcKyKPT2DC90xvjjawKp136AAAAZAAKsZQAAAABAAAAAAAAAAEAAAAJSmF2YSBGVFchAAAAAAAAAQAAAAAAAAABAAAAAG9wfBI7rRYoBlX3qRa0KOnI75W5BaPU6NbyKmm2t71MAAAAAAAAAAABMS0AAAAAAAAAAAEKp136AAAAQOWEjL+Sm+WP2puE9dLIxWlOibIEOz8PsXyG77jOCVdHZfQvkgB49Mu5wqKCMWWIsDSLFekwUsLaunvmXrpyBwQ="); Assert.AreEqual(response.SubmitTransactionResponseExtras.ResultXdr, "AAAAAAAAAGT/////AAAAAQAAAAAAAAAB////+wAAAAA="); Assert.IsNotNull(response.SubmitTransactionResponseExtras); Assert.AreEqual("tx_failed", response.SubmitTransactionResponseExtras.ExtrasResultCodes.TransactionResultCode); Assert.AreEqual("op_no_destination", response.SubmitTransactionResponseExtras.ExtrasResultCodes.OperationsResultCodes[0]); }
public async Task MultisigTest() { using (var stellarServer = new Server(StellarNodeUri)) { KeyPair multisigAccount = KeyPair.FromSecretSeed(MultisigAccountSecretSeed); KeyPair account1 = KeyPair.FromSecretSeed(Account1SecretSeed); KeyPair account2 = KeyPair.FromSecretSeed(Account2SecretSeed); AccountResponse senderAccount = await stellarServer.Accounts.Account(multisigAccount); Operation payment = new PaymentOperation.Builder(account1, new AssetTypeNative(), "1").Build(); Transaction transaction = new Transaction.Builder(senderAccount) .AddOperation(payment) .Build(); transaction.Sign(account1); transaction.Sign(account2); SubmitTransactionResponse result = await stellarServer.SubmitTransaction(transaction); Assert.IsTrue(result.IsSuccess()); } }