Ejemplo n.º 1
0
        public void TestRpcVersion()
        {
            JObject json = TestUtils.RpcTestCases.Find(p => p.Name == nameof(RpcClient.GetVersionAsync).ToLower()).Response.Result;
            var     item = RpcVersion.FromJson(json);

            Assert.AreEqual(json.ToString(), item.ToJson().ToString());
        }
Ejemplo n.º 2
0
 public RpcProgramHeader(RpcVersion rpcVersion, UInt32 program, UInt32 programVersion)
     : base(memberSerializers)
 {
     this.rpcVersion     = (UInt32)rpcVersion;
     this.program        = program;
     this.programVersion = programVersion;
 }
Ejemplo n.º 3
0
        public void TestToJson()
        {
            var version = new RpcVersion()
            {
                TcpPort   = 800,
                WsPort    = 900,
                Nonce     = 1,
                UserAgent = "agent"
            };
            var json = version.ToJson();

            json["topPort"].AsNumber().Should().Be(800);
            json["wsPort"].AsNumber().Should().Be(900);
            json["nonce"].AsNumber().Should().Be(1);
            json["useragent"].AsString().Should().Be("agent");
        }
Ejemplo n.º 4
0
        static async Task <ProtocolSettings> GetProtocolSettingsAsync(Uri uri)
        {
            using var rpcClient = new RpcClient(uri);
            var result = await rpcClient.RpcSendAsync("getversion").ConfigureAwait(false);

            if (result["protocol"] == null)
            {
                var userAgent = result["useragent"].AsString();
                throw new NotSupportedException($"Trace not supported by {userAgent} running on {uri}");
            }

            var version = RpcVersion.FromJson(result);

            return(ProtocolSettings.Default with
            {
                AddressVersion = version.Protocol.AddressVersion,
                InitialGasDistribution = version.Protocol.InitialGasDistribution,
                MaxTraceableBlocks = version.Protocol.MaxTraceableBlocks,
                MaxTransactionsPerBlock = version.Protocol.MaxTransactionsPerBlock,
                MemoryPoolMaxTransactions = version.Protocol.MemoryPoolMaxTransactions,
                MillisecondsPerBlock = version.Protocol.MillisecondsPerBlock,
                Network = version.Protocol.Network,
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns the version information about the queried node.
        /// </summary>
        public async Task <RpcVersion> GetVersionAsync()
        {
            var result = await RpcSendAsync(GetRpcName()).ConfigureAwait(false);

            return(RpcVersion.FromJson(result));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns the version information about the queried node.
 /// </summary>
 public RpcVersion GetVersion()
 {
     return(RpcVersion.FromJson(RpcSend("getversion")));
 }
Ejemplo n.º 7
0
        public static RpcVersion GetVersion(this RpcClient rpcClient)
        {
            var result = rpcClient.RpcSend(RpcClient.GetRpcName());

            return(RpcVersion.FromJson(result));
        }