예제 #1
0
        public void SendFindNode(byte[] searchedNodeId)
        {
            var msg = _discoveryMessageFactory.CreateOutgoingMessage <FindNodeMessage>(ManagedNode);

            msg.SearchedNodeId   = searchedNodeId;
            _isNeighborsExpected = true;
            _discoveryManager.SendMessage(msg);
            NodeStats.AddNodeStatsEvent(NodeStatsEventType.DiscoveryFindNodeOut);
        }
예제 #2
0
        public async Task sending_ping_recieving_proper_pong_sets_bounded()
        {
            var node        = new Node(_host, _port);
            var nodeManager = new NodeLifecycleManager(node, _discoveryManagerMock
                                                       , _nodeTable, new DiscoveryMessageFactory(_timestamper), _evictionManagerMock, _nodeStatsMock, _discoveryConfigMock, _loggerMock);

            var sentPing = new PingMessage();

            _discoveryManagerMock.SendMessage(Arg.Do <PingMessage>(msg => sentPing = msg));

            await nodeManager.SendPingAsync();

            nodeManager.ProcessPongMessage(new PongMessage {
                PingMdc = sentPing.Mdc
            });

            Assert.IsTrue(nodeManager.IsBonded);
        }
예제 #3
0
    private void SendEnrRequest()
    {
        EnrRequestMsg msg = new (ManagedNode.Address, CalculateExpirationTime());

        _discoveryManager.SendMessage(msg);
        NodeStats.AddNodeStatsEvent(NodeStatsEventType.DiscoveryEnrRequestOut);
    }
        public void SendFindNode(byte[] searchedNodeId)
        {
            if (!IsBonded)
            {
                if (_logger.IsDebug)
                {
                    _logger.Debug($"Sending FIND NODE on {ManagedNode} before bonding");
                }
            }

            if (DateTime.UtcNow - _lastTimeSendFindNode < TimeSpan.FromSeconds(60))
            {
                return;
            }

            FindNodeMessage msg = _discoveryMessageFactory.CreateOutgoingMessage <FindNodeMessage>(ManagedNode);

            msg.SearchedNodeId   = searchedNodeId;
            _isNeighborsExpected = true;
            _discoveryManager.SendMessage(msg);
            NodeStats.AddNodeStatsEvent(NodeStatsEventType.DiscoveryFindNodeOut);
        }
예제 #5
0
        public async Task sending_ping_receiving_proper_pong_sets_bounded()
        {
            Node node = new(TestItem.PublicKeyB, _host, _port);
            NodeLifecycleManager nodeManager = new(node, _discoveryManagerMock
                                                   , _nodeTable, _evictionManagerMock, _nodeStatsMock, new NodeRecord(), _discoveryConfigMock, Timestamper.Default, _loggerMock);

            byte[]  mdc      = new byte[32];
            PingMsg?sentPing = null;

            _discoveryManagerMock.SendMessage(Arg.Do <PingMsg>(msg =>
            {
                msg.Mdc  = mdc;
                sentPing = msg;
            }));

            await nodeManager.SendPingAsync();

            nodeManager.ProcessPongMsg(new PongMsg(node.Address, GetExpirationTime(), sentPing !.Mdc !));

            Assert.IsTrue(nodeManager.IsBonded);
        }