public async Task SigningATransactionAltersTheEndorsementsList() { await using var pendingFx = await TestPendingTransfer.CreateAsync(_network, fx => { fx.TransferParams.Signatory = new Signatory( fx.PrivateKey, new PendingParams { PendingPayer = fx.PayingAccount, Administrator = fx.PublicKey, Memo = fx.Memo, }); }); var info = await pendingFx.PayingAccount.Client.GetPendingTransactionInfoAsync(pendingFx.Record.Pending.Id); Assert.Empty(info.Endorsements); await pendingFx.Client.SignPendingTransactionWithRecordAsync(pendingFx.Record.Pending.Id, pendingFx.SendingAccount.PrivateKey); info = await pendingFx.PayingAccount.Client.GetPendingTransactionInfoAsync(pendingFx.Record.Pending.Id); Assert.Single(info.Endorsements); Assert.Null(info.Executed); await pendingFx.Client.SignPendingTransactionWithRecordAsync(pendingFx.Record.Pending.Id, pendingFx.PayingAccount.PrivateKey); info = await pendingFx.PayingAccount.Client.GetPendingTransactionInfoAsync(pendingFx.Record.Pending.Id); Assert.Equal(2, info.Endorsements.Length); Assert.NotNull(info.Executed); }
public async Task CanScheduleATransferTransaction() { await using var pendingFx = await TestPendingTransfer.CreateAsync(_network); Assert.Equal(ResponseCode.Success, pendingFx.Record.Status); Assert.NotNull(pendingFx.Record.Pending); }
public async Task CanScheduleATransferTransactionWithAliasPayerDefect() { // Associating an asset with an account using its alias address has not yet been // implemented by the network, although it will accept the transaction. var testFailException = (await Assert.ThrowsAsync <TransactionException>(CanScheduleATransferTransactionWithAliasPayer)); Assert.StartsWith("Unable to schedule transaction, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Pending Transaction Create: Can Schedule a Transfer Transaction with Alias Payer")] async Task CanScheduleATransferTransactionWithAliasPayer() { await using var fxPayer = await TestAliasAccount.CreateAsync(_network); await using var pendingFx = await TestPendingTransfer.CreateAsync(_network, fx => { fx.TransferParams.Signatory = new Signatory( fx.PayingAccount.PrivateKey, fx.PrivateKey, new PendingParams { PendingPayer = fxPayer.Alias, Administrator = fx.PublicKey, Memo = fx.Memo }); }); Assert.Equal(ResponseCode.Success, pendingFx.Record.Status); Assert.NotNull(pendingFx.Record.Pending); } }
public async Task CanGetTokenInfo() { await using var fx = await TestPendingTransfer.CreateAsync(_network); Assert.Equal(ResponseCode.Success, fx.Record.Status); var receipt = await fx.Client.DeletePendingTransactionAsync(fx.Record.Pending.Id, ctx => ctx.Signatory = new Signatory(fx.PrivateKey, ctx.Signatory)); Assert.Equal(ResponseCode.Success, receipt.Status); }
public async Task CanSignAPendingTransferTransaction() { await using var pendingFx = await TestPendingTransfer.CreateAsync(_network); Assert.Equal(ResponseCode.Success, pendingFx.Record.Status); var receipt = await pendingFx.Client.SignPendingTransactionAsync(pendingFx.Record.Pending.Id, pendingFx.SendingAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.NotEqual(TxId.None, receipt.Id); Assert.Null(receipt.Pending); Assert.NotNull(receipt.CurrentExchangeRate); Assert.InRange(receipt.CurrentExchangeRate.Expiration, DateTime.MinValue, DateTime.MaxValue); Assert.NotNull(receipt.NextExchangeRate); Assert.InRange(receipt.NextExchangeRate.Expiration, DateTime.MinValue, DateTime.MaxValue); }
public static async Task <TestPendingTransfer> CreateAsync(NetworkCredentials networkCredentials, Action <TestPendingTransfer> customize = null) { var fx = new TestPendingTransfer(); networkCredentials.Output?.WriteLine("STARTING SETUP: Scheduled Transfer Crypto Transaction"); (fx.PublicKey, fx.PrivateKey) = Generator.KeyPair(); fx.Network = networkCredentials; fx.Client = networkCredentials.NewClient(); fx.SendingAccount = await TestAccount.CreateAsync(networkCredentials); fx.ReceivingAccount = await TestAccount.CreateAsync(networkCredentials); fx.PayingAccount = await TestAccount.CreateAsync(networkCredentials); fx.Memo = Generator.Code(10); var xferAmount = (long)fx.SendingAccount.CreateParams.InitialBalance / 2; fx.TransferParams = new TransferParams { CryptoTransfers = new Dictionary <AddressOrAlias, long> { { fx.SendingAccount, -xferAmount }, { fx.ReceivingAccount, xferAmount } }, Signatory = new Signatory( fx.PayingAccount.PrivateKey, fx.PrivateKey, new PendingParams { PendingPayer = fx.PayingAccount, Administrator = fx.PublicKey, Memo = fx.Memo }) }; customize?.Invoke(fx); fx.Record = await fx.Client.RetryKnownNetworkIssues(async client => { return(await fx.Client.TransferWithRecordAsync(fx.TransferParams)); }); Assert.Equal(ResponseCode.Success, fx.Record.Status); networkCredentials.Output?.WriteLine("SETUP COMPLETED: Scheduled Transfer Crypto Transaction"); return(fx); }
public async Task CanSignAPendingTransferTransactionAndGetRecord() { await using var pendingFx = await TestPendingTransfer.CreateAsync(_network); Assert.Equal(ResponseCode.Success, pendingFx.Record.Status); var record = await pendingFx.Client.SignPendingTransactionWithRecordAsync(pendingFx.Record.Pending.Id, pendingFx.SendingAccount.PrivateKey); Assert.Equal(ResponseCode.Success, record.Status); Assert.NotEqual(TxId.None, record.Id); Assert.Null(record.Pending); Assert.NotNull(record.CurrentExchangeRate); Assert.InRange(record.CurrentExchangeRate.Expiration, DateTime.MinValue, DateTime.MaxValue); Assert.NotNull(record.NextExchangeRate); Assert.InRange(record.NextExchangeRate.Expiration, DateTime.MinValue, DateTime.MaxValue); Assert.False(record.Hash.IsEmpty); Assert.NotNull(record.Concensus); Assert.Empty(record.Memo); Assert.InRange(record.Fee, 0UL, ulong.MaxValue); }
public async Task CanGetTokenInfo() { await using var fx = await TestPendingTransfer.CreateAsync(_network); Assert.Equal(ResponseCode.Success, fx.Record.Status); var info = await fx.PayingAccount.Client.GetPendingTransactionInfoAsync(fx.Record.Pending.Id); Assert.Equal(fx.Record.Pending.Id, info.Id); Assert.Equal(fx.Record.Pending.TxId, info.TxId); Assert.Equal(_network.Payer, info.Creator); Assert.Equal(fx.PayingAccount, info.Payer); Assert.Single(info.Endorsements); Assert.Equal(new Endorsement(fx.PayingAccount.PublicKey), info.Endorsements[0]); Assert.Equal(new Endorsement(fx.PublicKey), info.Administrator); Assert.Equal(fx.Memo, info.Memo); Assert.True(info.Expiration > DateTime.MinValue); Assert.Null(info.Executed); Assert.Null(info.Deleted); Assert.False(info.PendingTransactionBody.IsEmpty); }
public async Task DeletingPendingTransactionDoesNotRemovePendingInfo() { await using var fx = await TestPendingTransfer.CreateAsync(_network); var receipt = await fx.Client.DeletePendingTransactionAsync(fx.Record.Pending.Id, ctx => ctx.Signatory = new Signatory(fx.PrivateKey, ctx.Signatory)); var record = await fx.Client.GetTransactionRecordAsync(receipt.Id); var info = await fx.PayingAccount.Client.GetPendingTransactionInfoAsync(fx.Record.Pending.Id); Assert.Equal(fx.Record.Pending.Id, info.Id); Assert.Equal(fx.Record.Pending.TxId, info.TxId); Assert.Equal(_network.Payer, info.Creator); Assert.Equal(fx.PayingAccount, info.Payer); Assert.Single(info.Endorsements); Assert.Equal(new Endorsement(fx.PayingAccount.PublicKey), info.Endorsements[0]); Assert.Equal(new Endorsement(fx.PublicKey), info.Administrator); Assert.Equal(fx.Memo, info.Memo); Assert.True(info.Expiration > DateTime.MinValue); Assert.Null(info.Executed); Assert.Equal(record.Concensus, info.Deleted); Assert.False(info.PendingTransactionBody.IsEmpty); }