Exemple #1
0
        public void SetUp()
        {
            NetworkNodeDecoder.Init();
            NullLogManager logManager   = NullLogManager.Instance;
            ConfigProvider configSource = new ConfigProvider();

            _tempDir                  = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            _networkConfig            = configSource.GetConfig <INetworkConfig>();
            _networkConfig.DbBasePath = _tempDir;
            _statsConfig              = configSource.GetConfig <IStatsConfig>();

            _storage = new NetworkStorage("test", _networkConfig, logManager, new PerfService(logManager));
        }
Exemple #2
0
        static void Main()
        {
            ConfigModel config = new ConfigModel(@"D:\Projects\cs\labs\Files\SourceDir",
                                                 @"D:\Projects\cs\labs\Files\TargetDir", true, false, "11111111");

            ConfigProvider provider    = new ConfigProvider(@"D:\Projects\cs\labs\lab3\Config\config.xml");
            var            xmlConfig   = provider.GetConfig <ConfigModel>();
            var            xmlEConfing = provider.GetConfig <EncryptionOptions>();



            /*ConfigProvider provider = new ConfigProvider("D:\\Projects\\cs\\labs\\lab3\\Config\\appsettings.json");
             * var jsonConfig = provider.GetConfig<ConfigModel>();
             * var jsonEConfig = provider.GetConfig<EncryptionOptions>();*/
        }
Exemple #3
0
        public IBlockchainBridge CreateBlockchainBridge()
        {
            ReadOnlyBlockTree readOnlyTree = BlockTree.AsReadOnly();

            LazyInitializer.EnsureInitialized(ref _readOnlyDbProvider, () => new ReadOnlyDbProvider(DbProvider, false));

            // TODO: reuse the same trie cache here
            ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv = new(
                _readOnlyDbProvider,
                ReadOnlyTrieStore,
                readOnlyTree,
                SpecProvider,
                LogManager);

            IMiningConfig miningConfig = ConfigProvider.GetConfig <IMiningConfig>();
            ISyncConfig   syncConfig   = ConfigProvider.GetConfig <ISyncConfig>();

            return(new BlockchainBridge(
                       readOnlyTxProcessingEnv,
                       TxPool,
                       ReceiptFinder,
                       FilterStore,
                       FilterManager,
                       EthereumEcdsa,
                       Timestamper,
                       LogFinder,
                       miningConfig.Enabled,
                       syncConfig.BeamSync && syncConfig.FastSync
                       ));
        }
        public void Sync_is_disabled_when_needed(string configFile, bool isSyncEnabled)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            ISyncConfig    config         = configProvider.GetConfig <ISyncConfig>();

            Assert.AreEqual(isSyncEnabled, config.SynchronizationEnabled);
        }
Exemple #5
0
        public void Can_read_without_sources()
        {
            ConfigProvider configProvider = new ConfigProvider();
            IStatsConfig   statsConfig    = configProvider.GetConfig <IStatsConfig>();

            Assert.AreEqual(1000500L, statsConfig.PredefinedReputation);
        }
Exemple #6
0
        public void Geth_limits_configs_are_correct(string configFile, bool useGethLimitsInFastSync)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            ISyncConfig    config         = configProvider.GetConfig <ISyncConfig>();

            Assert.AreEqual(useGethLimitsInFastSync, config.UseGethLimitsInFastBlocks);
        }
        public void Metrics_disabled_by_default(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IMetricsConfig config         = configProvider.GetConfig <IMetricsConfig>();

            Assert.AreEqual(config.Enabled, false);
        }
        public void IsMining_enabled_for_ndm_consumer_local(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IInitConfig    config         = configProvider.GetConfig <IInitConfig>();

            Assert.AreEqual(true, config.IsMining);
        }
