Exemplo n.º 1
0
        public void Query(
            [Argument(
                 Name = "TARGET",
#pragma warning disable MEN002 // Line is too long
                 Description = "Comma seperated peer information({pubkey},{host},{port}) of target node. (e.g. 027bd36895d68681290e570692ad3736750ceaab37be402442ffb203967f98f7b6,9c.planetarium.dev,31236)")]
#pragma warning restore MEN002 // Line is too long
            string peerInfo)
        {
            BoundPeer          peer;
            AppProtocolVersion apv;

            try
            {
                peer = BoundPeer.ParsePeer(peerInfo);
            }
            catch
            {
                throw Utils.Error($"Failed to parse peer. Please check the input. [{peerInfo}]");
            }

            try
            {
                apv = peer.QueryAppProtocolVersion();
            }
            catch
            {
                throw Utils.Error($"Failed to query app protocol version.");
            }

            Console.WriteLine(apv.Token);
        }
Exemplo n.º 2
0
        public void ParsePeerException()
        {
            Assert.Throws <ArgumentNullException>(() => { BoundPeer.ParsePeer(null); });
            Assert.Throws <ArgumentException>(() => BoundPeer.ParsePeer(string.Empty));
#pragma warning disable MEN002 // Line is too long
            Assert.Throws <ArgumentException>(() => BoundPeer.ParsePeer("032038e153d344773986c039ba5dbff12ae70cfdf6ea8beb7c5ea9b361a72a9233"));
            Assert.Throws <ArgumentException>(() => BoundPeer.ParsePeer("032038e153d344773986c039ba5dbff12ae70cfdf6ea8beb7c5ea9b361a72a9233,192.168.0.1"));
            Assert.Throws <ArgumentException>(() => BoundPeer.ParsePeer("032038e153d344773986c039ba5dbff12ae70cfdf6ea8beb7c5ea9b361a72a9233,192.168.0.1,999999"));
#pragma warning restore MEN002 // Line is too long
        }
Exemplo n.º 3
0
        public void ParsePeer()
        {
#pragma warning disable MEN002 // Line is too long
            var peerInfo = "032038e153d344773986c039ba5dbff12ae70cfdf6ea8beb7c5ea9b361a72a9233,192.168.0.1,3333";
            var expected = new BoundPeer(
                new PublicKey(ByteUtil.ParseHex("032038e153d344773986c039ba5dbff12ae70cfdf6ea8beb7c5ea9b361a72a9233")),
                new DnsEndPoint("192.168.0.1", 3333)
                );
#pragma warning restore MEN002 // Line is too long
            Assert.Equal(expected, BoundPeer.ParsePeer(peerInfo));
        }