public async Task CanDissociateMultipleAssetsWithAccountAndGetRecordNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAsset1 = await TestAsset.CreateAsync(_network, null, fxAccount); await using var fxAsset2 = await TestAsset.CreateAsync(_network, null, fxAccount); var assets = new Address[] { fxAsset1.Record.Token, fxAsset2.Record.Token }; await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetIsAssociatedAsync(fxAsset2, fxAccount); var record = await fxAccount.Client.DissociateTokensWithRecordAsync(assets, fxAccount.Record.Address, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, record.Status); Assert.Equal(ResponseCode.Success, record.Status); Assert.False(record.Hash.IsEmpty); Assert.NotNull(record.Concensus); Assert.NotNull(record.CurrentExchangeRate); Assert.NotNull(record.NextExchangeRate); Assert.NotEmpty(record.Hash.ToArray()); Assert.Empty(record.Memo); Assert.InRange(record.Fee, 0UL, ulong.MaxValue); Assert.Equal(fxAccount.Record.Address, record.Id.Address); await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); }
public async Task CanAssociateAssetWithAccountNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var receipt = await fxAccount.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount.Record.Address, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, receipt.Status); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0U, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); }
public async Task CanDissociateMultipleAssetsWithAccountNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAsset1 = await TestAsset.CreateAsync(_network, null, fxAccount); await using var fxAsset2 = await TestAsset.CreateAsync(_network, null, fxAccount); var assets = new Address[] { fxAsset1.Record.Token, fxAsset2.Record.Token }; await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetIsAssociatedAsync(fxAsset2, fxAccount); var receipt = await fxAccount.Client.DissociateTokensAsync(assets, fxAccount.Record.Address, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, receipt.Status); await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); }
public async Task CanAssociateAssetWithAliasAccountDefect() { // 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>(CanAssociateAssetWithAliasAccount)); Assert.StartsWith("Unable to associate Token with Account, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Associate Assets: Can Associate asset with Alias Account")] async Task CanAssociateAssetWithAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Metadata = null); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var receipt = await fxAccount.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount.Alias, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0UL, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); } }
public async Task CanDissociateAssetFromAccountAndGetRecordNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0U, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); var record = await fxAccount.Client.DissociateTokenWithRecordAsync(fxAsset.Record.Token, fxAccount.Record.Address, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, record.Status); Assert.Equal(ResponseCode.Success, record.Status); Assert.False(record.Hash.IsEmpty); Assert.NotNull(record.Concensus); Assert.NotNull(record.CurrentExchangeRate); Assert.NotNull(record.NextExchangeRate); Assert.NotEmpty(record.Hash.ToArray()); Assert.Empty(record.Memo); Assert.InRange(record.Fee, 0UL, ulong.MaxValue); Assert.Equal(fxAccount.Record.Address, record.Id.Address); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); }
public async Task CanAutoAssociateAssetWithAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var receipt = await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); Assert.Equal(ResponseCode.Success, receipt.Status); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(1UL, association.Balance); Assert.Equal(0UL, association.Decimals); Assert.Equal(TokenKycStatus.NotApplicable, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.True(association.AutoAssociated); var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount); Assert.Equal(fxAccount.CreateParams.AutoAssociationLimit, info.AutoAssociationLimit); Assert.Single(info.Tokens); var balance = info.Tokens[0]; Assert.Equal(fxAsset.Record.Token, balance.Token); Assert.Equal(fxAsset.Params.Symbol, balance.Symbol); Assert.Equal(TokenKycStatus.NotApplicable, balance.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, balance.TradableStatus); Assert.True(balance.AutoAssociated); }
public async Task CanAssociateAssetWithAccountAndGetRecord() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Metadata = null); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var record = await fxAccount.Client.AssociateTokenWithRecordAsync(fxAsset.Record.Token, fxAccount.Record.Address, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, record.Status); Assert.False(record.Hash.IsEmpty); Assert.NotNull(record.Concensus); Assert.NotNull(record.CurrentExchangeRate); Assert.NotNull(record.NextExchangeRate); Assert.NotEmpty(record.Hash.ToArray()); Assert.Empty(record.Memo); Assert.InRange(record.Fee, 0UL, ulong.MaxValue); Assert.Equal(_network.Payer, record.Id.Address); Assert.Null(record.ParentTransactionConcensus); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0u, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); }
public async Task CanRaiseLimitAssetAutoAssociation() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.AutoAssociationLimit = 100); await using var fxAsset1 = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await using var fxAsset2 = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); var receipt = await fxAsset1.Client.TransferAssetAsync(new Asset(fxAsset1, 1), fxAsset1.TreasuryAccount, fxAccount, fxAsset1.TreasuryAccount); Assert.Equal(ResponseCode.Success, receipt.Status); await fxAccount.Client.UpdateAccountAsync(new UpdateAccountParams { Address = fxAccount, AutoAssociationLimit = 2, Signatory = fxAccount }); var receipt2 = await fxAsset2.Client.TransferAssetAsync(new Asset(fxAsset2, 1), fxAsset2.TreasuryAccount, fxAccount, fxAsset2.TreasuryAccount); Assert.Equal(ResponseCode.Success, receipt2.Status); await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetIsAssociatedAsync(fxAsset2, fxAccount); await AssertHg.AssetBalanceAsync(fxAsset1, fxAccount, 1); await AssertHg.AssetBalanceAsync(fxAsset2, fxAccount, 1); }
public async Task CanLimitAssetAutoAssociation() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.AutoAssociationLimit = 1); await using var fxAsset1 = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await using var fxAsset2 = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); var receipt = await fxAsset1.Client.TransferAssetAsync(new Asset(fxAsset1, 1), fxAsset1.TreasuryAccount, fxAccount, fxAsset1.TreasuryAccount); Assert.Equal(ResponseCode.Success, receipt.Status); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset1.Client.TransferAssetAsync(new Asset(fxAsset2, 1), fxAsset2.TreasuryAccount, fxAccount, fxAsset2.TreasuryAccount); }); Assert.Equal(ResponseCode.NoRemainingAutomaticAssociations, tex.Status); Assert.StartsWith("Unable to execute transfers, status: NoRemainingAutomaticAssociations", tex.Message); await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); await AssertHg.AssetBalanceAsync(fxAsset1, fxAccount, 1); }
public async Task CanNotScheduleAssociateAssetWithAccount() { await using var fxPayer = await TestAccount.CreateAsync(_network); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAccount.Client.AssociateTokenAsync( fxAsset.Record.Token, fxAccount.Record.Address, new Signatory( fxAccount.PrivateKey, new PendingParams { PendingPayer = fxPayer })); }); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Status); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Receipt.Status); Assert.StartsWith("Unable to schedule transaction, status: ScheduledTransactionNotInWhitelist", tex.Message); }
public async Task CanAssociateMultipleAssetsWithAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset1 = await TestAsset.CreateAsync(_network); await using var fxAsset2 = await TestAsset.CreateAsync(_network); await using var fxToken3 = await TestToken.CreateAsync(_network); var assets = new Address[] { fxAsset1.Record.Token, fxAsset2.Record.Token, fxToken3.Record.Token }; await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); await AssertHg.TokenNotAssociatedAsync(fxToken3, fxAccount); var receipt = await fxAccount.Client.AssociateTokensAsync(assets, fxAccount.Record.Address, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); Assert.Equal(fxAsset1.Record.Token, association.Token); Assert.Equal(fxAsset1.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0U, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); association = await AssertHg.AssetIsAssociatedAsync(fxAsset2, fxAccount); Assert.Equal(fxAsset2.Record.Token, association.Token); Assert.Equal(fxAsset2.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0U, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); association = await AssertHg.TokenIsAssociatedAsync(fxToken3, fxAccount); Assert.Equal(fxToken3.Record.Token, association.Token); Assert.Equal(fxToken3.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(fxToken3.Params.Decimals, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); }
public async Task GrantAssetCoinsRequiresGrantKeySignature() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Grant Token, status: InvalidSignature", tex.Message); }
public async Task NoAssetAutoAssociationResultsInError() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.AutoAssociationLimit = 0); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.TokenNotAssociatedToAccount, tex.Status); Assert.StartsWith("Unable to execute transfers, status: TokenNotAssociatedToAccount", tex.Message); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); }
public async Task AssociationRequiresSigningByTargetAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAccount.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount.Record.Address); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to associate Token with Account, status: InvalidSignature", tex.Message); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); }
public async Task CanDissociateMultipleAssetsWithAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset1 = await TestAsset.CreateAsync(_network, null, fxAccount); await using var fxAsset2 = await TestAsset.CreateAsync(_network, null, fxAccount); var assets = new Address[] { fxAsset1.Record.Token, fxAsset2.Record.Token }; await AssertHg.AssetIsAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetIsAssociatedAsync(fxAsset2, fxAccount); var receipt = await fxAccount.Client.DissociateTokensAsync(assets, fxAccount.Record.Address, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); await AssertHg.AssetNotAssociatedAsync(fxAsset1, fxAccount); await AssertHg.AssetNotAssociatedAsync(fxAsset2, fxAccount); }
public async Task NoAssetBalanceRecordExistsWhenNotAssociated() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var receipt = await fxAccount.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount.Record.Address, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); var association = await AssertHg.AssetIsAssociatedAsync(fxAsset, fxAccount); Assert.Equal(fxAsset.Record.Token, association.Token); Assert.Equal(fxAsset.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(0U, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); }
public async Task SuspendAssetRequiresSuspendKeyToSignTransaciton() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = false; }); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Suspend Token, status: InvalidSignature", tex.Message); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); }