public void PeerConnectorDiscover_WithConnectPeersSpecified_CanNotStart()
        {
            var nodeSettings = new NodeSettings
            {
                ConnectionManager = new Configuration.Settings.ConnectionManagerSettings()
            };

            nodeSettings.LoadArguments(new string[] { });

            var ipAddressThree            = IPAddress.Parse("::ffff:192.168.0.3");
            var networkAddressConnectNode = new NetworkAddress(ipAddressThree, 80);

            nodeSettings.ConnectionManager.Connect.Add(networkAddressConnectNode.Endpoint);

            var peerFolder         = AssureEmptyDirAsDataFolder(Path.Combine(AppContext.BaseDirectory, "PeerConnectorTests"));
            var peerAddressManager = new PeerAddressManager(peerFolder, this.extendedLoggerFactory);

            var connector = this.CreatePeerConnectorDiscovery(nodeSettings, peerAddressManager);

            Assert.False(connector.CanStartConnect);
        }
Beispiel #2
0
        public void PeerConnectorConnect_WithConnectPeersSpecified_CanStart()
        {
            var peerFolder         = AssureEmptyDirAsDataFolder(Path.Combine(AppContext.BaseDirectory, "PeerConnectorTests"));
            var peerAddressManager = new PeerAddressManager(DateTimeProvider.Default, peerFolder, this.extendedLoggerFactory);

            var ipAddressThree      = IPAddress.Parse("::ffff:192.168.0.3");
            var endpointConnectNode = new NetworkAddress(ipAddressThree, 80);

            var nodeSettings = new NodeSettings();

            nodeSettings.LoadArguments(new string[] { });

            var connectionSettings = new ConnectionManagerSettings();

            connectionSettings.Load(nodeSettings);

            connectionSettings.Connect.Add(endpointConnectNode.Endpoint);

            var connector = this.CreatePeerConnectorConnectNode(nodeSettings, connectionSettings, peerAddressManager);

            Assert.True(connector.CanStartConnect);
        }
        public void Load_RpcPasswordWithoutRpcUserName_ThrowsConfigurationException()
        {
            Assert.Throws <ConfigurationException>(() =>
            {
                string dir      = CreateTestDir(this);
                var confFile    = Path.Combine(dir, "bitcoin.conf");
                var configLines = new List <string>()
                {
                    "server=true",
                    "rpcport=1378",
                    "rpcpassword=testpassword",
                    "rpcallowip=0.0.0.0",
                    "rpcbind=127.0.0.1"
                };

                WriteConfigurationToFile(confFile, configLines);

                var nodeSettings = new NodeSettings(Network.TestNet);
                nodeSettings.LoadArguments(new string[] { "-conf=" + confFile });

                var rpcSettings = new RpcSettings();
                rpcSettings.Load(nodeSettings);
            });
        }
Beispiel #4
0
        /// <summary>
        /// Creates a full node with data folder set to the test folder.
        /// </summary>
        /// <param name="folderName">Data folder to use.</param>
        /// <param name="setup">Specifies startup options for the index store.</param>
        /// <returns></returns>
        private IFullNode CreateTestNode([CallerMemberName] string folderName = null, Action <IndexSettings> setup = null)
        {
            if (System.IO.Directory.Exists(folderName))
            {
                System.IO.Directory.Delete(folderName, true);
            }

            System.IO.Directory.CreateDirectory(folderName);

            NodeSettings nodeSettings = new NodeSettings("stratis", Network.StratisTest, ProtocolVersion.ALT_PROTOCOL_VERSION);

            nodeSettings = nodeSettings.LoadArguments(new string[] { $"-datadir={folderName}" });

            return(new FullNodeBuilder()
                   .UseNodeSettings(nodeSettings)
                   .UseStratisConsensus()
                   .UseIndexStore(setup)
                   .AddRPC(s =>
            {
                s.RpcUser = "******";
                s.RpcPassword = "******";
            })
                   .Build());
        }