示例#1
0
        public async Task get_block()
        {
            var args = new GetBlockArgs
            {
                BlockNum = 22054347
            };
            var resp = await Api.CondenserGetBlock(args, CancellationToken.None);

            TestPropetries(resp);
        }
示例#2
0
        public async Task get_block()
        {
            var args = new GetBlockArgs
            {
                BlockNum = 1
            };
            var resp = await Api.GetBlockAsync(args, CancellationToken.None).ConfigureAwait(false);

            TestPropetries(resp);
        }
示例#3
0
        public void get_block()
        {
            var args = new GetBlockArgs()
            {
                BlockNum = 1
            };
            var resp = Api.GetBlock(args, CancellationToken.None);

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

            var obj = Api.CustomGetRequest <JObject>(KnownApiNames.BlockApi, "get_block", args, CancellationToken.None);

            TestPropetries(resp.Result.GetType(), obj.Result);
            WriteLine("----------------------------------------------------------------------------");
            WriteLine(obj);
        }
示例#4
0
 /// <summary>
 /// API name: get_block
 /// Retrieve a full, signed block
 ///
 ///
 /// </summary>
 /// <param name="args">API type: get_block_args</param>
 /// <param name="token">Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.</param>
 /// <returns>API type: get_block_return the referenced block, or null if no matching block was found</returns>
 /// <exception cref="T:System.OperationCanceledException">The token has had cancellation requested.</exception>
 public Task <JsonRpcResponse <GetBlockReturn> > GetBlock(GetBlockArgs args, CancellationToken token)
 {
     return(CustomGetRequest <GetBlockReturn>(KnownApiNames.BlockApi, "get_block", args, token));
 }
示例#5
0
 //  "condenser_api.get_block",
 public Task <JsonRpcResponse <GetBlockReturn> > CondenserGetBlockAsync(GetBlockArgs args, CancellationToken token)
 {
     return(CondenserCustomGetRequestAsync <GetBlockReturn>(KnownApiNames.CondenserApi, "get_block", args, token));
 }
示例#6
0
        //[TestCase("https://steemd2.steepshot.org")]
        //[TestCase("https://steemd.steepshot.org")]
        public async Task NodeTest(string url)
        {
            var token = CancellationToken.None;

            var sw = new Stopwatch();

            sw.Start();
            try
            {
                var isConnected = await Api
                                  .ConnectToAsync(url, token)
                                  .ConfigureAwait(false);

                Assert.IsTrue(isConnected, $"1 - DOWN {sw.ElapsedMilliseconds}");
            }
            catch (AssertionException)
            {
                throw;
            }
            catch (Exception e)
            {
                Assert.Fail($"1 - DOWN {sw.ElapsedMilliseconds}");
                return;
            }

            var configResp = await Api
                             .GetConfigAsync <JObject>(token)
                             .ConfigureAwait(false);

            Assert.IsFalse(configResp.IsError, $"2 - NO CONFIG {sw.ElapsedMilliseconds}");

            var conf = configResp.Result;

            var isTestNet = conf.Value <bool>("IS_TEST_NET");

            Assert.IsFalse(isTestNet, "3 - Testnet");

            var version = configResp.Result.Value <string>("STEEM_BLOCKCHAIN_VERSION");

            if (string.IsNullOrEmpty(version))
            {
                version = configResp.Result.Value <string>("STEEMIT_BLOCKCHAIN_VERSION");
            }

            Assert.IsFalse(string.IsNullOrEmpty(version), "4 - no version");
            Assert.IsTrue(new Regex("^0.20.[0-9]{1,2}$").IsMatch(version), "5 - not supported version");
            WriteLine(version);

            var args = new GetBlockArgs
            {
                BlockNum = 28000000
            };
            var block = await Api
                        .GetBlockAsync(args, CancellationToken.None)
                        .ConfigureAwait(false);

            Assert.IsFalse(block.IsError, "6 - get block error");

            var testDir  = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory));
            var testFile = Path.Combine(testDir, "TestBlock28000000.txt");

            Assert.IsTrue(File.Exists(testFile), "test file not exist!");

            var validJson = File.ReadAllText(testFile);
            var t         = JsonBeautify(block.RawResponse);

            Assert.IsTrue(t.Contains(validJson), $"7 - block validation fail{Environment.NewLine}{t}");

            WriteLine($"time (mls): {sw.ElapsedMilliseconds}");
            Assert.IsTrue(Api.IsConnected);
        }