Пример #1
0
        public async Task CanScheduleATransferTransaction()
        {
            await using var pendingFx = await TestPendingTransfer.CreateAsync(_network);

            Assert.Equal(ResponseCode.Success, pendingFx.Record.Status);
            Assert.NotNull(pendingFx.Record.Pending);
        }
Пример #2
0
    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);
        }
    }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #8
0
        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);
        }