public MothraPeeringWorker(ILogger <MothraPeeringWorker> logger, IOptionsMonitor <MothraConfiguration> mothraConfigurationOptions, IHostEnvironment environment, IClientVersion clientVersion, IStore store, IMothraLibp2p mothraLibp2P, DataDirectory dataDirectory, PeerManager peerManager, PeerDiscoveredProcessor peerDiscoveredProcessor, RpcPeeringStatusProcessor rpcPeeringStatusProcessor, RpcBeaconBlocksByRangeProcessor rpcBeaconBlocksByRangeProcessor, SignedBeaconBlockProcessor signedBeaconBlockProcessor) { _logger = logger; _environment = environment; _clientVersion = clientVersion; _dataDirectory = dataDirectory; _mothraConfigurationOptions = mothraConfigurationOptions; _mothraLibp2P = mothraLibp2P; _peerManager = peerManager; _peerDiscoveredProcessor = peerDiscoveredProcessor; _rpcPeeringStatusProcessor = rpcPeeringStatusProcessor; _rpcBeaconBlocksByRangeProcessor = rpcBeaconBlocksByRangeProcessor; _signedBeaconBlockProcessor = signedBeaconBlockProcessor; _store = store; // 396 bytes _minimumSignedBeaconBlockLength = Ssz.Ssz.SignedBeaconBlockLength( new SignedBeaconBlock(new BeaconBlock(Slot.Zero, Root.Zero, Root.Zero, BeaconBlockBody.Zero), BlsSignature.Zero)); }
public void SetUp() { _mockLoggerOptionsMonitor = Substitute.For <IOptionsMonitor <ConsoleLoggerOptions> >(); _mockLoggerOptionsMonitor.CurrentValue.Returns(new ConsoleLoggerOptions() { Format = ConsoleLoggerFormat.Systemd, DisableColors = true, IncludeScopes = true, TimestampFormat = " HH':'mm':'sszz " }); _loggerFactory = new LoggerFactory(new [] { new ConsoleLoggerProvider(_mockLoggerOptionsMonitor) }); _mockMothra = new MockMothra(); // mockMothra.StartCalled += settings => // { // ThreadPool.QueueUserWorkItem(x => // { // Thread.Sleep(TimeSpan.FromMilliseconds(100)); // byte[] peerUtf8 = Encoding.UTF8.GetBytes("peer1"); // mockMothra.RaisePeerDiscovered(peerUtf8); // }); // }; _mockForkChoice = Substitute.For <IForkChoice>(); _mockSynchronizationManager = Substitute.For <ISynchronizationManager>(); _mockStore = Substitute.For <IStore>(); _mockStore.IsInitialized.Returns(true); _mockMothraConfigurationMonitor = Substitute.For <IOptionsMonitor <MothraConfiguration> >(); _mockMothraConfigurationMonitor.CurrentValue.Returns(new MothraConfiguration()); // TODO: Replace with MothraNetworkPeering and mockMothra. _mockNetworkPeering = Substitute.For <INetworkPeering>(); _dataDirectory = new DataDirectory("data"); _peerManager = new PeerManager(_loggerFactory.CreateLogger <PeerManager>()); _peerDiscoveredProcessor = new PeerDiscoveredProcessor( _loggerFactory.CreateLogger <PeerDiscoveredProcessor>(), _mockSynchronizationManager, _peerManager); _rpcPeeringStatusProcessor = new RpcPeeringStatusProcessor( _loggerFactory.CreateLogger <RpcPeeringStatusProcessor>(), _mockSynchronizationManager, _peerManager); _rpcBeaconBlocksByRangeProcessor = new RpcBeaconBlocksByRangeProcessor(_loggerFactory.CreateLogger <RpcBeaconBlocksByRangeProcessor>(), _mockNetworkPeering, _mockForkChoice, _mockStore); _signedBeaconBlockProcessor = new SignedBeaconBlockProcessor( _loggerFactory.CreateLogger <SignedBeaconBlockProcessor>(), _mockMothraConfigurationMonitor, Substitute.For <IFileSystem>(), _mockForkChoice, _mockStore, _dataDirectory, _peerManager); }