Пример #1
0
        private void OnCommandAccounts(string[] args)
        {
            Task.Run(async() =>
            {
                foreach (var entry in wallets)
                {
                    var o          = new JObject();
                    string name    = entry.Key;
                    string address = entry.Value.Address;

                    (ulong?balance, string error) = await web4b.GetBalanceAsync(address, Be4Helper.LATEST);

                    o.Put <string>("name", name);
                    o.Put <string>("address", address);
                    o.Put <string>("balance", Coin.ToCoin(balance ?? 0).ToString("N"));

                    BConsole.WriteLine(o);
                }
            });
        }
Пример #2
0
        public async Task ShouldPassBe4CallTest()
        {
            string  error;
            Address coinbase;
            long    number;
            H256    hash;
            ulong?  balance, nonce;
            JObject block, block1;
            int     count;

            // be4_coinbase
            (coinbase, error) = await be4.GetCoinbaseAsync();

            Assert.True(string.IsNullOrEmpty(error));
            Assert.False(string.IsNullOrEmpty(coinbase));

            // be4_blockNumber
            (number, error) = await be4.GetBlockNumberAsync();

            Assert.True(string.IsNullOrEmpty(error));

            // be4_getBalance ( earliest )
            (balance, error) = await be4.GetBalanceAsync(coinbase, Be4Helper.EARLIEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // be4_getBalance ( latest )
            (balance, error) = await be4.GetBalanceAsync(coinbase, Be4Helper.LATEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // be4_getBalance ( pending )
            (balance, error) = await be4.GetBalanceAsync(coinbase, Be4Helper.PENDING);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // be4_getBalance ( number )
            (balance, error) = await be4.GetBalanceAsync(coinbase, Hex.ToString(number, true));

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // be4_getTransactionCount ( earliest )
            (nonce, error) = await be4.GetTransactionCountAsync(coinbase, Be4Helper.EARLIEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // be4_getTransactionCount ( latest )
            (nonce, error) = await be4.GetTransactionCountAsync(coinbase, Be4Helper.LATEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // be4_getTransactionCount ( pending )
            (nonce, error) = await be4.GetTransactionCountAsync(coinbase, Be4Helper.PENDING);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // be4_getBalance ( number )
            (nonce, error) = await be4.GetTransactionCountAsync(coinbase, Hex.ToString(number, true));

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // be4_getBlockByNumber / be4_getBlockByHash
            (block, error) = await be4.GetBlockByNumberAsync(number, true);

            Assert.True(string.IsNullOrEmpty(error));

            hash = block.Value <string>("hash");

            (block1, error) = await be4.GetBlockByHashAsync(block.Value <string>("hash"), true);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.Equal(block.Value <string>("hash"), block1.Value <string>("hash"));

            // be4_getBlockTransactionCountByHash
            (count, error) = await be4.GetBlockTransactionCountByHashAsync(hash);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.True(count >= 0);

            // be4_getBlockTransactionCountByNumber
            (count, error) = await be4.GetBlockTransactionCountByNumberAsync(number);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.True(count >= 0);
        }