Пример #1
0
        public RpcServerChannelFactoryTests()
        {
            _testScheduler      = new TestScheduler();
            _correlationManager = Substitute.For <IRpcMessageCorrelationManager>();
            _keySigner          = Substitute.For <FakeKeySigner>();
            _keySigner.CryptoContext.SignatureLength.Returns(64);

            var authenticationStrategy = Substitute.For <IAuthenticationStrategy>();

            authenticationStrategy.Authenticate(Arg.Any <PeerId>()).Returns(true);

            var peerSettings = Substitute.For <IPeerSettings>();

            peerSettings.NetworkType.Returns(NetworkType.Devnet);

            var peerIdValidator = Substitute.For <IPeerIdValidator>();

            peerIdValidator.ValidatePeerIdFormat(Arg.Any <PeerId>()).Returns(true);
            _factory = new TestRpcServerChannelFactory(
                _correlationManager,
                _keySigner,
                authenticationStrategy,
                peerIdValidator,
                peerSettings,
                _testScheduler);
        }
 public TestRpcClientChannelFactory(IKeySigner keySigner,
                                    IRpcMessageCorrelationManager correlationManager,
                                    IPeerIdValidator peerIdValidator,
                                    IPeerSettings peerSettings,
                                    TestScheduler testScheduler)
     : base(keySigner, correlationManager, peerIdValidator, peerSettings, 100, testScheduler)
 {
     _handlers = HandlerGenerationFunction();
 }
Пример #3
0
 public TestRpcServerChannelFactory(IRpcMessageCorrelationManager correlationManager,
                                    IKeySigner keySigner,
                                    IAuthenticationStrategy authenticationStrategy,
                                    IPeerIdValidator peerIdValidator,
                                    IPeerSettings peerSettings,
                                    TestScheduler testScheduler)
     : base(correlationManager, keySigner, authenticationStrategy, peerIdValidator, peerSettings, testScheduler)
 {
     _handlers = HandlerGenerationFunction();
 }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="keySigner"></param>
        /// <param name="messageCorrelationCache"></param>
        /// <param name="peerIdValidator"></param>
        /// <param name="peerSettings"></param>
        /// <param name="backLogValue"></param>
        /// <param name="scheduler"></param>
        public RpcClientChannelFactory(IKeySigner keySigner,
                                       IRpcMessageCorrelationManager messageCorrelationCache,
                                       IPeerIdValidator peerIdValidator,
                                       IPeerSettings peerSettings,
                                       int backLogValue     = 100,
                                       IScheduler scheduler = null) : base(backLogValue)
        {
            var observableScheduler = scheduler ?? Scheduler.Default;

            _keySigner = keySigner;
            _messageCorrelationCache = messageCorrelationCache;
            _peerIdValidator         = peerIdValidator;
            _signingContext          = new SigningContext {
                NetworkType = peerSettings.NetworkType, SignatureType = SignatureType.ProtocolRpc
            };
            _observableServiceHandler = new ObservableServiceHandler(observableScheduler);
        }
        public void Init()
        {
            _testScheduler      = new TestScheduler();
            _correlationManager = Substitute.For <IRpcMessageCorrelationManager>();
            _keySigner          = Substitute.For <FakeKeySigner>();

            var peerIdValidator = Substitute.For <IPeerIdValidator>();

            peerIdValidator.ValidatePeerIdFormat(Arg.Any <PeerId>()).Returns(true);

            var peerSettings = Substitute.For <IPeerSettings>();

            peerSettings.NetworkType.Returns(NetworkType.Devnet);

            _factory = new TestRpcClientChannelFactory(_keySigner, _correlationManager, peerIdValidator,
                                                       peerSettings, _testScheduler);
        }
        /// <summary>
        /// </summary>
        /// <param name="correlationManger"></param>
        /// <param name="keySigner"></param>
        /// <param name="authenticationStrategy"></param>
        /// <param name="peerIdValidator"></param>
        /// <param name="peerSettings"></param>
        /// <param name="scheduler"></param>
        public RpcServerChannelFactory(IRpcMessageCorrelationManager correlationManger,
                                       IKeySigner keySigner,
                                       IAuthenticationStrategy authenticationStrategy,
                                       IPeerIdValidator peerIdValidator,
                                       IPeerSettings peerSettings,
                                       IScheduler scheduler = null)
        {
            var observableScheduler = scheduler ?? Scheduler.Default;

            _correlationManger      = correlationManger;
            _authenticationStrategy = authenticationStrategy;
            _keySigner       = keySigner;
            _peerIdValidator = peerIdValidator;
            _signingContext  = new SigningContext {
                NetworkType = peerSettings.NetworkType, SignatureType = SignatureType.ProtocolRpc
            };
            _observableServiceHandler = new ObservableServiceHandler(observableScheduler);
        }
Пример #7
0
        public RpcClientChannelFactoryTests()
        {
            _testScheduler            = new TestScheduler();
            _serverCorrelationManager = Substitute.For <IRpcMessageCorrelationManager>();
            _serverKeySigner          = Substitute.For <IKeySigner>();
            _serverKeySigner.CryptoContext.SignatureLength.Returns(64);

            _authenticationStrategy = Substitute.For <IAuthenticationStrategy>();

            _peerIdValidator = Substitute.For <IPeerIdValidator>();
            var peerSettings = Substitute.For <IPeerSettings>();

            peerSettings.NetworkType.Returns(NetworkType.Devnet);

            _serverFactory = new UnitTests.Rpc.IO.Transport.Channels.RpcServerChannelFactoryTests.TestRpcServerChannelFactory(
                _serverCorrelationManager,
                _serverKeySigner,
                _authenticationStrategy,
                _peerIdValidator,
                peerSettings,
                _testScheduler);

            _clientCorrelationManager = Substitute.For <IRpcMessageCorrelationManager>();
            _clientKeySigner          = Substitute.For <IKeySigner>();
            _clientKeySigner.CryptoContext.SignatureLength.Returns(64);
            var clientFactory =
                new UnitTests.Rpc.IO.Transport.Channels.RpcClientChannelFactoryTests.TestRpcClientChannelFactory(
                    _clientKeySigner,
                    _clientCorrelationManager,
                    _peerIdValidator,
                    peerSettings,
                    _testScheduler);

            _serverChannel =
                new EmbeddedChannel("server".ToChannelId(), true, _serverFactory.InheritedHandlers.ToArray());

            _clientChannel =
                new EmbeddedChannel("client".ToChannelId(), true, clientFactory.InheritedHandlers.ToArray());
        }