Example #1
0
 public void Setup()
 {
     _configProvider            = Substitute.For <IConfigProvider>();
     _configManager             = Substitute.For <IConfigManager>();
     _ndmConfig                 = new NdmConfig();
     _baseDbPath                = "db";
     _rocksProvider             = Substitute.For <IDbProvider>();
     _mongoProvider             = Substitute.For <IMongoProvider>();
     _logManager                = Substitute.For <ILogManager>();
     _blockTree                 = Substitute.For <IBlockTree>();
     _specProvider              = Substitute.For <ISpecProvider>();
     _transactionPool           = Substitute.For <ITxPool>();
     _receiptStorage            = Substitute.For <IReceiptStorage>();
     _filterStore               = Substitute.For <IFilterStore>();
     _filterManager             = Substitute.For <IFilterManager>();
     _wallet                    = Substitute.For <IWallet>();
     _timestamper               = Substitute.For <ITimestamper>();
     _ecdsa                     = Substitute.For <IEthereumEcdsa>();
     _keyStore                  = Substitute.For <IKeyStore>();
     _rpcModuleProvider         = Substitute.For <IRpcModuleProvider>();
     _jsonSerializer            = Substitute.For <IJsonSerializer>();
     _cryptoRandom              = Substitute.For <ICryptoRandom>();
     _enode                     = Substitute.For <IEnode>();
     _ndmConsumerChannelManager = Substitute.For <INdmConsumerChannelManager>();
     _ndmDataPublisher          = Substitute.For <INdmDataPublisher>();
     _grpcServer                = Substitute.For <IGrpcServer>();
     _ethRequestService         = Substitute.For <IEthRequestService>();
     _notifier                  = Substitute.For <INdmNotifier>();
     _enableUnsecuredDevWallet  = false;
     _blockProcessor            = Substitute.For <IBlockProcessor>();
     _jsonRpcClientProxy        = Substitute.For <IJsonRpcClientProxy>();
     _ethJsonRpcClientProxy     = Substitute.For <IEthJsonRpcClientProxy>();
     _httpClient                = Substitute.For <IHttpClient>();
     _ndmModule                 = new NdmModule();
 }
        public void set_url_throw_exception_if_url_proxy_is_not_valid_uri()
        {
            _proxy = new JsonRpcClientProxy(_client, null, LimboLogs.Instance);
            Action act = () => _proxy.SetUrls("http:/localhost");

            act.Should().Throw <UriFormatException>();
        }
Example #3
0
        public Scenario(string jsonRpcUrl)
        {
            var logsManager = LimboLogs.Instance;
            var serializer  = new EthereumJsonSerializer();

            _client = new JsonRpcClientProxy(new DefaultHttpClient(new HttpClient(), serializer, logsManager, 0),
                                             new[] { jsonRpcUrl }, logsManager);
        }
Example #4
0
 public ProxyService(IJsonRpcClientProxy jsonRpcClientProxy, IConfigManager configManager, string configId,
                     ILogManager logManager)
 {
     _jsonRpcClientProxy = jsonRpcClientProxy;
     _configManager      = configManager ?? throw new ArgumentNullException(nameof(configManager));
     _configId           = configId ?? throw new ArgumentNullException(nameof(configId));
     _logger             = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
 }
        public async Task send_async_should_not_invoke_client_post_json_and_return_null_when_url_is_empty()
        {
            const string method = "test";

            _proxy = new JsonRpcClientProxy(_client, null, LimboLogs.Instance);
            var @params = new List <object> {
                "arg1", 1, new object()
            };
            var result = await _proxy.SendAsync <object>(method, @params);

            result.Should().BeNull();
            await _client.DidNotReceiveWithAnyArgs().PostJsonAsync <RpcResult <object> >(null);
        }
Example #6
0
        public Scenario(string client, string jsonRpcUrl, int pullDataDelay = 10, int pullDataRetries = 10,
                        int pullDataFailures = 100)
        {
            _client           = client;
            _pullDataDelay    = pullDataDelay;
            _pullDataRetries  = pullDataRetries;
            _pullDataFailures = pullDataFailures;
            var logsManager = LimboLogs.Instance;

            _serializer    = new EthereumJsonSerializer();
            _jsonRpcClient = new JsonRpcClientProxy(new DefaultHttpClient(
                                                        new HttpClient(), _serializer, logsManager, 0), new[] { jsonRpcUrl }, logsManager);
        }