Exemple #9
0
        public void Can_read_without_sources()
        {
            ConfigProvider configProvider = new ConfigProvider();
            INetworkConfig config         = configProvider.GetConfig <INetworkConfig>();

            Assert.AreEqual(30303, config.DiscoveryPort);
        }
        public void Sync_defaults_are_correct(string configFile, bool fastSyncEnabled)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            ISyncConfig    config         = configProvider.GetConfig <ISyncConfig>();

            Assert.AreEqual(config.FastSync, fastSyncEnabled);
        }
        public void Can_read_without_sources()
        {
            ConfigProvider configProvider = new ConfigProvider();
            IStatsConfig   statsConfig    = configProvider.GetConfig <IStatsConfig>();

            Assert.AreEqual(10000, statsConfig.PenalizedReputationTooManyPeersTimeout);
        }
        public void Ethstats_values_are_correct(string configFile, string host)
        {
            ConfigProvider  configProvider = GetConfigProviderFromFile(configFile);
            IEthStatsConfig config         = configProvider.GetConfig <IEthStatsConfig>();

            Assert.AreEqual(host, config.Server);
        }
Exemple #13
0
        public IBlockchainBridge CreateBlockchainBridge()
        {
            ReadOnlyBlockTree       readOnlyTree            = new ReadOnlyBlockTree(BlockTree);
            IReadOnlyDbProvider     readOnlyDbProvider      = new ReadOnlyDbProvider(DbProvider, false);
            ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv = new ReadOnlyTxProcessingEnv(
                readOnlyDbProvider,
                readOnlyTree,
                SpecProvider,
                LogManager);

            IMiningConfig miningConfig = ConfigProvider.GetConfig <IMiningConfig>();
            ISyncConfig   syncConfig   = ConfigProvider.GetConfig <ISyncConfig>();

            return(new BlockchainBridge(
                       readOnlyTxProcessingEnv,
                       TxPool,
                       ReceiptFinder,
                       FilterStore,
                       FilterManager,
                       EthereumEcdsa,
                       Timestamper,
                       LogFinder,
                       miningConfig.Enabled,
                       syncConfig.BeamSync && syncConfig.FastSync
                       ));
        }
        public void Genesis_hash_is_correct(string configFile, string genesisHash)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IInitConfig    config         = configProvider.GetConfig <IInitConfig>();

            Assert.AreEqual(config.GenesisHash, genesisHash);
        }
        public void Kafka_disabled_by_default(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IKafkaConfig   kafkaConfig    = configProvider.GetConfig <IKafkaConfig>();

            Assert.AreEqual(false, kafkaConfig.Enabled, nameof(kafkaConfig.Enabled));
        }
        public void Mining_defaults_are_correct(string configFile, bool defaultValue = false)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IInitConfig    config         = configProvider.GetConfig <IInitConfig>();

            Assert.AreEqual(config.IsMining, defaultValue);
        }
