private void InitRlp() { /* this is to invoke decoder registrations that happen in their static constructor * looks like this will be quite a long term temporary solution (2018.11.27)*/ ParityTraceDecoder.Init(); NetworkNodeDecoder.Init(); }
public void Initialize() { NetworkNodeDecoder.Init(); SetupNodeIds(); var logManager = NullLogManager.Instance; //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket _configurationProvider = new ConfigProvider(); INetworkConfig networkConfig = _configurationProvider.GetConfig <INetworkConfig>(); networkConfig.PongTimeout = 50; networkConfig.BucketSize = 3; networkConfig.BucketsCount = 1; IKeyStoreConfig keyStoreConfig = _configurationProvider.GetConfig <IKeyStoreConfig>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var calculator = new NodeDistanceCalculator(networkConfig); _nodeTable = new NodeTable(new FileKeyStore(keyStoreConfig, new EthereumJsonSerializer(), new AesEncrypter(keyStoreConfig, logManager), new CryptoRandom(), logManager), calculator, networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _timestamp = new Timestamp(); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(networkConfig, _timestamp), evictionManager, new NodeStatsManager(statsConfig, logManager), networkConfig, logManager); _udpClient = Substitute.For <IMessageSender>(); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage("test", networkConfig, logManager, new PerfService(logManager)), networkConfig, logManager); _discoveryManager.MessageSender = _udpClient; }
public void Initialize() { NetworkNodeDecoder.Init(); var privateKey = new PrivateKey(TestPrivateKeyHex); _publicKey = privateKey.PublicKey; var logManager = NullLogManager.Instance; IDiscoveryConfig discoveryConfig = new DiscoveryConfig(); discoveryConfig.PongTimeout = 100; IStatsConfig statsConfig = new StatsConfig(); _messageSender = Substitute.For <IMessageSender>(); var calculator = new NodeDistanceCalculator(discoveryConfig); _nodeTable = new NodeTable(calculator, discoveryConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _timestamp = new Timestamp(); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(_timestamp), evictionManager, new NodeStatsManager(statsConfig, logManager), discoveryConfig, logManager); _nodes = new[] { new Node("192.168.1.18", 1), new Node("192.168.1.19", 2) }; IFullDb nodeDb = new SimpleFilePublicKeyDb("test_db", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(nodeDb, logManager), discoveryConfig, logManager); _discoveryManager.MessageSender = _messageSender; }
public void Initialize() { NetworkNodeDecoder.Init(); var privateKey = new PrivateKey(TestPrivateKeyHex); _publicKey = privateKey.PublicKey; var logManager = NullLogManager.Instance; //var config = new NetworkConfigurationProvider(new NetworkHelper(logger)) { PongTimeout = 100 }; var config = new JsonConfigProvider(); var networkConfig = config.GetConfig <INetworkConfig>(); networkConfig.PongTimeout = 100; var statsConfig = config.GetConfig <IStatsConfig>(); _messageSender = Substitute.For <IMessageSender>(); _nodeFactory = new NodeFactory(LimboLogs.Instance); var calculator = new NodeDistanceCalculator(config); _nodeTable = new NodeTable(_nodeFactory, new FileKeyStore(config, new JsonSerializer(logManager), new AesEncrypter(config, logManager), new CryptoRandom(), logManager), calculator, config, logManager); _nodeTable.Initialize(); _timestamp = new Timestamp(); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeFactory, _nodeTable, new DiscoveryMessageFactory(config, _timestamp), evictionManager, new NodeStatsProvider(statsConfig, _nodeFactory, logManager), config, logManager); _nodes = new[] { _nodeFactory.CreateNode("192.168.1.18", 1), _nodeFactory.CreateNode("192.168.1.19", 2) }; _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeFactory, _nodeTable, new NetworkStorage("test", networkConfig, logManager, new PerfService(logManager)), config, logManager); _discoveryManager.MessageSender = _messageSender; }
public void Initialize() { NetworkNodeDecoder.Init(); SetupNodeIds(); var logManager = NullLogManager.Instance; //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket _configurationProvider = new ConfigProvider(); IDiscoveryConfig discoveryConfig = _configurationProvider.GetConfig <IDiscoveryConfig>(); discoveryConfig.PongTimeout = 50; discoveryConfig.BucketSize = 3; discoveryConfig.BucketsCount = 1; IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var calculator = new NodeDistanceCalculator(discoveryConfig); _nodeTable = new NodeTable(calculator, discoveryConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _timestamp = new Timestamp(); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(_timestamp), evictionManager, new NodeStatsManager(statsConfig, logManager), discoveryConfig, logManager); _udpClient = Substitute.For <IMessageSender>(); var discoveryDb = new SimpleFilePublicKeyDb("test", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(discoveryDb, logManager), discoveryConfig, logManager); _discoveryManager.MessageSender = _udpClient; }
public void Initialize() { NetworkNodeDecoder.Init(); PrivateKey privateKey = new(TestPrivateKeyHex); _publicKey = privateKey.PublicKey; LimboLogs?logManager = LimboLogs.Instance; IDiscoveryConfig discoveryConfig = new DiscoveryConfig(); discoveryConfig.PongTimeout = 100; _msgSender = Substitute.For <IMsgSender>(); NodeDistanceCalculator calculator = new(discoveryConfig); _networkConfig.ExternalIp = "99.10.10.66"; _networkConfig.LocalIp = "10.0.0.5"; _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); EvictionManager evictionManager = new(_nodeTable, logManager); ITimerFactory timerFactory = Substitute.For <ITimerFactory>(); NodeLifecycleManagerFactory lifecycleFactory = new(_nodeTable, evictionManager, new NodeStatsManager(timerFactory, logManager), new NodeRecord(), discoveryConfig, Timestamper.Default, logManager); _nodes = new[] { new Node(TestItem.PublicKeyA, "192.168.1.18", 1), new Node(TestItem.PublicKeyB, "192.168.1.19", 2) }; IFullDb nodeDb = new SimpleFilePublicKeyDb("Test", "test_db", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(nodeDb, logManager), discoveryConfig, logManager); _discoveryManager.MsgSender = _msgSender; }
public void Initialize() { NetworkNodeDecoder.Init(); var privateKey = new PrivateKey(TestPrivateKeyHex); _publicKey = privateKey.PublicKey; var logManager = NullLogManager.Instance; IKeyStoreConfig keyStoreConfig = new KeyStoreConfig(); INetworkConfig networkConfig = new NetworkConfig(); networkConfig.PongTimeout = 100; IStatsConfig statsConfig = new StatsConfig(); _messageSender = Substitute.For <IMessageSender>(); var calculator = new NodeDistanceCalculator(networkConfig); _nodeTable = new NodeTable(new FileKeyStore(keyStoreConfig, new EthereumJsonSerializer(), new AesEncrypter(keyStoreConfig, logManager), new CryptoRandom(), logManager), calculator, networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _timestamp = new Timestamp(); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(networkConfig, _timestamp), evictionManager, new NodeStatsManager(statsConfig, logManager), networkConfig, logManager); _nodes = new[] { new Node("192.168.1.18", 1), new Node("192.168.1.19", 2) }; _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage("test", networkConfig, logManager, new PerfService(logManager)), networkConfig, logManager); _discoveryManager.MessageSender = _messageSender; }
public void Initialize() { NetworkNodeDecoder.Init(); var privateKey = new PrivateKey(TestPrivateKeyHex); _publicKey = privateKey.PublicKey; var logManager = LimboLogs.Instance; IDiscoveryConfig discoveryConfig = new DiscoveryConfig(); discoveryConfig.PongTimeout = 100; _messageSender = Substitute.For <IMessageSender>(); var calculator = new NodeDistanceCalculator(discoveryConfig); _networkConfig.ExternalIp = "99.10.10.66"; _networkConfig.LocalIp = "10.0.0.5"; _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _timestamper = Timestamper.Default; _ipResolver = new IPResolver(_networkConfig, logManager); var evictionManager = new EvictionManager(_nodeTable, logManager); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(_timestamper), evictionManager, new NodeStatsManager(logManager), discoveryConfig, logManager); _nodes = new[] { new Node("192.168.1.18", 1), new Node("192.168.1.19", 2) }; IFullDb nodeDb = new SimpleFilePublicKeyDb("Test", "test_db", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(nodeDb, logManager), discoveryConfig, logManager, _ipResolver); _discoveryManager.MessageSender = _messageSender; }
public void SetUp() { NetworkNodeDecoder.Init(); ILogManager logManager = LimboLogs.Instance; ConfigProvider configSource = new ConfigProvider(); _tempDir = TempPath.GetTempDirectory(); var db = new SimpleFilePublicKeyDb("Test", _tempDir.Path, logManager); _storage = new NetworkStorage(db, logManager); }
public void Initialize() { NetworkNodeDecoder.Init(); _timestamp = new Timestamp(); _logManager = new OneLoggerLogManager(new SimpleConsoleLogger()); _configurationProvider = new ConfigProvider(); INetworkConfig networkConfig = _configurationProvider.GetConfig <INetworkConfig>(); networkConfig.DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests"); networkConfig.IsActivePeerTimerEnabled = false; networkConfig.IsDiscoveryNodesPersistenceOn = false; networkConfig.IsPeersPersistenceOn = false; if (!Directory.Exists(networkConfig.DbBasePath)) { Directory.CreateDirectory(networkConfig.DbBasePath); } var syncManager = Substitute.For <ISynchronizationManager>(); Block genesisBlock = Build.A.Block.Genesis.TestObject; syncManager.Head.Returns(genesisBlock.Header); syncManager.Genesis.Returns(genesisBlock.Header); _nodeFactory = new NodeFactory(LimboLogs.Instance); _localPeer = new TestRlpxPeer(); var keyProvider = new PrivateKeyGenerator(new CryptoRandom()); var key = keyProvider.Generate().PublicKey; _synchronizationManager = Substitute.For <ISynchronizationManager>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var nodeTable = new NodeTable(_nodeFactory, Substitute.For <IKeyStore>(), new NodeDistanceCalculator(networkConfig), networkConfig, _logManager); nodeTable.Initialize(new NodeId(key)); _discoveryManager = new DiscoveryManager(new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, new DiscoveryMessageFactory(networkConfig, _timestamp), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider.GetConfig <IStatsConfig>(), _nodeFactory, _logManager, true), networkConfig, _logManager), _nodeFactory, nodeTable, new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)), networkConfig, _logManager); _discoveryManager.MessageSender = Substitute.For <IMessageSender>(); _transactionPool = NullTransactionPool.Instance; _blockTree = Substitute.For <IBlockTree>(); var app = new DiscoveryApp(new NodesLocator(nodeTable, _discoveryManager, _configurationProvider, _logManager), _discoveryManager, _nodeFactory, nodeTable, Substitute.For <IMessageSerializationService>(), new CryptoRandom(), Substitute.For <INetworkStorage>(), networkConfig, _logManager, new PerfService(_logManager)); app.Initialize(key); var sessionLogger = new PeerSessionLogger(_logManager, _configurationProvider, new PerfService(_logManager)); sessionLogger.Init(Path.GetTempPath()); var networkStorage = new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)); _peerManager = new PeerManager(_localPeer, app, _synchronizationManager, new NodeStatsProvider(statsConfig, _nodeFactory, _logManager, true), networkStorage, _nodeFactory, _configurationProvider, new PerfService(_logManager), _transactionPool, _logManager, sessionLogger); _peerManager.Init(true); }
public void SetUp() { NetworkNodeDecoder.Init(); NullLogManager logManager = NullLogManager.Instance; ConfigProvider configSource = new ConfigProvider(); _tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); _statsConfig = configSource.GetConfig <IStatsConfig>(); var db = new SimpleFilePublicKeyDb("Test", _tempDir, logManager); _storage = new NetworkStorage(db, logManager); }
public void SetUp() { NetworkNodeDecoder.Init(); NullLogManager logManager = NullLogManager.Instance; ConfigProvider configSource = new ConfigProvider(); _tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); _networkConfig = configSource.GetConfig <INetworkConfig>(); _networkConfig.DbBasePath = _tempDir; _statsConfig = configSource.GetConfig <IStatsConfig>(); _storage = new NetworkStorage("test", _networkConfig, logManager, new PerfService(logManager)); }
public void Initialize() { _discoveryManagerMock = Substitute.For <IDiscoveryManager>(); _discoveryConfigMock = Substitute.For <IDiscoveryConfig>(); NetworkNodeDecoder.Init(); SetupNodeIds(); var logManager = LimboLogs.Instance; _loggerMock = Substitute.For <ILogger>(); //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket _configurationProvider = new ConfigProvider(); _networkConfig.ExternalIp = "99.10.10.66"; _networkConfig.LocalIp = "10.0.0.5"; IDiscoveryConfig discoveryConfig = _configurationProvider.GetConfig <IDiscoveryConfig>(); discoveryConfig.PongTimeout = 50; discoveryConfig.BucketSize = 3; discoveryConfig.BucketsCount = 1; _ipResolverMock = Substitute.For <IIPResolver>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var calculator = new NodeDistanceCalculator(discoveryConfig); _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _nodeStatsMock = Substitute.For <INodeStats>(); _timestamper = Timestamper.Default; var evictionManager = new EvictionManager(_nodeTable, logManager); _evictionManagerMock = Substitute.For <IEvictionManager>(); var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(_timestamper), evictionManager, new NodeStatsManager(statsConfig, logManager), discoveryConfig, logManager); _udpClient = Substitute.For <IMessageSender>(); var discoveryDb = new SimpleFilePublicKeyDb("Test", "test", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(discoveryDb, logManager), discoveryConfig, logManager, _ipResolverMock); _discoveryManager.MessageSender = _udpClient; _discoveryManagerMock = Substitute.For <IDiscoveryManager>(); }
public void Setup() { _discoveryManagerMock = Substitute.For <IDiscoveryManager>(); _discoveryConfigMock = Substitute.For <IDiscoveryConfig>(); NetworkNodeDecoder.Init(); SetupNodeIds(); LimboLogs?logManager = LimboLogs.Instance; _loggerMock = Substitute.For <ILogger>(); //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket IConfigProvider configurationProvider = new ConfigProvider(); _networkConfig.ExternalIp = "99.10.10.66"; _networkConfig.LocalIp = "10.0.0.5"; IDiscoveryConfig discoveryConfig = configurationProvider.GetConfig <IDiscoveryConfig>(); discoveryConfig.PongTimeout = 50; discoveryConfig.BucketSize = 3; discoveryConfig.BucketsCount = 1; NodeDistanceCalculator calculator = new(discoveryConfig); _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager); _nodeTable.Initialize(TestItem.PublicKeyA); _nodeStatsMock = Substitute.For <INodeStats>(); EvictionManager evictionManager = new(_nodeTable, logManager); _evictionManagerMock = Substitute.For <IEvictionManager>(); ITimerFactory timerFactory = Substitute.For <ITimerFactory>(); NodeLifecycleManagerFactory lifecycleFactory = new(_nodeTable, evictionManager, new NodeStatsManager(timerFactory, logManager), new NodeRecord(), discoveryConfig, Timestamper.Default, logManager); IMsgSender udpClient = Substitute.For <IMsgSender>(); SimpleFilePublicKeyDb discoveryDb = new("Test", "test", logManager); _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(discoveryDb, logManager), discoveryConfig, logManager); _discoveryManager.MsgSender = udpClient; _discoveryManagerMock = Substitute.For <IDiscoveryManager>(); }