public async Task CanResumeASuspendedAccount() { 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; }, fxAccount); var circulation = fxAsset.Metadata.Length; var xferAmount = circulation / 3; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); }
public async Task CanSuspendAssetTradingFromAnyAccountWithSuspendKey() { await using var fxOther = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); 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; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey, ctx => { ctx.Payer = fxOther.Record.Address; ctx.Signatory = fxOther.PrivateKey; }); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); }
public async Task CanReumeAssetCoinTradingFromAnyAccountWithSuspendKey() { await using var fxOther = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 100_00_000_000); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }, fxAccount); var circulation = fxAsset.Metadata.Length; var xferAmount = circulation / 3; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey, ctx => { ctx.Payer = fxOther.Record.Address; ctx.Signatory = fxOther.PrivateKey; }); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); }
public async Task CannotSuspendAssetWhenFreezeNotEnabled() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.SuspendEndorsement = null; fx.Params.InitializeSuspended = false; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.NotApplicable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); }); Assert.Equal(ResponseCode.TokenHasNoFreezeKey, tex.Status); Assert.Equal(ResponseCode.TokenHasNoFreezeKey, tex.Receipt.Status); Assert.StartsWith("Unable to Suspend Token, status: TokenHasNoFreezeKey", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.NotApplicable); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.NotApplicable); }
public async Task CanNotScheduleSuspendAssetTrading() { await using var fxPayer = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 20_00_000_000); 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; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.SuspendTokenAsync( fxAsset.Record.Token, fxAccount, new Signatory( fxAsset.SuspendPrivateKey, 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 ResumingAnUnfrozenAccountIsNoop() { 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; }, fxAccount); var circulation = (ulong)fxAsset.Metadata.Length; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); var info = (await fxAccount.Client.GetAccountInfoAsync(fxAccount)).Tokens.FirstOrDefault(t => t.Token == fxAsset.Record.Token); Assert.Equal(0Ul, info.Balance); Assert.Equal(0U, info.Decimals); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.False(info.AutoAssociated); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); info = (await fxAccount.Client.GetAccountInfoAsync(fxAccount)).Tokens.FirstOrDefault(t => t.Token == fxAsset.Record.Token); Assert.Equal(1UL, info.Balance); Assert.Equal(0U, info.Decimals); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.False(info.AutoAssociated); }
public async Task CanRevokeTokens() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); 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, 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 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 CanGrantAssetsAndGetRecordWithoutExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); var record = await fxAsset.Client.GrantTokenKycWithRecordAsync(fxAsset.Record.Token, fxAccount, ctx => ctx.Signatory = new Signatory(_network.Signatory, fxAsset.GrantPrivateKey)); 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); 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 RevokeTokenCoinsRequiresGrantKeySignature() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); var circulation = (ulong)fxAsset.Metadata.Length; 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); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.RevokeTokenKycAsync(fxAsset.Record.Token, fxAccount); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Revoke Token, status: InvalidSignature", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Granted); }
public async Task CanReumeAssetCoinTradingAndGetRecordNoExtraSignatory() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }, fxAccount); var circulation = fxAsset.Metadata.Length; var xferAmount = circulation / 3; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var record = await fxAsset.Client.ResumeTokenWithRecordAsync(fxAsset.Record.Token, fxAccount, ctx => ctx.Signatory = new Signatory(_network.Signatory, fxAsset.SuspendPrivateKey)); 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); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); }
public async Task CanNotScheduleRevokeTokenCoins() { await using var fxPayer = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 20_00_000_000); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); var circulation = (ulong)fxAsset.Metadata.Length; 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); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.RevokeTokenKycAsync( fxAsset.Record.Token, fxAccount, new Signatory( fxAsset.GrantPrivateKey, 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 CanRevokeTokenCoinsFromAnyAccountWithGrantKey() { await using var fxOther = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); var circulation = (ulong)fxAsset.Metadata.Length; 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, fxAsset.GrantPrivateKey, ctx => { ctx.Payer = fxOther.Record.Address; ctx.Signatory = fxOther.PrivateKey; }); 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 CanSuspendAResumedAccount() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); }
public async Task CanGrantAssets() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount, 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 CannotGrantAssetCoinsWhenGrantKYCTurnedOff() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.NotApplicable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount, fxAsset.GrantPrivateKey); }); Assert.Equal(ResponseCode.TokenHasNoKycKey, tex.Status); Assert.Equal(ResponseCode.TokenHasNoKycKey, tex.Receipt.Status); Assert.StartsWith("Unable to Grant Token, status: TokenHasNoKycKey", tex.Message); }
public async Task CanReumeAssetCoinTrading() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); }
public async Task ResumeAssetRequiresSuspendKeyToSignTransaction() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = true; }, fxAccount); var circulation = fxAsset.Metadata.Length; var xferAmount = circulation / 3; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Resume Token, status: InvalidSignature", tex.Message); var info = (await fxAccount.Client.GetAccountInfoAsync(fxAccount)).Tokens.FirstOrDefault(t => t.Token == fxAsset.Record.Token); Assert.Equal(0Ul, info.Balance); Assert.Equal(0U, info.Decimals); Assert.Equal(TokenTradableStatus.Suspended, info.TradableStatus); Assert.False(info.AutoAssociated); tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); }
public async Task CanRevokeTokensAndGetRecord() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); var circulation = (ulong)fxAsset.Metadata.Length; 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); var record = await fxAsset.Client.RevokeTokenKycWithRecordAsync(fxAsset.Record.Token, fxAccount, fxAsset.GrantPrivateKey); 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); 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 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 CanGrantAssetCoinsFromWnyAccountWithGrantKey() { await using var fxOther = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, null, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.Revoked); await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount, fxAsset.GrantPrivateKey, ctx => { ctx.Payer = fxOther.Record.Address; ctx.Signatory = fxOther.PrivateKey; }); 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 CanSuspendAssetTradingOfAliasAccountDefect() { // Suspending 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>(CanSuspendAssetTradingOfAliasAccount)); Assert.StartsWith("Unable to Suspend Token, status: InvalidAccountId", testFailException.Message); //[Fact(DisplayName = "Suspend Assets: Can Suspend Asset Trading of Alias Account")] async Task CanSuspendAssetTradingOfAliasAccount() { await using var fxAccount = await TestAliasAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.InitializeSuspended = false; }); await fxAsset.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount, fxAccount.PrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); await fxAsset.Client.SuspendTokenAsync(fxAsset.Record.Token, fxAccount.Alias, fxAsset.SuspendPrivateKey); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount.Alias, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); } }
public async Task CanSuspendAssetTradingAndGetRecord() { 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; }, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Tradable); var record = await fxAsset.Client.SuspendTokenWithRecordAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); 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); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Status); Assert.Equal(ResponseCode.AccountFrozenForToken, tex.Receipt.Status); Assert.StartsWith("Unable to execute transfers, status: AccountFrozenForToken", tex.Message); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.Suspended); }
public async Task CanNotResumeAssetWhenFreezeNotEnabled() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.GrantKycEndorsement = null; fx.Params.SuspendEndorsement = null; fx.Params.InitializeSuspended = false; }, fxAccount); var circulation = fxAsset.Metadata.Length; var xferAmount = circulation / 3; await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.NotApplicable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.ResumeTokenAsync(fxAsset.Record.Token, fxAccount, fxAsset.SuspendPrivateKey); }); Assert.Equal(ResponseCode.TokenHasNoFreezeKey, tex.Status); Assert.Equal(ResponseCode.TokenHasNoFreezeKey, tex.Receipt.Status); Assert.StartsWith("Unable to Resume Token, status: TokenHasNoFreezeKey", tex.Message); var info = (await fxAccount.Client.GetAccountInfoAsync(fxAccount)).Tokens.FirstOrDefault(t => t.Token == fxAsset.Record.Token); Assert.Equal(0Ul, info.Balance); Assert.Equal(0U, info.Decimals); Assert.Equal(TokenTradableStatus.NotApplicable, info.TradableStatus); Assert.False(info.AutoAssociated); await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenTradableStatus.NotApplicable); }