Exemple #17
0
        static void Main()
        {
            var configPath       = @"D:\Projects\cs\lab4\ServiceLayer\ServiceConfig.json";
            var configProvider   = new ConfigProvider(configPath);
            var serviceModel     = configProvider.GetConfig <ServiceModel>();
            var connectionString = serviceModel.ConnectionString;
            var targetPath       = serviceModel.TargetXmlPath;
            var errorLogger      = new Logger();
            int id = 5;

            try
            {
                PersonalInfo personalInfo = new PersonalInfo();////////
                personalInfo.Name        = "testName";
                personalInfo.PhoneNumber = "testPhone";
                LoginInfo   loginInfo   = new LoginInfo(connectionString, id);
                AddressInfo addressInfo = new AddressInfo();///////
                addressInfo.Address = "testAddress";
                XmlModel   obj     = new XmlModel(personalInfo, loginInfo, addressInfo);
                XmlCreator creator = new XmlCreator();
                creator.CreateXmlFile(obj, targetPath);
            }
            catch (Exception e)
            {
                errorLogger.AddError(e, DateTime.Now);
            }
        }
        [Timeout(12000)] // just to make sure we are not on infinite loop on steps because of incorrect dependencies
        public async Task Smoke_cancel(string chainSpecPath)
        {
            Type type1 = typeof(ITxPoolConfig);
            Type type2 = typeof(INetworkConfig);
            Type type3 = typeof(IKeyStoreConfig);
            Type type4 = typeof(IDbConfig);
            Type type5 = typeof(IStatsConfig);
            Type type6 = typeof(IKafkaConfig);
            Type type7 = typeof(IEthStatsConfig);
            Type type8 = typeof(ISyncConfig);
            Type type9 = typeof(IBloomConfig);

            var configProvider = new ConfigProvider();

            configProvider.AddSource(new ConfigSource(chainSpecPath));

            Console.WriteLine(type1.Name);
            Console.WriteLine(type2.Name);
            Console.WriteLine(type3.Name);
            Console.WriteLine(type4.Name);
            Console.WriteLine(type5.Name);
            Console.WriteLine(type6.Name);
            Console.WriteLine(type7.Name);
            Console.WriteLine(type8.Name);
            Console.WriteLine(type9.Name);

            var tempPath = Path.Combine(Path.GetTempPath(), "test_" + Guid.NewGuid());

            Directory.CreateDirectory(tempPath);

            try
            {
                configProvider.GetConfig <IInitConfig>().BaseDbPath = tempPath;

                EthereumRunner runner = new EthereumRunner(
                    new RpcModuleProvider(new JsonRpcConfig(), LimboLogs.Instance),
                    configProvider,
                    NUnitLogManager.Instance,
                    Substitute.For <IGrpcServer>(),
                    Substitute.For <INdmConsumerChannelManager>(),
                    Substitute.For <INdmDataPublisher>(),
                    Substitute.For <INdmInitializer>(),
                    Substitute.For <IWebSocketsManager>(),
                    new EthereumJsonSerializer(),
                    Substitute.For <IMonitoringService>());

                CancellationTokenSource cts = new CancellationTokenSource();
                Task task = runner.Start(cts.Token);

                cts.Cancel();

                await task;
            }
            finally
            {
                // rocks db still has a lock on a file called "LOCK".
                Directory.Delete(tempPath, true);
            }
        }
        public void Grpc_enabled_for_ndm(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IGrpcConfig    config         = configProvider.GetConfig <IGrpcConfig>();

            Assert.AreEqual(true, config.Enabled);
            Assert.AreEqual(false, config.ProducerEnabled);
        }
        public void Fast_sync_settings_as_expected(string configFile, bool downloadBodies, bool downloadsReceipts)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            ISyncConfig    syncConfig     = configProvider.GetConfig <ISyncConfig>();

            Assert.AreEqual(downloadBodies, syncConfig.DownloadBodiesInFastSync, nameof(syncConfig.DownloadBodiesInFastSync));
            Assert.AreEqual(downloadsReceipts, syncConfig.DownloadReceiptsInFastSync, nameof(syncConfig.DownloadReceiptsInFastSync));
        }
        public void Grpc_disabled_by_default(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IGrpcConfig    config         = configProvider.GetConfig <IGrpcConfig>();

            Assert.AreEqual(false, config.Enabled);
            Assert.AreEqual(false, config.ProducerEnabled);
        }
Exemple #22
0
 private void Test <T, TProperty>(string configWildcard, Func <T, TProperty> getter, Action <string, TProperty> expectedValue) where T : IConfig
 {
     foreach (string configFile in Resolve(configWildcard))
     {
         ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
         T config = configProvider.GetConfig <T>();
         expectedValue(configFile, getter(config));
     }
 }
        public void Json_default_are_correct(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IJsonRpcConfig jsonRpcConfig  = configProvider.GetConfig <IJsonRpcConfig>();

            Assert.AreEqual(8545, jsonRpcConfig.Port, nameof(jsonRpcConfig.Port));
            Assert.AreEqual("127.0.0.1", jsonRpcConfig.Host, nameof(jsonRpcConfig.Host));
            Assert.AreEqual(false, jsonRpcConfig.Enabled, nameof(jsonRpcConfig.Enabled));
        }
        public void Sync_defaults_are_correct(string configFile, bool fastSyncEnabled, bool fastBlocksEnabled)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            ISyncConfig    config         = configProvider.GetConfig <ISyncConfig>();

            Assert.AreEqual(fastSyncEnabled, config.FastSync, "fast sync");
            Assert.AreEqual(fastBlocksEnabled, config.FastBlocks, "fast blocks");
            Assert.AreEqual(false, config.BeamSync);
        }
        public void Bloom_configs_are_as_expected(string configFile, int[] levels = null, bool index = true)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IBloomConfig   bloomConfig    = configProvider.GetConfig <IBloomConfig>();

            bloomConfig.Index.Should().Be(index);
            bloomConfig.Migration.Should().BeFalse();
            bloomConfig.MigrationStatistics.Should().BeFalse();
            bloomConfig.IndexLevelBucketSizes.Should().Equal(levels ?? new BloomConfig().IndexLevelBucketSizes);
        }
