Exemplo n.º 1
0
        public void PeerManagerTestsSimple()
        {
            var socketFactory = new SocketDescriptorFactory();

            using var peerMan = getTestPeerManager();
            var socket1 = socketFactory.GetNewSocket();

            peerMan.NewInboundConnection(socket1);
            var socket2      = socketFactory.GetNewSocket();
            var theirNodeId  = _pubKeys[1];
            var theirNodeIds = peerMan.GetPeerNodeIds(_pool);

            Assert.Empty(theirNodeIds);
            var actOne = peerMan.NewOutboundConnection(socket2, theirNodeId.ToBytes());

            Assert.Equal(50, actOne.Length);
            // Console.WriteLine($"actOne in C# is {Hex.EncodeData(actOne)}");

            theirNodeIds = peerMan.GetPeerNodeIds(_pool);
            // It does not count when handshake is not complete
            Assert.Empty(theirNodeIds);
            peerMan.Dispose();
        }