Beispiel #1
0
        internal static async Task TokenNotAssociatedAsync(TestToken fxToken, TestAccount fxAccount)
        {
            var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount);

            Assert.NotNull(info);

            var association = info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token);

            Assert.Null(association);
        }
Beispiel #2
0
        public static async Task <TestToken> CreateAsync(NetworkCredentials networkCredentials, Action <TestToken> customize = null, params TestAccount[] associate)
        {
            var wholeTokens = (ulong)(Generator.Integer(10, 20) * 100000);
            var decimals    = (uint)Generator.Integer(2, 5);
            var circulation = wholeTokens * (ulong)Math.Pow(10, decimals);
            var fx          = new TestToken
            {
                Network = networkCredentials
            };

            fx.Network.Output?.WriteLine("STARTING SETUP: Test Token Instance");
            (fx.AdminPublicKey, fx.AdminPrivateKey)           = Generator.KeyPair();
            (fx.GrantPublicKey, fx.GrantPrivateKey)           = Generator.KeyPair();
            (fx.SuspendPublicKey, fx.SuspendPrivateKey)       = Generator.KeyPair();
            (fx.ConfiscatePublicKey, fx.ConfiscatePrivateKey) = Generator.KeyPair();
            (fx.SupplyPublicKey, fx.SupplyPrivateKey)         = Generator.KeyPair();
            fx.Payer           = networkCredentials.Payer;
            fx.Client          = networkCredentials.NewClient();
            fx.TreasuryAccount = await TestAccount.CreateAsync(networkCredentials);

            fx.RenewAccount = await TestAccount.CreateAsync(networkCredentials);

            fx.Params = new CreateTokenParams
            {
                Name                  = Generator.Code(50),
                Symbol                = Generator.UppercaseAlphaCode(20),
                Circulation           = circulation,
                Decimals              = decimals,
                Treasury              = fx.TreasuryAccount.Record.Address,
                Administrator         = fx.AdminPublicKey,
                GrantKycEndorsement   = fx.GrantPublicKey,
                SuspendEndorsement    = fx.SuspendPublicKey,
                ConfiscateEndorsement = fx.ConfiscatePublicKey,
                SupplyEndorsement     = fx.SupplyPublicKey,
                InitializeSuspended   = false,
                Expiration            = Generator.TruncatedFutureDate(2000, 3000),
                RenewAccount          = fx.RenewAccount.Record.Address,
                RenewPeriod           = TimeSpan.FromDays(90),
                Signatory             = new Signatory(fx.AdminPrivateKey, fx.RenewAccount.PrivateKey, fx.TreasuryAccount.PrivateKey),
                Memo                  = "Test Token: " + Generator.Code(20)
            };
            customize?.Invoke(fx);
            fx.Record = await fx.Client.CreateTokenWithRecordAsync(fx.Params, ctx =>
            {
                ctx.Memo = "TestToken Setup: " + fx.Params.Symbol ?? "(null symbol)";
            });

            Assert.Equal(ResponseCode.Success, fx.Record.Status);
            await fx.AssociateAccounts(associate);

            networkCredentials.Output?.WriteLine("SETUP COMPLETED: Test Token Instance");
            return(fx);
        }
Beispiel #3
0
        public static async Task TokenStatusAsync(TestToken fxToken, TestAccount fxAccount, TokenKycStatus status)
        {
            var info = await fxAccount.Client.GetAccountInfoAsync(fxAccount);

            Assert.NotNull(info);

            var tokenRecord = info.Tokens.FirstOrDefault(t => t.Token == fxToken.Record.Token);

            Assert.NotNull(tokenRecord);

            Assert.Equal(status, tokenRecord.KycStatus);
        }
Beispiel #4
0
        public static async Task TokenBalanceAsync(TestToken fxToken, TestAccount fxAccount, ulong expectedBalance)
        {
            var balance = await fxToken.Client.GetAccountTokenBalanceAsync(fxAccount, fxToken);

            Assert.Equal(expectedBalance, balance);
        }