public async Task EmptyKeyAdministratorKeyIsAllowed() { await using var fxToken = await TestToken.CreateAsync(_network, ctx => { ctx.Params.Administrator = Endorsement.None; }); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Null(info.Administrator); }
public async Task EmptySupplyKeyIsAllowed() { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.SupplyEndorsement = Endorsement.None; }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.Null(info.SupplyEndorsement); }
public async Task InitializeSupendedCanBeFalse() { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.InitializeSuspended = true; }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.Equal(TokenTradableStatus.Suspended, info.TradableStatus); }
public async Task MissingSupplyAdminSignatureIsAllowed() { await using var fx = await TestToken.CreateAsync(_network, fx => { fx.Params.Signatory = new Signatory(fx.AdminPrivateKey, fx.GrantPrivateKey, fx.SuspendPrivateKey, fx.ConfiscatePrivateKey, fx.RenewAccount.PrivateKey, fx.TreasuryAccount.PrivateKey); }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.NotNull(info.SupplyEndorsement); }
public async Task NullConfiscateKeyIsAllowed() { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.ConfiscateEndorsement = null; }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.Null(info.ConfiscateEndorsement); }
public async Task NameDoesAllowNumbersAndSpaces() { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.Name = Generator.UppercaseAlphaCode(20) + " 123\r\n\t?"; }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.Equal(fx.Params.Name, info.Name); }
public async Task EmptyKeySuspendKeyIsAllowed() { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.SuspendEndorsement = Endorsement.None; }); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.Null(info.SuspendEndorsement); Assert.Equal(TokenTradableStatus.NotApplicable, info.TradableStatus); }
public async Task EmptyKeyGrantKycKeyIsAllowed() { await using var fxToken = await TestToken.CreateAsync(_network, ctx => { ctx.Params.GrantKycEndorsement = Endorsement.None; }); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Null(info.GrantKycEndorsement); Assert.Equal(TokenKycStatus.NotApplicable, info.KycStatus); }
public async Task EmptyAddressIdentifierRaisesException() { await using var fx = await TestToken.CreateAsync(_network); var ane = await Assert.ThrowsAsync <ArgumentNullException>(async() => { await fx.Client.GetTokenInfoAsync(Address.None); }); Assert.Equal("token", ane.ParamName); Assert.StartsWith("Token is missing. Please check that it is not null", ane.Message); }
public async Task CanMintTokensAndGetRecord() { await using var fxToken = await TestToken.CreateAsync(_network); Assert.NotNull(fxToken.Record); Assert.NotNull(fxToken.Record.Token); Assert.True(fxToken.Record.Token.AccountNum > 0); Assert.Equal(ResponseCode.Success, fxToken.Record.Status); var record = await fxToken.Client.MintTokenWithRecordAsync(fxToken.Record.Token, fxToken.Params.Circulation, fxToken.SupplyPrivateKey); 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.Equal(fxToken.Params.Circulation * 2, record.Circulation); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Equal(fxToken.Record.Token, info.Token); Assert.Equal(TokenType.Fungible, info.Type); Assert.Equal(fxToken.Params.Symbol, info.Symbol); Assert.Equal(fxToken.TreasuryAccount.Record.Address, info.Treasury); // Note: we doubled the circulation Assert.Equal(fxToken.Params.Circulation * 2, info.Circulation); Assert.Equal(fxToken.Params.Decimals, info.Decimals); Assert.Equal(fxToken.Params.Ceiling, info.Ceiling); Assert.Equal(fxToken.Params.Administrator, info.Administrator); Assert.Equal(fxToken.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxToken.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxToken.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxToken.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(fxToken.Params.RoyaltiesEndorsement, info.RoyaltiesEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.Empty(info.Royalties); Assert.False(info.Deleted); Assert.Equal(fxToken.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ var expectedTreasury = 2 * fxToken.Params.Circulation; Assert.Equal(expectedTreasury, await fxToken.Client.GetAccountTokenBalanceAsync(fxToken.TreasuryAccount, fxToken)); }
public async Task CanDeleteToken() { await using var fx = await TestToken.CreateAsync(_network); var record = await fx.Client.DeleteTokenAsync(fx.Record.Token, fx.AdminPrivateKey); Assert.Equal(ResponseCode.Success, record.Status); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.True(info.Deleted); }
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 EmptyNameIsNotAllowed() { var aoe = await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.Name = string.Empty; }); }); Assert.Equal("Name", aoe.ParamName); Assert.StartsWith("The name cannot be null or empty. (Parameter 'Name')", aoe.Message); }
public async Task ZeroCirculationRaisesError() { var aoe = await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { await TestToken.CreateAsync(_network, ctx => { ctx.Params.Circulation = 0; }); }); Assert.Equal("Circulation", aoe.ParamName); Assert.StartsWith("The initial circulation of tokens must be greater than zero.", aoe.Message); }
public async Task ExpirationTimeInPastRaisesError() { var aoe = await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { await TestToken.CreateAsync(_network, fx => { fx.Params.Expiration = DateTime.UtcNow.AddDays(-5); }); }); Assert.Equal("Expiration", aoe.ParamName); Assert.StartsWith("The expiration time must be in the future.", aoe.Message); }
public async Task CreateTokenMissingRenewAccountSignatureRaisesError() { var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await TestToken.CreateAsync(_network, fx => { fx.Params.Signatory = new Signatory(fx.AdminPrivateKey, fx.GrantPrivateKey, fx.SuspendPrivateKey, fx.ConfiscatePrivateKey, fx.SupplyPrivateKey, fx.TreasuryAccount.PrivateKey); }); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.StartsWith("Unable to create Token, status: InvalidSignature", tex.Message); }
public async Task AutoRenewAccountIsNotRequired() { await using var fxToken = await TestToken.CreateAsync(_network, fx => { fx.Params.RenewAccount = null; fx.Params.RenewPeriod = null; fx.Params.Signatory = new Signatory(fx.AdminPrivateKey, fx.TreasuryAccount.PrivateKey); }); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Null(info.RenewAccount); }
public async Task EmptySymbolIsNotAllowed() { var aoe = await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { await using var fx = await TestToken.CreateAsync(_network, ctx => { ctx.Params.Symbol = string.Empty; }); }); Assert.Equal("Symbol", aoe.ParamName); Assert.StartsWith("The token symbol must be specified. (Parameter 'Symbol')", aoe.Message); }
public async Task CanMintTokensFromAnyAccountWithSupplyKey() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 100_00_000_000); await using var fxToken = await TestToken.CreateAsync(_network); Assert.NotNull(fxToken.Record); Assert.NotNull(fxToken.Record.Token); Assert.True(fxToken.Record.Token.AccountNum > 0); Assert.Equal(ResponseCode.Success, fxToken.Record.Status); var receipt = await fxToken.Client.MintTokenAsync(fxToken.Record.Token, fxToken.Params.Circulation, fxToken.SupplyPrivateKey, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.Equal(fxToken.Params.Circulation * 2, receipt.Circulation); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Equal(fxToken.Record.Token, info.Token); Assert.Equal(TokenType.Fungible, info.Type); Assert.Equal(fxToken.Params.Symbol, info.Symbol); Assert.Equal(fxToken.TreasuryAccount.Record.Address, info.Treasury); // Note: we doubled the circulation Assert.Equal(fxToken.Params.Circulation * 2, info.Circulation); Assert.Equal(fxToken.Params.Decimals, info.Decimals); Assert.Equal(fxToken.Params.Ceiling, info.Ceiling); Assert.Equal(fxToken.Params.Administrator, info.Administrator); Assert.Equal(fxToken.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxToken.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxToken.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxToken.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(fxToken.Params.RoyaltiesEndorsement, info.RoyaltiesEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.Empty(info.Royalties); Assert.False(info.Deleted); Assert.Equal(fxToken.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ var expectedTreasury = 2 * fxToken.Params.Circulation; Assert.Equal(expectedTreasury, await fxToken.Client.GetAccountTokenBalanceAsync(fxToken.TreasuryAccount, fxToken)); }
public async Task CanAssociateMultipleTokensWithAccountAndGetRecordNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxToken1 = await TestToken.CreateAsync(_network); await using var fxToken2 = await TestToken.CreateAsync(_network); var tokens = new Address[] { fxToken1.Record.Token, fxToken2.Record.Token }; await AssertHg.TokenNotAssociatedAsync(fxToken1, fxAccount); await AssertHg.TokenNotAssociatedAsync(fxToken2, fxAccount); var record = await fxAccount.Client.AssociateTokensWithRecordAsync(tokens, 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); var association = await AssertHg.TokenIsAssociatedAsync(fxToken1, fxAccount); Assert.Equal(fxToken1.Record.Token, association.Token); Assert.Equal(fxToken1.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(fxToken1.Params.Decimals, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); association = await AssertHg.TokenIsAssociatedAsync(fxToken2, fxAccount); Assert.Equal(fxToken2.Record.Token, association.Token); Assert.Equal(fxToken2.Params.Symbol, association.Symbol); Assert.Equal(0UL, association.Balance); Assert.Equal(fxToken2.Params.Decimals, association.Decimals); Assert.Equal(TokenKycStatus.Revoked, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); }
public async Task CanUpdateToken() { await using var fxToken = await TestToken.CreateAsync(_network); await using var fxTemplate = await TestToken.CreateAsync(_network); await fxTemplate.TreasuryAccount.Client.AssociateTokenAsync(fxToken, fxTemplate.TreasuryAccount, fxTemplate.TreasuryAccount); var newSymbol = Generator.UppercaseAlphaCode(20); var newName = Generator.String(20, 50); var updateParams = new UpdateTokenParams { Token = fxToken.Record.Token, Treasury = fxTemplate.Params.Treasury, Administrator = fxTemplate.Params.Administrator, GrantKycEndorsement = fxTemplate.Params.GrantKycEndorsement, SuspendEndorsement = fxTemplate.Params.SuspendEndorsement, ConfiscateEndorsement = fxTemplate.Params.ConfiscateEndorsement, SupplyEndorsement = fxTemplate.Params.SupplyEndorsement, Symbol = newSymbol, Name = newName, Expiration = DateTime.UtcNow.AddDays(90), RenewPeriod = fxTemplate.Params.RenewPeriod, RenewAccount = fxTemplate.RenewAccount, Signatory = new Signatory(fxToken.Params.Signatory, fxTemplate.Params.Signatory), Memo = fxTemplate.Params.Memo }; var receipt = await fxToken.Client.UpdateTokenAsync(updateParams); Assert.Equal(ResponseCode.Success, receipt.Status); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Equal(fxToken.Record.Token, info.Token); Assert.Equal(newSymbol, info.Symbol); Assert.Equal(newName, info.Name); Assert.Equal(fxTemplate.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal(fxToken.Params.Circulation, info.Circulation); Assert.Equal(fxToken.Params.Decimals, info.Decimals); Assert.Equal(fxTemplate.Params.Administrator, info.Administrator); Assert.Equal(fxTemplate.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxTemplate.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxTemplate.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxTemplate.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.Equal(fxTemplate.Params.Memo, info.Memo); Assert.False(info.Deleted); }
public async Task CanGetCreateTokenReceipt() { await using var fx = await TestToken.CreateAsync(_network); var receipt = await fx.Client.GetReceiptAsync(fx.Record.Id); var createReceipt = Assert.IsType <CreateTokenReceipt>(receipt); Assert.Equal(fx.Record.Id, createReceipt.Id); Assert.Equal(fx.Record.Status, createReceipt.Status); Assert.Equal(fx.Record.CurrentExchangeRate, createReceipt.CurrentExchangeRate); Assert.Equal(fx.Record.NextExchangeRate, createReceipt.NextExchangeRate); Assert.Equal(fx.Record.Token, createReceipt.Token); }
public async Task FileAddressAsTreasuryRaisesError() { var fxFile = await TestFile.CreateAsync(_network); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await TestToken.CreateAsync(_network, fx => { fx.Params.Treasury = fxFile.Record.File; }); }); Assert.Equal(ResponseCode.InvalidTreasuryAccountForToken, tex.Status); Assert.StartsWith("Unable to create Token, status: InvalidTreasuryAccountForToken", tex.Message); }
public async Task AssociatingWithDuplicateAccountRaisesError() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network); var pex = await Assert.ThrowsAsync <PrecheckException>(async() => { var tokens = new Address[] { fxToken.Record.Token, fxToken.Record.Token }; await fxToken.Client.AssociateTokensAsync(tokens, fxAccount.Record.Address, fxAccount.PrivateKey); }); Assert.Equal(ResponseCode.TokenIdRepeatedInTokenList, pex.Status); Assert.StartsWith("Transaction Failed Pre-Check: TokenIdRepeatedInTokenList", pex.Message); }
public async Task CanCreateWithReUsedNameFromDeletedToken() { await using var fxTaken = await TestToken.CreateAsync(_network); await fxTaken.Client.DeleteTokenAsync(fxTaken, fxTaken.AdminPrivateKey); await using var fxToken = await TestToken.CreateAsync(_network, fx => { fx.Params.Name = fxTaken.Params.Name; }); Assert.NotNull(fxToken.Record); Assert.NotNull(fxToken.Record.Token); Assert.True(fxToken.Record.Token.AccountNum > 0); Assert.Equal(ResponseCode.Success, fxToken.Record.Status); var info = await fxToken.Client.GetTokenInfoAsync(fxToken.Record.Token); Assert.Equal(fxToken.Record.Token, info.Token); Assert.Equal(fxToken.Params.Symbol, info.Symbol); Assert.Equal(fxToken.Params.Name, info.Name); Assert.Equal(fxToken.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal(fxToken.Params.Circulation, info.Circulation); Assert.Equal(fxToken.Params.Decimals, info.Decimals); Assert.Equal(fxToken.Params.Administrator, info.Administrator); Assert.Equal(fxToken.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxToken.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxToken.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxToken.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.False(info.Deleted); Assert.Equal(fxToken.Params.Memo, info.Memo); var treasury = await fxToken.Client.GetAccountInfoAsync(fxToken.TreasuryAccount.Record.Address); Assert.Equal(fxToken.TreasuryAccount.CreateParams.InitialBalance, treasury.Balance); Assert.Single(treasury.Tokens); var tokens = treasury.Tokens[0]; Assert.Equal(fxToken.Record.Token, tokens.Token); Assert.Equal(fxToken.Params.Symbol, tokens.Symbol); Assert.Equal(fxToken.Params.Circulation, tokens.Balance); Assert.Equal(fxToken.Params.Decimals, tokens.Decimals); Assert.Equal(TokenKycStatus.Granted, tokens.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, tokens.TradableStatus); }
public async Task CanDissociateTokenFromContract() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxContract = await GreetingContract.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); var xferAmount = 2 * fxToken.Params.Circulation / 3; var receipt = await fxContract.Client.AssociateTokenAsync(fxToken.Record.Token, fxContract.ContractRecord.Contract, fxContract.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); var info = await fxAccount.Client.GetContractInfoAsync(fxContract.ContractRecord.Contract); Assert.NotNull(info); var association = info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token); Assert.NotNull(association); 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.NotApplicable, association.KycStatus); Assert.Equal(TokenTradableStatus.Tradable, association.TradableStatus); Assert.False(association.AutoAssociated); receipt = await fxContract.Client.DissociateTokenAsync(fxToken.Record.Token, fxContract.ContractRecord.Contract, fxContract.PrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); info = await fxAccount.Client.GetContractInfoAsync(fxContract.ContractRecord.Contract); Assert.NotNull(info); Assert.Null(info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token)); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxToken.Client.TransferTokensAsync(fxToken.Record.Token, fxToken.TreasuryAccount.Record.Address, fxContract.ContractRecord.Contract, (long)xferAmount, fxToken.TreasuryAccount.PrivateKey); }); Assert.Equal(ResponseCode.TokenNotAssociatedToAccount, tex.Status); Assert.StartsWith("Unable to execute transfers, status: TokenNotAssociatedToAccount", tex.Message); Assert.Equal(0UL, await fxToken.Client.GetContractTokenBalanceAsync(fxContract, fxToken)); }
public async Task AssociatingWithDeletedAccountRaisesError() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network); await fxAccount.Client.DeleteAccountAsync(fxAccount, _network.Payer, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAccount.Client.AssociateTokenAsync(fxToken.Record.Token, fxAccount.Record.Address, fxAccount.PrivateKey); }); Assert.Equal(ResponseCode.AccountDeleted, tex.Status); Assert.StartsWith("Unable to associate Token with Account, status: AccountDeleted", tex.Message); }
public async Task CannotGrantTokenCoinsWhenGrantKYCTurnedOff() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxToken = await TestToken.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null, fxAccount); await AssertHg.TokenStatusAsync(fxToken, fxAccount, TokenKycStatus.NotApplicable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxToken.Client.GrantTokenKycAsync(fxToken.Record.Token, fxAccount, fxToken.GrantPrivateKey); }); Assert.Equal(ResponseCode.TokenHasNoKycKey, tex.Status); Assert.StartsWith("Unable to Grant Token, status: TokenHasNoKycKey", tex.Message); }
public async Task CanDeleteTreasuryAfterDeletingToken() { await using var fx = await TestToken.CreateAsync(_network); var record = await fx.Client.DeleteTokenAsync(fx.Record.Token, fx.AdminPrivateKey); Assert.Equal(ResponseCode.Success, record.Status); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.True(info.Deleted); var receipt = await fx.Client.DeleteAccountAsync(fx.TreasuryAccount.Record.Address, _network.Payer, fx.TreasuryAccount.PrivateKey); Assert.Equal(ResponseCode.Success, record.Status); }
public async Task CallingDeleteWithoutAdminKeyRaisesError() { await using var fx = await TestToken.CreateAsync(_network); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fx.Client.DeleteTokenAsync(fx.Record.Token); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.StartsWith("Unable to Delete Token, status: InvalidSignature", tex.Message); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.False(info.Deleted); }