Example #7
0
 public NdmRequiredServices(IConfigProvider configProvider, IConfigManager configManager, INdmConfig ndmConfig,
                            string baseDbPath, IDbProvider rocksProvider, IMongoProvider mongoProvider, ILogManager logManager,
                            IBlockTree blockTree, ITxPool transactionPool, ISpecProvider specProvider, IReceiptStorage receiptStorage,
                            IFilterStore filterStore, IFilterManager filterManager, IWallet wallet, ITimestamper timestamper,
                            IEthereumEcdsa ecdsa, IKeyStore keyStore, IRpcModuleProvider rpcModuleProvider,
                            IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode,
                            INdmConsumerChannelManager ndmConsumerChannelManager, INdmDataPublisher ndmDataPublisher,
                            IGrpcServer grpcServer, IEthRequestService ethRequestService, INdmNotifier notifier,
                            bool enableUnsecuredDevWallet, IBlockProcessor blockProcessor, IJsonRpcClientProxy jsonRpcClientProxy,
                            IEthJsonRpcClientProxy ethJsonRpcClientProxy, IHttpClient httpClient, IMonitoringService monitoringService)
 {
     ConfigProvider            = configProvider;
     ConfigManager             = configManager;
     NdmConfig                 = ndmConfig;
     BaseDbPath                = baseDbPath;
     RocksProvider             = rocksProvider;
     MongoProvider             = mongoProvider;
     LogManager                = logManager;
     BlockTree                 = blockTree;
     TransactionPool           = transactionPool;
     SpecProvider              = specProvider;
     ReceiptStorage            = receiptStorage;
     FilterStore               = filterStore;
     FilterManager             = filterManager;
     Wallet                    = wallet;
     Timestamper               = timestamper;
     Ecdsa                     = ecdsa;
     KeyStore                  = keyStore;
     RpcModuleProvider         = rpcModuleProvider;
     JsonSerializer            = jsonSerializer;
     CryptoRandom              = cryptoRandom;
     Enode                     = enode;
     NdmConsumerChannelManager = ndmConsumerChannelManager;
     NdmDataPublisher          = ndmDataPublisher;
     GrpcServer                = grpcServer;
     EthRequestService         = ethRequestService;
     Notifier                  = notifier;
     EnableUnsecuredDevWallet  = enableUnsecuredDevWallet;
     BlockProcessor            = blockProcessor;
     JsonRpcClientProxy        = jsonRpcClientProxy;
     EthJsonRpcClientProxy     = ethJsonRpcClientProxy;
     HttpClient                = httpClient;
     MonitoringService         = monitoringService;
 }
 public void Setup()
 {
     _ndmModule          = Substitute.For <INdmModule>();
     _ndmConsumersModule = Substitute.For <INdmConsumersModule>();
     _configProvider     = Substitute.For <IConfigProvider>();
     _dbProvider         = Substitute.For <IDbProvider>();
     _blockTree          = Substitute.For <IBlockTree>();
     _txPool             = Substitute.For <ITxPool>();
     _txSender           = Substitute.For <ITxSender>();
     _specProvider       = Substitute.For <ISpecProvider>();
     _receiptFinder      = Substitute.For <IReceiptFinder>();
     _wallet             = Substitute.For <IWallet>();
     _filterStore        = Substitute.For <IFilterStore>();
     _filterManager      = Substitute.For <IFilterManager>();
     _timestamper        = Substitute.For <ITimestamper>();
     _ecdsa                       = Substitute.For <IEthereumEcdsa>();
     _rpcModuleProvider           = Substitute.For <IRpcModuleProvider>();
     _keyStore                    = Substitute.For <IKeyStore>();
     _jsonSerializer              = Substitute.For <IJsonSerializer>();
     _cryptoRandom                = Substitute.For <ICryptoRandom>();
     _enode                       = Substitute.For <IEnode>();
     _consumerChannelManager      = Substitute.For <INdmConsumerChannelManager>();
     _dataPublisher               = Substitute.For <INdmDataPublisher>();
     _grpcServer                  = Substitute.For <IGrpcServer>();
     _nodeStatsManager            = Substitute.For <INodeStatsManager>();
     _protocolsManager            = Substitute.For <IProtocolsManager>();
     _protocolValidator           = Substitute.For <IProtocolValidator>();
     _messageSerializationService = Substitute.For <IMessageSerializationService>();
     _webSocketsManager           = Substitute.For <IWebSocketsManager>();
     _logManager                  = LimboLogs.Instance;
     _blockProcessor              = Substitute.For <IBlockProcessor>();
     _jsonRpcClientProxy          = Substitute.For <IJsonRpcClientProxy>();
     _ethJsonRpcClientProxy       = Substitute.For <IEthJsonRpcClientProxy>();
     _httpClient                  = Substitute.For <IHttpClient>();
     _monitoringService           = Substitute.For <IMonitoringService>();
     _enableUnsecuredDevWallet    = false;
     _ndmConfig                   = new NdmConfig {
         Enabled = true, StoreConfigInDatabase = false
     };
     _configProvider.GetConfig <INdmConfig>().Returns(_ndmConfig);
     _ndmInitializer = new NdmInitializer(_ndmModule, _ndmConsumersModule, _logManager);
     _bloomStorage   = Substitute.For <IBloomStorage>();
 }
 public void set_url_should_succeed_when_url_is_empty()
 {
     _proxy = new JsonRpcClientProxy(_client, null, LimboLogs.Instance);
     _proxy.SetUrls(null);
 }
        public void constructor_should_throw_exception_if_url_proxy_is_not_valid_uri()
        {
            Action act = () => _proxy = new JsonRpcClientProxy(_client, new [] { "http:/localhost" }, LimboLogs.Instance);

            act.Should().Throw <UriFormatException>();
        }
        public void constructor_should_throw_exception_if_client_argument_is_null()
        {
            Action act = () => _proxy = new JsonRpcClientProxy(null, _urlProxies, LimboLogs.Instance);

            act.Should().Throw <ArgumentNullException>();
        }
 public void Setup()
 {
     _client     = Substitute.For <IHttpClient>();
     _urlProxies = new[] { "http://localhost:8545" };
     _proxy      = new JsonRpcClientProxy(_client, _urlProxies, LimboLogs.Instance);
 }
