public async Task CanUpdateKeyOfAliasAccountDefect() { // Updating 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>(CanUpdateKeyOfAliasAccount)); Assert.StartsWith("Unable to update account, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Update Account: Can Update Key of Alias Account")] async Task CanUpdateKeyOfAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); var updatedKeyPair = Generator.KeyPair(); var originalInfo = await fxAccount.Client.GetAccountInfoAsync(fxAccount.CreateRecord.Address); Assert.Equal(new Endorsement(fxAccount.PublicKey), originalInfo.Endorsement); var updateResult = await fxAccount.Client.UpdateAccountAsync(new UpdateAccountParams { Address = fxAccount.Alias, Endorsement = new Endorsement(updatedKeyPair.publicKey), Signatory = new Signatory(fxAccount.PrivateKey, updatedKeyPair.privateKey) }); Assert.Equal(ResponseCode.Success, updateResult.Status); var updatedInfo = await fxAccount.Client.GetAccountInfoAsync(fxAccount.CreateRecord.Address); Assert.Equal(new Endorsement(updatedKeyPair.publicKey), updatedInfo.Endorsement); } }
public async Task CanGrantTokensToAliasAccountDefect() { // 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>(CanGrantTokensToAliasAccount)); Assert.StartsWith("Unable to Grant Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Grant Tokens: Can Grant Token Coins to Alias Account")] async Task CanGrantTokensToAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network); await fxToken.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount, fxAccount.PrivateKey); var circulation = fxToken.Params.Circulation; var xferAmount = circulation / 3; await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenKycStatus.Revoked); await fxToken.Client.GrantTokenKycAsync(fxToken.Record.Token, fxAccount.Alias, fxToken.GrantPrivateKey); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenKycStatus.Granted); await fxToken.Client.TransferTokensAsync(fxToken, fxToken.TreasuryAccount, fxAccount, (long)xferAmount, fxToken.TreasuryAccount); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenKycStatus.Granted); } }
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 static async Task <TestAliasAccount> CreateAsync(NetworkCredentials networkCredentials, Action <TestAliasAccount> customize = null) { var fx = new TestAliasAccount(); networkCredentials.Output?.WriteLine("STARTING SETUP: Pay to Alias Account Instance"); (fx.PublicKey, fx.PrivateKey) = Generator.KeyPair(); fx.Network = networkCredentials; fx.Client = networkCredentials.NewClient(); fx.Alias = new Alias(fx.PublicKey); fx.InitialTransfer = Generator.Integer(1_00_000_000, 2_00_000_000); customize?.Invoke(fx); fx.TransactionRecord = await fx.Client.RetryKnownNetworkIssues(async client => { return(await fx.Client.TransferWithRecordAsync(fx.Network.Payer, fx.Alias, fx.InitialTransfer, ctx => { ctx.Memo = "Test Account Instance: Creating Test Account on Network"; })); }); var createTransactionId = new TxId(fx.TransactionRecord.Id.Address, fx.TransactionRecord.Id.ValidStartSeconds, fx.TransactionRecord.Id.ValidStartNanos, false, 1); Assert.Equal(ResponseCode.Success, fx.TransactionRecord.Status); fx.CreateRecord = await fx.Client.GetTransactionRecordAsync(createTransactionId) as CreateAccountRecord; Assert.NotNull(fx.CreateRecord); networkCredentials.Output?.WriteLine("SETUP COMPLETED: Pay to Alias Account Instance"); return(fx); }
public async Task CanCreateATopicWithAliasRenewAccountDefect() { // Creating a topic with a renewal 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>(CanCreateATopicWithAliasRenewAccount)); Assert.StartsWith("Unable to create Consensus Topic, status: InvalidAutorenewAccount", testFailException.Message); //[Fact(DisplayName = "Create Topic: Can Create Topic with Alias Renew Account")] async Task CanCreateATopicWithAliasRenewAccount() { await using var fxRenew = await TestAliasAccount.CreateAsync(_network); await using var fx = await TestTopic.CreateAsync(_network, fx => { fx.Params.RenewAccount = fxRenew.Alias; fx.Signatory = new Signatory(fx.AdminPrivateKey, fx.ParticipantPrivateKey, fxRenew.PrivateKey); }); var info = await fx.Client.GetTopicInfoAsync(fx.Record.Topic); Assert.Equal(fx.Memo, info.Memo); Assert.NotEmpty(info.RunningHash.ToArray()); Assert.Equal(0UL, info.SequenceNumber); Assert.True(info.Expiration > DateTime.MinValue); Assert.Equal(new Endorsement(fx.AdminPublicKey), info.Administrator); Assert.Equal(new Endorsement(fx.ParticipantPublicKey), info.Participant); Assert.True(info.AutoRenewPeriod > TimeSpan.MinValue); Assert.Equal(fxRenew.CreateRecord.Address, info.RenewAccount); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ } }
public async Task CanUpdateAutoRenewAccountToAliasAccountDefect() { // Data corruption bug when using the Alias form to update a renew account. var testFailException = (await Assert.ThrowsAsync <TransactionException>(CanUpdateAutoRenewAccountToAliasAccount)); Assert.StartsWith("Unable to update Topic, status: InvalidAutorenewAccount", testFailException.Message); //[Fact(DisplayName = "Update Topic: Can Update Auto Renew Account to Alias Account")] async Task CanUpdateAutoRenewAccountToAliasAccount() { await using var fxTopic = await TestTopic.CreateAsync(_network); await using var fxAccount = await TestAliasAccount.CreateAsync(_network); var infoBefore = await fxTopic.Client.GetTopicInfoAsync(fxTopic.Record.Topic); Assert.Equal(fxTopic.TestAccount.Record.Address, infoBefore.RenewAccount); await fxTopic.Client.UpdateTopicAsync(new UpdateTopicParams { Topic = fxTopic.Record.Topic, Signatory = new Signatory(fxTopic.AdminPrivateKey, fxAccount.PrivateKey), RenewAccount = fxAccount.Alias }); var infoAfter = await fxTopic.Client.GetTopicInfoAsync(fxTopic.Record.Topic); Assert.Equal(fxAccount.CreateRecord.Address, infoAfter.RenewAccount); } }
public async Task CanReusmeTokenCoinTradingWithAiasAccountDefect() { // Resuming a token 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>(CanReusmeTokenCoinTradingWithAiasAccount)); Assert.StartsWith("Unable to Resume Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Resume Tokens: Can Reume Token Coin Trading with Alias Account")] async Task CanReusmeTokenCoinTradingWithAiasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }); await fxToken.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount, fxAccount.PrivateKey); var circulation = fxToken.Params.Circulation; var xferAmount = circulation / 3; await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Suspended); await fxToken.Client.ResumeTokenAsync(fxToken.Record.Token, fxAccount.Alias, fxToken.SuspendPrivateKey); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Tradable); await fxToken.Client.TransferTokensAsync(fxToken, fxToken.TreasuryAccount, fxAccount, (long)xferAmount, fxToken.TreasuryAccount); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Tradable); } }
public async Task CanGrantAssetsToAliasAccountDefect() { // Granting Access to 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>(CanGrantAssetsToAliasAccount)); Assert.StartsWith("Unable to Grant Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Grant Assets: Can Grant Asset Coins to Alias Account")] async Task CanGrantAssetsToAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await fxAsset.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount, fxAccount.PrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount.Alias, fxAsset.GrantPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Granted); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Granted); } }
public async Task CanDissociateTokenFromAliasAccountDefect() { // Disassociating a token from 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>(CanDissociateTokenFromAliasAccount)); Assert.StartsWith("Unable to Dissociate Token from Account, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Dissociate Tokens: Can Dissociate token from Alias Account")] async Task CanDissociateTokenFromAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network); await fxToken.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount, fxAccount.PrivateKey); var association = await AssertHg.TokenIsAssociatedAsync(fxToken, fxAccount); Assert.Equal(fxToken.Record.Token, association.Token); Assert.Equal(fxToken.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(fxToken.Params.Decimals, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); var receipt = await fxAccount.Client.DissociateTokenAsync(fxToken.Record.Token, fxAccount.Alias, fxAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); await AssertHg.TokenNotAssociatedAsync(fxToken, fxAccount); } }
internal static async Task AssetNotAssociatedAsync(TestAsset fxAsset, TestAliasAccount fxAccount) { var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount); Assert.NotNull(info); var association = info.Tokens.FirstOrDefault(t => t.Token == fxAsset.Record.Token); Assert.Null(association); }
public async Task CanGetTinybarBalanceForAliasAccountAsync() { await using var fx = await TestAliasAccount.CreateAsync(_network); var balanceByAlias = await fx.Client.GetAccountBalanceAsync(fx.Alias); Assert.True(balanceByAlias > 0, "Account Balance should be greater than zero."); var balanceByAccount = await fx.Client.GetAccountBalanceAsync(fx.CreateRecord.Address); Assert.Equal(balanceByAccount, balanceByAlias); }
public async Task CanTransferAssetsToAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await fxAsset.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount, fxAccount.PrivateKey); var asset = new Asset(fxAsset.Record.Token, 1); var receipt = await fxAsset.Client.TransferAssetAsync(asset, fxAsset.TreasuryAccount.Record.Address, fxAccount.Alias, fxAsset.TreasuryAccount.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); var info = await fxAsset.Client.GetTokenInfoAsync(fxAsset.Record.Token); Assert.Equal(fxAsset.Record.Token, info.Token); Assert.Equal(TokenType.Asset, info.Type); Assert.Equal(fxAsset.Params.Symbol, info.Symbol); Assert.Equal(fxAsset.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal((ulong)fxAsset.Metadata.Length, info.Circulation); Assert.Equal(0UL, info.Decimals); Assert.Equal(fxAsset.Params.Ceiling, info.Ceiling); Assert.Equal(fxAsset.Params.Administrator, info.Administrator); Assert.Equal(fxAsset.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxAsset.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxAsset.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxAsset.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(fxAsset.Params.RoyaltiesEndorsement, info.RoyaltiesEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.NotApplicable, info.KycStatus); Assert.Empty(info.Royalties); Assert.False(info.Deleted); Assert.Equal(fxAsset.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ var balances = await fxAccount.Client.GetAccountBalancesAsync(fxAccount.CreateRecord.Address); Assert.Equal(fxAccount.CreateRecord.Address, balances.Address); Assert.True(balances.Crypto > 0); Assert.Single(balances.Tokens); Assert.Equal(1ul, balances.Tokens[fxAsset.Record.Token].Balance); balances = await fxAccount.Client.GetAccountBalancesAsync(fxAsset.TreasuryAccount.Record.Address); Assert.Equal(fxAsset.TreasuryAccount.Record.Address, balances.Address); Assert.Equal(fxAsset.TreasuryAccount.CreateParams.InitialBalance, balances.Crypto); Assert.Single(balances.Tokens); Assert.Equal((ulong)(fxAsset.Metadata.Length - 1), balances.Tokens[fxAsset.Record.Token].Balance); }
public static async Task TokenStatusAsync(TestToken fxToken, TestAliasAccount fxAccount, TokenTradableStatus status) { var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount.CreateRecord.Address); Assert.NotNull(info); var tokenRecord = info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token); Assert.NotNull(tokenRecord); Assert.Equal(status, tokenRecord.TradableStatus); }
public async Task CanTransferCryptoToNewAliasAccount() { await using var fx = await TestAliasAccount.CreateAsync(_network); var startingBalance = await fx.Client.GetAccountBalanceAsync(fx.Alias); var transferAmount = (long)Generator.Integer(10, 100); var receipt = await fx.Client.TransferAsync(_network.Payer, fx.Alias, transferAmount); var endingBalance = await fx.Client.GetAccountBalanceAsync(fx.Alias); Assert.Equal(startingBalance + (ulong)transferAmount, endingBalance); }
public async Task CanConfiscateAssetCoinsFromAliasDefect() { // Confiscating 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>(CanConfiscateAssetCoinsFromAlias)); Assert.StartsWith("Unable to Confiscate Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Confiscate Assets: Can Confiscate Asset Coins from Alias")] async Task CanConfiscateAssetCoinsFromAlias() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await fxAsset.Client.AssociateTokenAsync(fxAsset, fxAccount, fxAccount.PrivateKey); var circulation = (ulong)fxAsset.Metadata.Length; var xferAmount = circulation / (ulong)Generator.Integer(3, 5) + 1; var expectedTreasury = (ulong)fxAsset.Metadata.Length - xferAmount; var serialNumbersToConfiscate = Enumerable.Range(1, (int)xferAmount).Select(i => (long)i); await fxAsset.Client.TransferAsync(new TransferParams { AssetTransfers = serialNumbersToConfiscate.Select(sn => new AssetTransfer(new Asset(fxAsset.Record.Token, sn), fxAsset.TreasuryAccount, fxAccount)), Signatory = fxAsset.TreasuryAccount }); Assert.Equal(xferAmount, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAccount, fxAsset)); Assert.Equal(expectedTreasury, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); Assert.Equal(circulation, (await fxAsset.Client.GetTokenInfoAsync(fxAsset)).Circulation); var receipt = await fxAsset.Client.ConfiscateAssetsAsync(fxAsset.Record.Token, serialNumbersToConfiscate, fxAccount.Alias, fxAsset.ConfiscatePrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.Equal(expectedTreasury, receipt.Circulation); Assert.Equal(0ul, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAccount, fxAsset)); Assert.Equal(expectedTreasury, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); Assert.Equal(expectedTreasury, (await fxAsset.Client.GetTokenInfoAsync(fxAsset)).Circulation); } }
public async Task CanGetInfoForAliasFacet() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); var infoFromAddress = await fxAccount.Client.GetAccountInfoAsync(fxAccount.CreateRecord.Address); Assert.Equal(fxAccount.CreateRecord.Address, infoFromAddress.Address); Assert.NotNull(infoFromAddress.SmartContractId); Assert.False(infoFromAddress.Deleted); Assert.NotNull(infoFromAddress.Proxy); Assert.Equal(Address.None, infoFromAddress.Proxy); Assert.Equal(0, infoFromAddress.ProxiedToAccount); Assert.Equal(fxAccount.PublicKey, infoFromAddress.Endorsement); Assert.True(infoFromAddress.Balance > 0); Assert.False(infoFromAddress.ReceiveSignatureRequired); Assert.True(infoFromAddress.AutoRenewPeriod.TotalSeconds > 0); Assert.True(infoFromAddress.Expiration > DateTime.MinValue); Assert.Equal("auto-created account", infoFromAddress.Memo); Assert.Equal(0, infoFromAddress.AssetCount); Assert.Equal(0, infoFromAddress.AutoAssociationLimit); Assert.Equal(fxAccount.Alias, infoFromAddress.Alias); AssertHg.NotEmpty(infoFromAddress.Ledger); var infoFromAlias = await fxAccount.Client.GetAccountInfoAsync(fxAccount.Alias); Assert.Equal(fxAccount.CreateRecord.Address, infoFromAlias.Address); Assert.NotNull(infoFromAlias.SmartContractId); Assert.False(infoFromAlias.Deleted); Assert.NotNull(infoFromAlias.Proxy); Assert.Equal(Address.None, infoFromAlias.Proxy); Assert.Equal(0, infoFromAlias.ProxiedToAccount); Assert.Equal(fxAccount.PublicKey, infoFromAlias.Endorsement); Assert.True(infoFromAlias.Balance > 0); Assert.False(infoFromAlias.ReceiveSignatureRequired); Assert.True(infoFromAlias.AutoRenewPeriod.TotalSeconds > 0); Assert.True(infoFromAlias.Expiration > DateTime.MinValue); Assert.Equal("auto-created account", infoFromAlias.Memo); Assert.Equal(0, infoFromAlias.AssetCount); Assert.Equal(0, infoFromAlias.AutoAssociationLimit); Assert.Equal(fxAccount.Alias, infoFromAlias.Alias); AssertHg.Equal(infoFromAddress.Ledger, infoFromAlias.Ledger); }
public async Task CanSuspendTokenCoinTradingWithAliasAddressDefect() { // 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>(CanSuspendTokenCoinTradingWithAliasAddress)); Assert.StartsWith("Unable to Suspend Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Suspend Tokens: Can Suspend Token Coin Trading with Alias Address")] async Task CanSuspendTokenCoinTradingWithAliasAddress() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = false; }); await fxToken.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount, fxAccount.PrivateKey); var circulation = fxToken.Params.Circulation; var xferAmount = circulation / 3; await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Tradable); await fxToken.Client.SuspendTokenAsync(fxToken.Record.Token, fxAccount.Alias, fxToken.SuspendPrivateKey); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxToken.Client.TransferTokensAsync(fxToken, fxToken.TreasuryAccount, fxAccount, (long)xferAmount, fxToken.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenTradableStatus.Suspended); } }
public async Task CanRevokeTokensToAliasAccountDefect() { // 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>(CanRevokeTokensToAliasAccount)); Assert.StartsWith("Unable to Revoke Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Revoke Assets: Can Revoke Assets to Alias ACcount")] async Task CanRevokeTokensToAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await fxAsset.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount, fxAccount.PrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); await fxAsset.Client.GrantTokenKycAsync(fxAsset, fxAccount, fxAsset.GrantPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Granted); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await fxAsset.Client.RevokeTokenKycAsync(fxAsset.Record.Token, fxAccount.Alias, fxAsset.GrantPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 2), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountKycNotGrantedForToken, tex.Status); Assert.Equal(ResponseCode.AccountKycNotGrantedForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountKycNotGrantedForToken", tex.Message); } }
public async Task CanSendFromAliasAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAlias = await TestAliasAccount.CreateAsync(_network); var aliasStartingBalance = await fxAlias.Client.GetAccountBalanceAsync(fxAlias.Alias); var transferAmount = (aliasStartingBalance) / 2 + 1; var accountStartingBalance = await fxAlias.Client.GetAccountBalanceAsync(fxAccount); var receipt = await fxAlias.Client.TransferAsync(fxAlias.Alias, fxAccount.Record.Address, (long)transferAmount, fxAlias.PrivateKey); var accountEndingBalance = await fxAlias.Client.GetAccountBalanceAsync(fxAccount); Assert.Equal(accountStartingBalance + (ulong)transferAmount, accountEndingBalance); var aliasEndingBalance = await fxAlias.Client.GetAccountBalanceAsync(fxAlias.Alias); Assert.Equal(aliasStartingBalance - (ulong)transferAmount, aliasEndingBalance); }
public async Task CanUpdateMemoUsingAliasDefect() { // Updating 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>(CanUpdateMemoUsingAlias)); Assert.StartsWith("Unable to update account, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Update Account: Can Update Memo using Alias")] async Task CanUpdateMemoUsingAlias() { var newMemo = Generator.String(20, 40); await using var fxAccount = await TestAliasAccount.CreateAsync(_network); var record = await fxAccount.Client.UpdateAccountWithRecordAsync(new UpdateAccountParams { Address = fxAccount.Alias, Memo = newMemo, Signatory = fxAccount }); 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); var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount); Assert.Equal(newMemo, info.Memo); } }
public async Task CanConfiscateTokenCoinsFromAliasAccountDefect() { // 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>(CanConfiscateTokenCoinsFromAliasAccount)); Assert.StartsWith("Unable to Confiscate Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Confiscate Tokens: Can Confiscate Token Coins From Alias Account")] async Task CanConfiscateTokenCoinsFromAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await fxToken.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount, fxAccount.PrivateKey); var xferAmount = 2 * fxToken.Params.Circulation / (ulong)Generator.Integer(3, 5); var expectedTreasury = fxToken.Params.Circulation - xferAmount; await fxToken.Client.TransferTokensAsync(fxToken, fxToken.TreasuryAccount, fxAccount, (long)xferAmount, fxToken.TreasuryAccount); Assert.Equal(xferAmount, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAccount, fxToken)); Assert.Equal(expectedTreasury, await fxAccount.Client.GetAccountTokenBalanceAsync(fxToken.TreasuryAccount, fxToken)); Assert.Equal(fxToken.Params.Circulation, (await fxToken.Client.GetTokenInfoAsync(fxToken)).Circulation); var receipt = await fxToken.Client.ConfiscateTokensAsync(fxToken, fxAccount.Alias, xferAmount, fxToken.ConfiscatePrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.Equal(expectedTreasury, receipt.Circulation); Assert.Equal(0ul, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAccount, fxToken)); Assert.Equal(expectedTreasury, await fxAccount.Client.GetAccountTokenBalanceAsync(fxToken.TreasuryAccount, fxToken)); Assert.Equal(expectedTreasury, (await fxToken.Client.GetTokenInfoAsync(fxToken)).Circulation); } }
internal static async Task <TokenBalance> TokenIsAssociatedAsync(TestToken fxToken, TestAliasAccount fxAccount) { var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount.CreateRecord.Address); Assert.NotNull(info); var association = info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token); Assert.NotNull(association); return(association); }