Exemple #26
0
 public void OnContainerCreateInstanceFinished()
 {
     if (null != ConfigProvider)
     {
         var e = ConfigProvider.GetConfig();
         if (null != e)
         {
             InitializeFromXml(e);
         }
     }
 }
        public void Network_defaults_are_correct(string configFile)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            INetworkConfig networkConfig  = configProvider.GetConfig <INetworkConfig>();

            Assert.AreEqual(30303, networkConfig.DiscoveryPort, nameof(networkConfig.DiscoveryPort));
            Assert.AreEqual(30303, networkConfig.P2PPort, nameof(networkConfig.P2PPort));
            Assert.Null(networkConfig.ExternalIp, nameof(networkConfig.ExternalIp));
            Assert.Null(networkConfig.LocalIp, nameof(networkConfig.LocalIp));
            Assert.AreEqual(50, networkConfig.ActivePeersMaxCount, 50);
        }
        public void Basic_configs_are_as_expected(string configFile, bool isProduction = false)
        {
            ConfigProvider configProvider = GetConfigProviderFromFile(configFile);
            IInitConfig    initConfig     = configProvider.GetConfig <IInitConfig>();
            ISyncConfig    syncConfig     = configProvider.GetConfig <ISyncConfig>();

            Assert.True(initConfig.DiscoveryEnabled, nameof(initConfig.DiscoveryEnabled));
            Assert.True(initConfig.ProcessingEnabled, nameof(initConfig.ProcessingEnabled));
            Assert.True(initConfig.PeerManagerEnabled, nameof(initConfig.PeerManagerEnabled));
            Assert.True(syncConfig.SynchronizationEnabled, nameof(syncConfig.SynchronizationEnabled));
            Assert.False(initConfig.WebSocketsEnabled, nameof(initConfig.WebSocketsEnabled));
            if (isProduction)
            {
                Assert.False(initConfig.EnableUnsecuredDevWallet, nameof(initConfig.EnableUnsecuredDevWallet));
            }

            Assert.False(initConfig.KeepDevWalletInMemory, nameof(initConfig.KeepDevWalletInMemory));
            Assert.False(initConfig.IsMining, nameof(initConfig.IsMining));
            Assert.True(initConfig.StoreReceipts, nameof(initConfig.StoreReceipts));

            Assert.AreEqual(configFile.Replace("cfg", "logs.txt"), initConfig.LogFileName, nameof(initConfig.LogFileName));
        }
Exemple #29
0
        public void SetUp()
        {
            NetworkNodeDecoder.Init();
            NullLogManager logManager   = NullLogManager.Instance;
            ConfigProvider configSource = new ConfigProvider();

            _tempDir     = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            _statsConfig = configSource.GetConfig <IStatsConfig>();

            var db = new SimpleFilePublicKeyDb("Test", _tempDir, logManager);

            _storage = new NetworkStorage(db, logManager);
        }
Exemple #30
0
        public void SetUp()
        {
            NetworkNodeDecoder.Init();
            ILogManager    logManager   = LimboLogs.Instance;
            ConfigProvider configSource = new ConfigProvider();

            _tempDir     = TempPath.GetTempDirectory();
            _statsConfig = configSource.GetConfig <IStatsConfig>();

            var db = new SimpleFilePublicKeyDb("Test", _tempDir.Path, logManager);

            _storage = new NetworkStorage(db, logManager);
        }