Example #1
0
        public void GivenBitcoinTestnet_ThenUseTheCorrectPort()
        {
            // Arrange.
            NodeSettings nodeSettings = NodeSettings.Default(Network.TestNet);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.TestBitcoinApiPort, settings.ApiPort);
        }
Example #2
0
        public void GivenApiPortIsProvided_ThenPortIsUsedWithDefaultApiUri()
        {
            // Arrange.
            int          customPort   = 55555;
            NodeSettings nodeSettings = new NodeSettings(args: new[] { $"-apiport={customPort}" }, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(customPort, settings.ApiPort);
            Assert.Equal(new Uri($"{ApiSettings.DefaultApiHost}:{customPort}"), settings.ApiUri);
        }
Example #3
0
        public void GivenStratisTestnet_ThenUseTheCorrectPort()
        {
            // Arrange.
            Transaction.TimeStamp = true;
            Block.BlockSignature  = true;
            NodeSettings nodeSettings = NodeSettings.Default(Network.StratisTest);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.TestStratisApiPort, settings.ApiPort);
        }
Example #4
0
        public void GivenNoApiSettingsAreProvided_AndOnBitcoinNetwork_ThenDefaultSettingAreUsed()
        {
            // Arrange.
            Network      network      = Network.Main;
            NodeSettings nodeSettings = new NodeSettings(network, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.DefaultBitcoinApiPort, settings.ApiPort);
            Assert.Equal(new Uri($"{ApiSettings.DefaultApiHost}:{ApiSettings.DefaultBitcoinApiPort}"), settings.ApiUri);
        }
Example #5
0
        public void GivenApiUriIsProvided_AndGivenBitcoinNetwork_ThenApiUriIsUsedWithDefaultBitcoinApiPort()
        {
            // Arrange.
            string       customApiUri = "http://0.0.0.0";
            Network      network      = Network.Main;
            NodeSettings nodeSettings = new NodeSettings(network, args: new[] { $"-apiuri={customApiUri}" }, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.DefaultBitcoinApiPort, settings.ApiPort);
            Assert.Equal(new Uri($"{customApiUri}:{ApiSettings.DefaultBitcoinApiPort}"), settings.ApiUri);
        }
Example #6
0
        public void GivenNoApiSettingsAreProvided_AndOnStratisNetwork_ThenDefaultSettingAreUsed()
        {
            // Arrange.
            Transaction.TimeStamp = true;
            Block.BlockSignature  = true;
            Network      network      = Network.StratisMain;
            NodeSettings nodeSettings = new NodeSettings(network, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.DefaultStratisApiPort, settings.ApiPort);
            Assert.Equal(new Uri($"{ApiSettings.DefaultApiHost}:{ApiSettings.DefaultStratisApiPort}"), settings.ApiUri);
        }
Example #7
0
        public void GivenApiUriIncludingPortIsProvided_ThenUseThePassedApiUri()
        {
            // Arrange.
            int          customPort   = 5522;
            string       customApiUri = $"http://0.0.0.0:{customPort}";
            Network      network      = Network.Main;
            NodeSettings nodeSettings = new NodeSettings(network, args: new[] { $"-apiuri={customApiUri}" }, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(customPort, settings.ApiPort);
            Assert.Equal(new Uri($"{customApiUri}"), settings.ApiUri);
        }
Example #8
0
        public void GivenApiUri_AndApiPortIsProvided_AndGivenBitcoinNetwork_ThenApiUriIsUsedWithApiPort()
        {
            // Arrange.
            string       customApiUri = "http://0.0.0.0";
            int          customPort   = 55555;
            Network      network      = Network.Main;
            NodeSettings nodeSettings = new NodeSettings("bitcoin", network).LoadArguments(new[] { $"-apiuri={customApiUri}", $"-apiport={customPort}" });

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(customPort, settings.ApiPort);
            Assert.Equal(new Uri($"{customApiUri}:{customPort}"), settings.ApiUri);
        }
Example #9
0
        public void GivenApiUriIsProvided_AndGivenStratisNetwork_ThenApiUriIsUsedWithDefaultStratisApiPort()
        {
            // Arrange.
            Transaction.TimeStamp = true;
            Block.BlockSignature  = true;
            string       customApiUri = "http://0.0.0.0";
            Network      network      = Network.StratisMain;
            NodeSettings nodeSettings = new NodeSettings(network, args: new[] { $"-apiuri={customApiUri}" }, loadConfiguration: false);

            // Act.
            ApiSettings settings = new FullNodeBuilder()
                                   .UseNodeSettings(nodeSettings)
                                   .UseApi()
                                   .Build()
                                   .NodeService <ApiSettings>();

            settings.Load(nodeSettings);

            // Assert.
            Assert.Equal(ApiSettings.DefaultStratisApiPort, settings.ApiPort);
            Assert.Equal(new Uri($"{customApiUri}:{ApiSettings.DefaultStratisApiPort}"), settings.ApiUri);
        }