private async Task Setup() { _peerChallenger = ContainerProvider.Container.Resolve <IPeerChallenger>(); var eventLoopGroupFactoryConfiguration = new EventLoopGroupFactoryConfiguration { TcpClientHandlerWorkerThreads = 2, TcpServerHandlerWorkerThreads = 3, UdpServerHandlerWorkerThreads = 4, UdpClientHandlerWorkerThreads = 5 }; var keySigner = Substitute.For <IKeySigner>(); keySigner.Verify(Arg.Any <ISignature>(), Arg.Any <byte[]>(), default).ReturnsForAnyArgs(true); var signature = Substitute.For <ISignature>(); keySigner.Sign(Arg.Any <byte[]>(), default).ReturnsForAnyArgs(signature); _peerService = new PeerService(new UdpServerEventLoopGroupFactory(eventLoopGroupFactoryConfiguration), new PeerServerChannelFactory(ContainerProvider.Container.Resolve <IPeerMessageCorrelationManager>(), ContainerProvider.Container.Resolve <IBroadcastManager>(), keySigner, ContainerProvider.Container.Resolve <IPeerIdValidator>(), ContainerProvider.Container.Resolve <IPeerSettings>()), new DiscoveryHelper.DevDiscover(), ContainerProvider.Container.Resolve <IEnumerable <IP2PMessageObserver> >(), _peerSettings, ContainerProvider.Container.Resolve <ILogger>(), ContainerProvider.Container.Resolve <IHealthChecker>()); await _peerService.StartAsync(); }
private async Task Setup() { _peerChallengeRequest = ContainerProvider.Container.Resolve <IPeerChallengeRequest>(); var eventLoopGroupFactoryConfiguration = new EventLoopGroupFactoryConfiguration { TcpClientHandlerWorkerThreads = 2, TcpServerHandlerWorkerThreads = 3, UdpServerHandlerWorkerThreads = 4, UdpClientHandlerWorkerThreads = 5 }; var keySigner = ContainerProvider.Container.Resolve <IKeySigner>(); // @@ _peerService = new PeerService( new UdpServerEventLoopGroupFactory(eventLoopGroupFactoryConfiguration), new PeerServerChannelFactory(ContainerProvider.Container.Resolve <IPeerMessageCorrelationManager>(), ContainerProvider.Container.Resolve <IBroadcastManager>(), keySigner, ContainerProvider.Container.Resolve <IPeerIdValidator>(), ContainerProvider.Container.Resolve <IPeerSettings>()), new DiscoveryHelper.DevDiscover(), ContainerProvider.Container.Resolve <IEnumerable <IP2PMessageObserver> >(), _peerSettings, ContainerProvider.Container.Resolve <ILogger>(), ContainerProvider.Container.Resolve <IHealthChecker>()); await _peerService.StartAsync(); }
public async Task StartSockets() { await _rpcServer.StartAsync().ConfigureAwait(false); await _peerClient.StartAsync().ConfigureAwait(false); await _peer.StartAsync().ConfigureAwait(false); }
public void Init() { Setup(TestContext.CurrentContext); var logger = Substitute.For <ILogger>(); var keyRegistry = TestKeyRegistry.MockKeyRegistry(); ContainerProvider.ContainerBuilder.RegisterInstance(keyRegistry).As <IKeyRegistry>(); ContainerProvider.ContainerBuilder.RegisterModule(new KeystoreModule()); ContainerProvider.ContainerBuilder.RegisterModule(new KeySignerModule()); ContainerProvider.ContainerBuilder.RegisterModule(new HashingModule()); ContainerProvider.ContainerBuilder.RegisterModule(new BulletProofsModule()); _peerSettings = new PeerSettings(ContainerProvider.ConfigurationRoot); var peerSettings = PeerIdHelper.GetPeerId("sender", _peerSettings.BindAddress, _peerSettings.Port) .ToSubstitutedPeerSettings(); ContainerProvider.ContainerBuilder.Register(c => { var peerClient = c.Resolve <IPeerClient>(); peerClient.StartAsync().ConfigureAwait(false).GetAwaiter().GetResult(); return(new PeerChallengeRequest(logger, peerClient, peerSettings, 10)); }).As <IPeerChallengeRequest>().SingleInstance(); _peerChallengeRequest = ContainerProvider.Container.Resolve <IPeerChallengeRequest>(); var eventLoopGroupFactoryConfiguration = new EventLoopGroupFactoryConfiguration { TcpClientHandlerWorkerThreads = 2, TcpServerHandlerWorkerThreads = 3, UdpServerHandlerWorkerThreads = 4, UdpClientHandlerWorkerThreads = 5 }; var keySigner = ContainerProvider.Container.Resolve <IKeySigner>(); // @@ _peerService = new PeerService( new UdpServerEventLoopGroupFactory(eventLoopGroupFactoryConfiguration), new PeerServerChannelFactory(ContainerProvider.Container.Resolve <IPeerMessageCorrelationManager>(), ContainerProvider.Container.Resolve <IBroadcastManager>(), keySigner, ContainerProvider.Container.Resolve <IPeerIdValidator>(), ContainerProvider.Container.Resolve <IPeerSettings>()), new DiscoveryHelper.DevDiscover(), ContainerProvider.Container.Resolve <IEnumerable <IP2PMessageObserver> >(), _peerSettings, ContainerProvider.Container.Resolve <ILogger>(), ContainerProvider.Container.Resolve <IHealthChecker>()); _peerService.StartAsync().Wait(); }
private async Task InitialisePeerServiceAndSendMessage(IP2PMessageObserver pingRequestHandler, ProtocolMessage message) { _p2PMessageHandlers.Add(pingRequestHandler); _peerService = new PeerService(new UdpServerEventLoopGroupFactory(new EventLoopGroupFactoryConfiguration()), _udpServerServerChannelFactory, _peerDiscovery, _p2PMessageHandlers, _peerSettings, _logger, Substitute.For <IHealthChecker>()); await _peerService.StartAsync(); _serverChannel.SimulateReceivingMessagesAsync(message); }