Example #13
0
        public virtual async Task <INdmCapabilityConnector> InitAsync(IConfigProvider configProvider,
                                                                      IDbProvider dbProvider, string baseDbPath, IBlockTree blockTree, ITxPool txPool, ISpecProvider specProvider,
                                                                      IReceiptStorage receiptStorage, IWallet wallet, IFilterStore filterStore, IFilterManager filterManager,
                                                                      ITimestamper timestamper, IEthereumEcdsa ecdsa, IRpcModuleProvider rpcModuleProvider, IKeyStore keyStore,
                                                                      IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode,
                                                                      INdmConsumerChannelManager consumerChannelManager, INdmDataPublisher dataPublisher, IGrpcServer grpcServer,
                                                                      INodeStatsManager nodeStatsManager, IProtocolsManager protocolsManager,
                                                                      IProtocolValidator protocolValidator, IMessageSerializationService messageSerializationService,
                                                                      bool enableUnsecuredDevWallet, IWebSocketsManager webSocketsManager, ILogManager logManager,
                                                                      IBlockProcessor blockProcessor, IJsonRpcClientProxy jsonRpcClientProxy,
                                                                      IEthJsonRpcClientProxy ethJsonRpcClientProxy, IHttpClient httpClient, IMonitoringService monitoringService)
        {
            var(config, services, faucet, ethRequestService, accountService, consumerService, consumerAddress,
                providerAddress) = await PreInitAsync(configProvider, dbProvider, baseDbPath, blockTree, txPool,
                                                      specProvider, receiptStorage, wallet, filterStore, filterManager, timestamper, ecdsa, rpcModuleProvider,
                                                      keyStore, jsonSerializer, cryptoRandom, enode, consumerChannelManager, dataPublisher, grpcServer,
                                                      enableUnsecuredDevWallet, webSocketsManager, logManager, blockProcessor, jsonRpcClientProxy,
                                                      ethJsonRpcClientProxy, httpClient, monitoringService);

            if (!config.Enabled)
            {
                return(default);
        public void constructor_should_throw_exception_if_url_proxy_is_empty()
        {
            Action act = () => _proxy = new JsonRpcClientProxy(_client, new [] { string.Empty });

            act.Should().Throw <ArgumentException>();
        }
        public void constructor_should_throw_exception_if_url_proxies_argument_is_empty()
        {
            Action act = () => _proxy = new JsonRpcClientProxy(_client, Array.Empty <string>());

            act.Should().Throw <ArgumentException>();
        }
        public void constructor_should_throw_exception_if_url_proxies_argument_is_null()
        {
            Action act = () => _proxy = new JsonRpcClientProxy(_client, null);

            act.Should().Throw <ArgumentNullException>();
        }
 public EthJsonRpcClientProxy(IJsonRpcClientProxy proxy)
 {
     _proxy = proxy ?? throw new ArgumentNullException(nameof(proxy));
 }
Example #18
0
 public void Setup()
 {
     _client = Substitute.For <IJsonRpcClientProxy>();
     _proxy  = new EthJsonRpcClientProxy(_client);
 }