public async Task init_should_load_static_nodes_from_empty_file() { using var tempFile = TempPath.GetTempFile(); await File.WriteAllTextAsync(tempFile.Path, string.Empty); _staticNodesManager = new StaticNodesManager(tempFile.Path, LimboLogs.Instance); await _staticNodesManager.InitAsync(); _staticNodesManager.Nodes.Count().Should().Be(0); }
public async Task init_should_load_static_nodes_from_empty_file() { var path = Path.GetTempFileName(); await File.WriteAllTextAsync(path, string.Empty); try { _staticNodesManager = new StaticNodesManager(path, LimboLogs.Instance); await _staticNodesManager.InitAsync(); _staticNodesManager.Nodes.Count().Should().Be(0); } finally { File.Delete(path); } }
private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HelloMessageSerializer))); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Ecdsa(), _nodeKey, _logManager); var networkConfig = _configProvider.GetConfig <INetworkConfig>(); var discoveryConfig = _configProvider.GetConfig <IDiscoveryConfig>(); _sessionMonitor = new SessionMonitor(networkConfig, _logManager); _rlpxPeer = new RlpxPeer( _nodeKey.PublicKey, _initConfig.P2PPort, encryptionHandshakeServiceA, _logManager, _sessionMonitor); await _rlpxPeer.Init(); _staticNodesManager = new StaticNodesManager(_initConfig.StaticNodesPath, _logManager); await _staticNodesManager.InitAsync(); var peersDb = new SimpleFilePublicKeyDb(PeersDbPath, _logManager); var peerStorage = new NetworkStorage(peersDb, _logManager); ProtocolValidator protocolValidator = new ProtocolValidator(_nodeStatsManager, _blockTree, _logManager); _protocolsManager = new ProtocolsManager(_syncPeerPool, _syncServer, _txPool, _discoveryApp, _messageSerializationService, _rlpxPeer, _nodeStatsManager, protocolValidator, peerStorage, _perfService, _logManager); PeerLoader peerLoader = new PeerLoader(networkConfig, discoveryConfig, _nodeStatsManager, peerStorage, _logManager); _peerManager = new PeerManager(_rlpxPeer, _discoveryApp, _nodeStatsManager, peerStorage, peerLoader, networkConfig, _logManager, _staticNodesManager); _peerManager.Init(); }
public async Task init_should_load_static_nodes_from_the_file() { await _staticNodesManager.InitAsync(); _staticNodesManager.Nodes.Count().Should().Be(2); }
private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HelloMessageSerializer))); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Ecdsa(), _nodeKey, _logManager); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HiMessageSerializer))); var networkConfig = _configProvider.GetConfig <INetworkConfig>(); var discoveryConfig = _configProvider.GetConfig <IDiscoveryConfig>(); _sessionMonitor = new SessionMonitor(networkConfig, _logManager); _rlpxPeer = new RlpxPeer( _nodeKey.PublicKey, _initConfig.P2PPort, encryptionHandshakeServiceA, _logManager, _sessionMonitor); await _rlpxPeer.Init(); _staticNodesManager = new StaticNodesManager(_initConfig.StaticNodesPath, _logManager); await _staticNodesManager.InitAsync(); var peersDb = new SimpleFilePublicKeyDb(Path.Combine(_initConfig.BaseDbPath, PeersDbPath), _logManager); var peerStorage = new NetworkStorage(peersDb, _logManager); ProtocolValidator protocolValidator = new ProtocolValidator(_nodeStatsManager, _blockTree, _logManager); _protocolsManager = new ProtocolsManager(_syncPeerPool, _syncServer, _txPool, _discoveryApp, _messageSerializationService, _rlpxPeer, _nodeStatsManager, protocolValidator, peerStorage, _perfService, _logManager); if (!(_ndmInitializer is null)) { if (_logger.IsInfo) { _logger.Info($"Initializing NDM..."); } var capabilityConnector = await _ndmInitializer.InitAsync(_configProvider, _dbProvider, _initConfig.BaseDbPath, _blockProcessor, _blockTree, _txPool, _txPoolInfoProvider, _specProvider, _receiptStorage, _wallet, _timestamp, _ethereumEcdsa, _rpcModuleProvider, _keyStore, _jsonSerializer, _cryptoRandom, _enode, _ndmConsumerChannelManager, _ndmDataPublisher, _grpcService, _nodeStatsManager, _protocolsManager, protocolValidator, _messageSerializationService, _initConfig.EnableUnsecuredDevWallet, _logManager); capabilityConnector.Init(); if (_logger.IsInfo) { _logger.Info($"NDM initialized."); } } PeerLoader peerLoader = new PeerLoader(networkConfig, discoveryConfig, _nodeStatsManager, peerStorage, _logManager); _peerManager = new PeerManager(_rlpxPeer, _discoveryApp, _nodeStatsManager, peerStorage, peerLoader, networkConfig, _logManager, _staticNodesManager); _peerManager.Init(); }