public ConnectionManagerSettingsTest()
 {
     this.connectionManager = new Mock <IConnectionManager>();
     this.mockLoggerFactory = new Mock <ILoggerFactory>();
     this.mockLoggerFactory.Setup(i => i.CreateLogger(It.IsAny <string>())).Returns(new Mock <ILogger>().Object);
     this.connectionManager.Setup(i => i.Network)
     .Returns(KnownNetworks.StratisTest);
     this.controller = new ConnectionManagerController(this.connectionManager.Object, this.LoggerFactory.Object);
 }
        public void CanCall_AddNode()
        {
            string    dir      = CreateTestDir(this);
            IFullNode fullNode = this.BuildServicedNode(dir);
            ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>();

            Assert.Throws <System.Net.Sockets.SocketException>(() => { controller.AddNode("0.0.0.0", "onetry"); });
            Assert.Throws <ArgumentException>(() => { controller.AddNode("0.0.0.0", "notarealcommand"); });
            Assert.Throws <FormatException>(() => { controller.AddNode("a.b.c.d", "onetry"); });
            Assert.True(controller.AddNode("0.0.0.0", "remove"));
        }
        public void CanCall()
        {
            string    dir      = AssureEmptyDir("Stratis.Bitcoin.Features.RPC.Tests/TestData/AddNodeActionTest/CanCall");
            IFullNode fullNode = this.BuildServicedNode(dir);
            ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>();

            Assert.Throws(typeof(System.Net.Sockets.SocketException), () => { controller.AddNode("0.0.0.0", "onetry"); });
            Assert.Throws(typeof(ArgumentException), () => { controller.AddNode("0.0.0.0", "notarealcommand"); });
            Assert.Throws(typeof(FormatException), () => { controller.AddNode("a.b.c.d", "onetry"); });
            Assert.True(controller.AddNode("0.0.0.0", "remove"));
        }
Exemplo n.º 4
0
        public void CanCall_AddNode_AddsNodeToCollection()
        {
            string testDirectory = CreateTestDir(this);

            IFullNode fullNode = this.BuildStakingNode(testDirectory);

            ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>();

            var connectionManager = fullNode.NodeService <IConnectionManager>();

            controller.AddNode("0.0.0.0", "add");
            Assert.Single(connectionManager.NodeSettings.ConnectionManager.AddNode);
        }
Exemplo n.º 5
0
        public void CanCall_AddNode_AddsNodeToCollection()
        {
            var initialBlockSignature = Block.BlockSignature;

            try
            {
                Block.BlockSignature = false;
                string testDirectory = CreateTestDir(this);

                IFullNode fullNode = this.BuildServicedNode(testDirectory);

                ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>();

                var connectionManager = fullNode.NodeService <IConnectionManager>();
                controller.AddNode("0.0.0.0", "add");
                Assert.Single(connectionManager.ConnectionSettings.AddNode);
            }
            finally
            {
                Block.BlockSignature = initialBlockSignature;
            }
        }
Exemplo n.º 6
0
        public void CanCall_AddNode()
        {
            var initialBlockSignature = Block.BlockSignature;

            try
            {
                Block.BlockSignature = false;
                string testDirectory = CreateTestDir(this);


                IFullNode fullNode = this.BuildServicedNode(testDirectory);
                ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>();

                Assert.ThrowsAny <System.Net.Sockets.SocketException>(() => { controller.AddNode("0.0.0.0", "onetry"); });
                Assert.Throws <ArgumentException>(() => { controller.AddNode("0.0.0.0", "notarealcommand"); });
                Assert.Throws <FormatException>(() => { controller.AddNode("a.b.c.d", "onetry"); });
                Assert.True(controller.AddNode("0.0.0.0", "remove"));
            }
            finally
            {
                Block.BlockSignature = initialBlockSignature;
            }
        }