Ejemplo n.º 1
0
        public async Task Buyram_SuccessTest()
        {
            var op = new BuyramAction
            {
                Account = BuyramAction.ContractName,
                Args    = new Buyram
                {
                    Payer    = User.Login,
                    Receiver = User.Login,
                    Quant    = new Asset("100.0000 EOS")
                },
                Authorization = new[]
                {
                    new PermissionLevel
                    {
                        Actor      = User.Login,
                        Permission = "active"
                    }
                }
            };

            var resp = await Api.BroadcastActionsAsync(new[] { op }, new List <byte[]> {
                User.PrivateActiveKey
            }, CancellationToken).ConfigureAwait(false);

            WriteLine(resp);
            Assert.IsFalse(resp.IsError);
        }
Ejemplo n.º 2
0
        public async Task BroadcastActionsTest()
        {
            var op = new BuyramAction
            {
                Account = User.Login,

                Args = new Buyram
                {
                    Payer    = User.Login,
                    Receiver = User.Login,
                    Quant    = new Asset("0.001 EOS")
                },
                Authorization = new[]
                {
                    new PermissionLevel
                    {
                        Actor      = User.Login,
                        Permission = "active"
                    }
                }
            };

            await Api.WalletOpenAsync(User.Login, CancellationToken).ConfigureAwait(false);

            await Api.WalletUnlockAsync(User.Login, User.Password, CancellationToken).ConfigureAwait(false);

            var resp = await Api.BroadcastActionsWithWalletAsync(new[] { op }, new[] { new PublicKey(User.PublicActiveWif) }, CancellationToken).ConfigureAwait(false);

            await Api.WalletLockAsync(User.Login, CancellationToken).ConfigureAwait(false);

            WriteLine(resp);
            Assert.IsFalse(resp.IsError);
        }
Ejemplo n.º 3
0
        public async Task BroadcastWithScatterTest()
        {
            var op = new BuyramAction
            {
                Account = User.Login,

                Args = new Buyram
                {
                    Payer    = User.Login,
                    Receiver = User.Login,
                    Quant    = new Asset("0.001 EOS")
                },
                Authorization = new[]
                {
                    new PermissionLevel
                    {
                        Actor      = User.Login,
                        Permission = "active"
                    }
                }
            };

            var resp = await Api.BroadcastActionsAsync(new[] { op }, new[] { new PublicKey(User.PublicActiveWif) }, SigningWithEosWallet, CancellationToken).ConfigureAwait(false);

            WriteLine(resp);
            Assert.IsFalse(resp.IsError);

            resp = await Api.BroadcastActionsAsync(new[] { op }, new[] { new PublicKey(User.PublicActiveWif) }, SigningWithScatter, CancellationToken).ConfigureAwait(false);

            WriteLine(resp);
            Assert.IsFalse(resp.IsError);
        }
Ejemplo n.º 4
0
        public async Task SignTransactionTest()
        {
            var op = new BuyramAction
            {
                Account = User.Login,

                Args = new Buyram
                {
                    Payer    = User.Login,
                    Receiver = User.Login,
                    Quant    = new Asset("0.001 EOS")
                },
                Authorization = new[]
                {
                    new PermissionLevel
                    {
                        Actor      = User.Login,
                        Permission = "active"
                    }
                }
            };

            var initOpRez = await Api.AbiJsonToBinAsync(new[] { op }, CancellationToken).ConfigureAwait(false);

            if (initOpRez.IsError)
            {
                WriteLine(initOpRez);
                Assert.Fail();
            }

            var infoResp = await Api.GetInfoAsync(CancellationToken).ConfigureAwait(false);

            if (infoResp.IsError)
            {
                WriteLine(infoResp);
                Assert.Fail();
            }

            var info = infoResp.Result;

            var blockArgs = new GetBlockParams
            {
                BlockNumOrId = info.HeadBlockId
            };
            var getBlock = await Api.GetBlockAsync(blockArgs, CancellationToken).ConfigureAwait(false);

            if (getBlock.IsError)
            {
                WriteLine(getBlock);
                Assert.Fail();
            }

            var block = getBlock.Result;

            var trx = new SignedTransaction
            {
                Actions        = new[] { op },
                RefBlockNum    = (ushort)(block.BlockNum & 0xffff),
                RefBlockPrefix = block.RefBlockPrefix,
                Expiration     = block.Timestamp.Value.AddSeconds(30)
            };


            await Api.WalletOpenAsync(User.Login, CancellationToken).ConfigureAwait(false);

            await Api.WalletUnlockAsync(User.Login, User.Password, CancellationToken).ConfigureAwait(false);

            var resp = await Api.WalletSignTransactionAsync(trx, new[] { new PublicKey(User.PublicActiveWif), }, info.ChainId, CancellationToken.None).ConfigureAwait(false);

            await Api.WalletLockAsync(User.Login, CancellationToken).ConfigureAwait(false);

            WriteLine(resp);

            Assert.IsFalse(resp.IsError);
            Assert.IsTrue(resp.Result.Signatures.Length == 1);
        }