private JsonRpcResponse TestRequest<T>(T module, string method, params string[] parameters) where T : IRpcModule { RpcModuleProvider moduleProvider = new RpcModuleProvider(new FileSystem(), _configurationProvider.GetConfig<IJsonRpcConfig>(), LimboLogs.Instance); moduleProvider.Register(new SingletonModulePool<T>(new SingletonFactory<T>(module), true)); _jsonRpcService = new JsonRpcService(moduleProvider, _logManager); JsonRpcRequest request = RpcTest.GetJsonRequest(method, parameters); JsonRpcResponse response = _jsonRpcService.SendRequestAsync(request, JsonRpcContext.Http).Result; Assert.AreEqual(request.Id, response.Id); return response; }
public void Module_provider_will_recognize_disabled_modules() { JsonRpcConfig jsonRpcConfig = new JsonRpcConfig(); jsonRpcConfig.EnabledModules = new string[0]; _moduleProvider = new RpcModuleProvider(jsonRpcConfig, LimboLogs.Instance); _moduleProvider.Register(new SingletonModulePool <IProofModule>(Substitute.For <IProofModule>(), false)); ModuleResolution resolution = _moduleProvider.Check("proof_call"); Assert.AreEqual(ModuleResolution.Disabled, resolution); }
public TestRpcModuleProvider(T module) { _jsonRpcConfig = new JsonRpcConfig(); _provider = new RpcModuleProvider(new FileSystem(), _jsonRpcConfig, LimboLogs.Instance); _provider.Register(new SingletonModulePool <INetRpcModule>(new SingletonFactory <INetRpcModule>(typeof(INetRpcModule).IsAssignableFrom(typeof(T)) ? (INetRpcModule)module : Substitute.For <INetRpcModule>()), true)); _provider.Register(new SingletonModulePool <IEthRpcModule>(new SingletonFactory <IEthRpcModule>(typeof(IEthRpcModule).IsAssignableFrom(typeof(T)) ? (IEthRpcModule)module : Substitute.For <IEthRpcModule>()), true)); _provider.Register(new SingletonModulePool <IWeb3RpcModule>(new SingletonFactory <IWeb3RpcModule>(typeof(IWeb3RpcModule).IsAssignableFrom(typeof(T)) ? (IWeb3RpcModule)module : Substitute.For <IWeb3RpcModule>()), true)); _provider.Register(new SingletonModulePool <IDebugRpcModule>(new SingletonFactory <IDebugRpcModule>(typeof(IDebugRpcModule).IsAssignableFrom(typeof(T)) ? (IDebugRpcModule)module : Substitute.For <IDebugRpcModule>()), true)); _provider.Register(new SingletonModulePool <ITraceRpcModule>(new SingletonFactory <ITraceRpcModule>(typeof(ITraceRpcModule).IsAssignableFrom(typeof(T)) ? (ITraceRpcModule)module : Substitute.For <ITraceRpcModule>()), true)); _provider.Register(new SingletonModulePool <IParityRpcModule>(new SingletonFactory <IParityRpcModule>(typeof(IParityRpcModule).IsAssignableFrom(typeof(T)) ? (IParityRpcModule)module : Substitute.For <IParityRpcModule>()), true)); }
private JsonRpcResponse TestRequest <T>(IModule ethModule, string method, params string[] parameters) where T : IModule { RpcModuleProvider moduleProvider = new RpcModuleProvider(_configurationProvider.GetConfig <IJsonRpcConfig>()); moduleProvider.Register <T>(ethModule); _jsonRpcService = new JsonRpcService(moduleProvider, _logManager); JsonRpcRequest request = RpcTest.GetJsonRequest(method, parameters); JsonRpcResponse response = _jsonRpcService.SendRequestAsync(request).Result; Assert.AreEqual(request.Id, response.Id); return(response); }
public void With_filter_can_reject(string regex, ModuleResolution expectedResult) { JsonRpcConfig config = new JsonRpcConfig(); _fileSystem.File.Exists(Arg.Any <string>()).Returns(true); _fileSystem.File.ReadLines(Arg.Any <string>()).Returns(new[] { regex }); _moduleProvider = new RpcModuleProvider(_fileSystem, config, LimboLogs.Instance); SingletonModulePool <INetModule> pool = new SingletonModulePool <INetModule>(new NetModule(LimboLogs.Instance, Substitute.For <INetBridge>()), true); _moduleProvider.Register(pool); ModuleResolution resolution = _moduleProvider.Check("net_version"); resolution.Should().Be(expectedResult); }
public void Initialize() { _moduleProvider = new RpcModuleProvider(new JsonRpcConfig(), LimboLogs.Instance); }
public void Initialize() { _fileSystem = Substitute.For <IFileSystem>(); _moduleProvider = new RpcModuleProvider(_fileSystem, new JsonRpcConfig(), LimboLogs.Instance); }