From 98a959b9483458bc9ec187f7a4a20d1cdaf5d7bb Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 4 Mar 2020 11:48:21 +0000 Subject: [PATCH 1/8] Solution builds --- .../CertificateAuthority.API.csproj | 7 +- src/CertificateAuthority.API/Startup.cs | 13 +- .../CertificateAuthority.Tests.Common.csproj | 2 +- .../CertificateAuthority.Tests.csproj | 6 +- .../FullProjectTests/ControllersTests.cs | 39 +----- src/NBitcoin.Tests/NBitcoin.Tests.csproj | 3 +- .../Stratis.Bitcoin.Api.Tests.csproj | 7 +- .../ConfigureSwaggerOptions.cs | 6 +- src/Stratis.Bitcoin.Features.Api/Program.cs | 13 +- src/Stratis.Bitcoin.Features.Api/Startup.cs | 43 ++++--- .../Stratis.Bitcoin.Features.Api.csproj | 17 +-- ...s.Bitcoin.Features.BlockStore.Tests.csproj | 4 +- ...Stratis.Bitcoin.Features.BlockStore.csproj | 15 ++- .../PeerBanningTest.cs | 5 - ...rovenHeaderConsenusManagerBehaviorTests.cs | 4 +- .../Rules/CommonRules/PowCoinViewRuleTests.cs | 2 - .../Rules/TestRulesContext.cs | 2 - ...is.Bitcoin.Features.Consensus.Tests.csproj | 3 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 7 +- .../Rules/CheckTxOutDustRuleTests.cs | 1 - ...s.Bitcoin.Features.MemoryPool.Tests.csproj | 5 +- ...Stratis.Bitcoin.Features.MemoryPool.csproj | 13 +- .../Controllers/MiningControllerTest.cs | 1 - ...tratis.Bitcoin.Features.Miner.Tests.csproj | 5 +- .../Stratis.Bitcoin.Features.Miner.csproj | 9 +- ...itcoin.Features.Notifications.Tests.csproj | 5 +- ...atis.Bitcoin.Features.Notifications.csproj | 15 ++- ...eatures.PoA.IntegrationTests.Common.csproj | 3 +- ...tcoin.Features.PoA.IntegrationTests.csproj | 5 +- .../Stratis.Bitcoin.Features.PoA.Tests.csproj | 3 +- .../Stratis.Bitcoin.Features.PoA.csproj | 5 +- .../Controller/RPCControllerTest.cs | 3 +- .../RPCJsonMvcOptionsSetupTest.cs | 2 +- .../Stratis.Bitcoin.Features.RPC.Tests.csproj | 9 +- .../Stratis.Bitcoin.Features.RPC.csproj | 29 +++-- .../Program.cs | 1 + .../Startup.cs | 14 ++- .../Stratis.Bitcoin.Features.SignalR.csproj | 35 +++--- .../Consensus/Rules/CanGetSenderRuleTest.cs | 2 - .../Consensus/Rules/TestRulesContext.cs | 3 - ...tcoin.Features.SmartContracts.Tests.csproj | 3 +- ...tis.Bitcoin.Features.SmartContracts.csproj | 8 +- ...ratis.Bitcoin.Features.Wallet.Tests.csproj | 7 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 15 ++- .../EnvironmentMockUpHelpers/CoreNode.cs | 1 - ...tis.Bitcoin.IntegrationTests.Common.csproj | 3 +- .../MinerTests.cs | 1 - .../Stratis.Bitcoin.IntegrationTests.csproj | 5 +- .../Logging/LogsTestBase.cs | 51 +++++--- .../Stratis.Bitcoin.Tests.Common.csproj | 7 +- ...Stratis.Bitcoin.Tests.Wallet.Common.csproj | 3 +- .../ConsensusManagerBehaviorTestsHelper.cs | 1 - .../BlockPulling/BlockPullerBehaviorTests.cs | 2 - .../BlockPulling/BlockPullerTestsHelper.cs | 1 - .../EnforcePeerVersionCheckBehaviorTests.cs | 4 +- .../P2P/NetworkPeerServerTests.cs | 1 - .../P2P/PeerAddressManagerBehaviourTests.cs | 1 - .../P2P/PeerConnectorTests.cs | 1 - .../P2P/PeerSelectorTests.cs | 1 - .../Stratis.Bitcoin.Tests.csproj | 6 +- .../Utilities/AsyncProviderTest.cs | 27 ++-- .../Logging/LoggingConfiguration.cs | 115 +++++++----------- .../Configuration/NodeSettings.cs | 21 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 13 +- src/Stratis.Bitcoin/Utilities/PrefixLogger.cs | 13 +- ...Stratis.Feature.PoA.Tokenless.Tests.csproj | 2 +- .../TokenlessTestHelper.cs | 1 - .../Stratis.Feature.PoA.Tokenless.csproj | 2 +- ...atures.SQLiteWalletRepository.Tests.csproj | 9 +- ...tis.Features.SQLiteWalletRepository.csproj | 12 +- .../ContractExecutorTestContext.cs | 3 +- .../ContractRefundProcessorTests.cs | 1 - .../ContractTransferProcessorTests.cs | 7 +- .../Stratis.SmartContracts.CLR.Tests.csproj | 5 +- ...SmartContracts.CLR.Validation.Tests.csproj | 3 +- ...ratis.SmartContracts.CLR.Validation.csproj | 5 +- .../Stratis.SmartContracts.CLR.csproj | 5 +- .../Stratis.SmartContracts.Core.Tests.csproj | 3 +- .../Stratis.SmartContracts.Core.csproj | 7 +- ...tis.SmartContracts.IntegrationTests.csproj | 3 +- .../Stratis.SmartContracts.Networks.csproj | 5 +- ...atis.SmartContracts.RuntimeObserver.csproj | 5 +- ...Stratis.SmartContracts.Tests.Common.csproj | 3 +- .../Stratis.SmartContracts.Tokenless.csproj | 3 +- .../Stratis.TokenlessD.csproj | 9 +- 85 files changed, 357 insertions(+), 413 deletions(-) diff --git a/src/CertificateAuthority.API/CertificateAuthority.API.csproj b/src/CertificateAuthority.API/CertificateAuthority.API.csproj index c5ec0211ae1..fef573ae968 100644 --- a/src/CertificateAuthority.API/CertificateAuthority.API.csproj +++ b/src/CertificateAuthority.API/CertificateAuthority.API.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 InProcess AspNetCoreModuleV2 true @@ -9,10 +9,9 @@ - - + - + diff --git a/src/CertificateAuthority.API/Startup.cs b/src/CertificateAuthority.API/Startup.cs index 907afcad841..cf9995ca687 100644 --- a/src/CertificateAuthority.API/Startup.cs +++ b/src/CertificateAuthority.API/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Swashbuckle.AspNetCore.Swagger; +using Microsoft.OpenApi.Models; namespace CertificateAuthority.API { @@ -29,7 +29,7 @@ public virtual void ConfigureServices(IServiceCollection services) .AddApplicationPart(typeof(HelpersController).GetTypeInfo().Assembly); services.AddSwaggerGen(c => - c.SwaggerDoc("v1", new Info { Title = "Stratis Certificate Authority API V1", Version = "v1" } + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Stratis Certificate Authority API V1", Version = "v1" } )); services.AddSingleton(); @@ -42,6 +42,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.ApplicationServices.GetService().Initialize(); app.ApplicationServices.GetService().Initialize(); + app.UseRouting(); + // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); @@ -55,7 +57,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHsts(); app.UseHttpsRedirection(); - app.UseMvc(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + endpoints.MapDefaultControllerRoute(); + }); } } } \ No newline at end of file diff --git a/src/CertificateAuthority.Tests.Common/CertificateAuthority.Tests.Common.csproj b/src/CertificateAuthority.Tests.Common/CertificateAuthority.Tests.Common.csproj index b55030d4707..d30615d319c 100644 --- a/src/CertificateAuthority.Tests.Common/CertificateAuthority.Tests.Common.csproj +++ b/src/CertificateAuthority.Tests.Common/CertificateAuthority.Tests.Common.csproj @@ -2,7 +2,7 @@ Library - netcoreapp2.1 + netcoreapp3.1 diff --git a/src/CertificateAuthority.Tests/CertificateAuthority.Tests.csproj b/src/CertificateAuthority.Tests/CertificateAuthority.Tests.csproj index 2f2fa438520..5280f75cd04 100644 --- a/src/CertificateAuthority.Tests/CertificateAuthority.Tests.csproj +++ b/src/CertificateAuthority.Tests/CertificateAuthority.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 false @@ -11,8 +11,8 @@ - - + + all diff --git a/src/CertificateAuthority.Tests/FullProjectTests/ControllersTests.cs b/src/CertificateAuthority.Tests/FullProjectTests/ControllersTests.cs index 50b3dc7ff9e..c39c8866e47 100644 --- a/src/CertificateAuthority.Tests/FullProjectTests/ControllersTests.cs +++ b/src/CertificateAuthority.Tests/FullProjectTests/ControllersTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; using CertificateAuthority.Controllers; using CertificateAuthority.Database; using CertificateAuthority.Models; @@ -295,7 +294,7 @@ public void CanIssueCertificateViaTemplateCsr() } [Fact] - public async Task CantRequestCertificateTwiceForSameIdentityAndCanReset() + public void CantRequestCertificateTwiceForSameIdentityAndCanReset() { CredentialsModel credentials1 = this.GetPrivilegedAccount(); @@ -459,41 +458,5 @@ private void Returns403IfNoAccess(Func action, AccountAcces break; } } - - private void CheckThrowsIfNoAccess(Action action, AccountAccessFlags requiredAccess) - { - CredentialsModel noAccessCredentials = CaTestHelper.CreateAccount(this.server.Host); - bool throwsIfNoAccess = false; - - try - { - action.Invoke(noAccessCredentials.AccountId, noAccessCredentials.Password); - } - catch (InvalidCredentialsException e) - { - Assert.Equal(CredentialsExceptionErrorCodes.InvalidAccess, e.ErrorCode); - throwsIfNoAccess = true; - } - catch (Exception e) - { - } - - if (!throwsIfNoAccess) - Assert.False(true, "Action was expected to throw."); - - CredentialsModel accessCredentials = CaTestHelper.CreateAccount(this.server.Host, requiredAccess); - - try - { - action.Invoke(accessCredentials.AccountId, accessCredentials.Password); - } - catch (InvalidCredentialsException e) - { - Assert.False(true, "Action was expected to not throw or throw different exception."); - } - catch (Exception) - { - } - } } } \ No newline at end of file diff --git a/src/NBitcoin.Tests/NBitcoin.Tests.csproj b/src/NBitcoin.Tests/NBitcoin.Tests.csproj index ec27caea5c0..ec37849855a 100644 --- a/src/NBitcoin.Tests/NBitcoin.Tests.csproj +++ b/src/NBitcoin.Tests/NBitcoin.Tests.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 diff --git a/src/Stratis.Bitcoin.Api.Tests/Stratis.Bitcoin.Api.Tests.csproj b/src/Stratis.Bitcoin.Api.Tests/Stratis.Bitcoin.Api.Tests.csproj index f59865b7471..7f8b3894b92 100644 --- a/src/Stratis.Bitcoin.Api.Tests/Stratis.Bitcoin.Api.Tests.csproj +++ b/src/Stratis.Bitcoin.Api.Tests/Stratis.Bitcoin.Api.Tests.csproj @@ -1,20 +1,19 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Api.Tests Stratis.Bitcoin.Api.Tests true - 2.1.1 - + all runtime; build; native; contentfiles; analyzers - + diff --git a/src/Stratis.Bitcoin.Features.Api/ConfigureSwaggerOptions.cs b/src/Stratis.Bitcoin.Features.Api/ConfigureSwaggerOptions.cs index 1f555531ced..53b25395a3a 100644 --- a/src/Stratis.Bitcoin.Features.Api/ConfigureSwaggerOptions.cs +++ b/src/Stratis.Bitcoin.Features.Api/ConfigureSwaggerOptions.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.Extensions.PlatformAbstractions; -using Swashbuckle.AspNetCore.Swagger; +using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; namespace Stratis.Bitcoin.Features.Api @@ -58,9 +58,9 @@ public void Configure(SwaggerGenOptions options) options.DescribeAllEnumsAsStrings(); } - static Info CreateInfoForApiVersion(ApiVersionDescription description) + static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription description) { - var info = new Info() + var info = new OpenApiInfo() { Title = "Stratis Node API", Version = description.ApiVersion.ToString(), diff --git a/src/Stratis.Bitcoin.Features.Api/Program.cs b/src/Stratis.Bitcoin.Features.Api/Program.cs index fe8d57dc056..9c76a617598 100644 --- a/src/Stratis.Bitcoin.Features.Api/Program.cs +++ b/src/Stratis.Bitcoin.Features.Api/Program.cs @@ -20,8 +20,8 @@ public static IWebHost Initialize(IEnumerable services, FullN Uri apiUri = apiSettings.ApiUri; - X509Certificate2 certificate = apiSettings.UseHttps - ? GetHttpsCertificate(apiSettings.HttpsCertificateFilePath, store) + X509Certificate2 certificate = apiSettings.UseHttps + ? GetHttpsCertificate(apiSettings.HttpsCertificateFilePath, store) : null; webHostBuilder @@ -30,9 +30,10 @@ public static IWebHost Initialize(IEnumerable services, FullN if (!apiSettings.UseHttps) return; - Action configureListener = listenOptions => { listenOptions.UseHttps(certificate); }; - var ipAddresses = Dns.GetHostAddresses(apiSettings.ApiUri.DnsSafeHost); - foreach (var ipAddress in ipAddresses) + options.AllowSynchronousIO = true; + void configureListener(ListenOptions listenOptions) { listenOptions.UseHttps(certificate); } + IPAddress[] ipAddresses = Dns.GetHostAddresses(apiSettings.ApiUri.DnsSafeHost); + foreach (IPAddress ipAddress in ipAddresses) { options.Listen(ipAddress, apiSettings.ApiPort, configureListener); } @@ -72,7 +73,7 @@ public static IWebHost Initialize(IEnumerable services, FullN .UseStartup(); IWebHost host = webHostBuilder.Build(); - + host.Start(); return host; diff --git a/src/Stratis.Bitcoin.Features.Api/Startup.cs b/src/Stratis.Bitcoin.Features.Api/Startup.cs index 3809d84cd77..f46dba645a0 100644 --- a/src/Stratis.Bitcoin.Features.Api/Startup.cs +++ b/src/Stratis.Bitcoin.Features.Api/Startup.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Versioning; @@ -8,7 +6,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Stratis.Bitcoin.Builder.Feature; using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerUI; @@ -16,10 +13,10 @@ namespace Stratis.Bitcoin.Features.Api { public class Startup { - public Startup(IHostingEnvironment env, IFullNode fullNode, ApiFeatureOptions apiFeatureOptions) + public Startup(IWebHostEnvironment env, IFullNode fullNode) { this.fullNode = fullNode; - this.apiFeatureOptions = apiFeatureOptions; + IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) @@ -30,13 +27,20 @@ public Startup(IHostingEnvironment env, IFullNode fullNode, ApiFeatureOptions ap } private readonly IFullNode fullNode; - private readonly ApiFeatureOptions apiFeatureOptions; public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddLogging( + loggingBuilder => + { + loggingBuilder.AddConfiguration(this.Configuration.GetSection("Logging")); + loggingBuilder.AddConsole(); + loggingBuilder.AddDebug(); + }); + // Add service and create Policy to allow Cross-Origin Requests services.AddCors ( @@ -59,13 +63,9 @@ public void ConfigureServices(IServiceCollection services) ); }); - // Filters api features based on options provide. - IEnumerable features = this.apiFeatureOptions.Includes.Any() - ? this.fullNode.Services.Features.Where(feature => this.apiFeatureOptions.Includes.Contains(feature.GetType())) - : this.fullNode.Services.Features.Where(feature => !this.apiFeatureOptions.Excludes.Contains(feature.GetType())); - // Add framework services. - services.AddMvc(options => + services + .AddMvc(options => { options.Filters.Add(typeof(LoggingActionFilter)); @@ -76,9 +76,9 @@ public void ConfigureServices(IServiceCollection services) options.Filters.Add(typeof(KeepaliveActionFilter)); } }) - // Add serializers for NBitcoin objects. - .AddJsonOptions(options => Utilities.JsonConverters.Serializer.RegisterFrontConverters(options.SerializerSettings)) - .AddControllers(features, services); + // add serializers for NBitcoin objects + .AddNewtonsoftJson(options => Utilities.JsonConverters.Serializer.RegisterFrontConverters(options.SerializerSettings)) + .AddControllers(this.fullNode.Services.Features, services); // Enable API versioning. // Note much of this is borrowed from https://github.com/microsoft/aspnet-api-versioning/blob/master/samples/aspnetcore/SwaggerSample/Startup.cs @@ -110,17 +110,20 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider) { - loggerFactory.AddConsole(this.Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); + app.UseStaticFiles(); + app.UseRouting(); app.UseCors("CorsPolicy"); // Register this before MVC and Swagger. app.UseMiddleware(); - app.UseMvc(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index faa6673d45a..d0d33d5fdeb 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 true Stratis.Bitcoin.Features.Api Library @@ -23,13 +23,16 @@ - - - - - + + + + + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj b/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj index c50d6ec9c3f..d11d1c3dcc7 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.BlockStore.Tests Stratis.Bitcoin.Features.BlockStore.Tests true @@ -27,7 +27,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index f6bbedcc850..8afd9f1b7d2 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -19,13 +19,16 @@ Stratis Group Ltd. - - - - + + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/PeerBanningTest.cs b/src/Stratis.Bitcoin.Features.Consensus.Tests/PeerBanningTest.cs index 19a48e2edec..f6d34a16291 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/PeerBanningTest.cs +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/PeerBanningTest.cs @@ -246,7 +246,6 @@ public void PeerBanning_Add_Peer_To_Address_Manager_And_Ban() var dataFolder = CreateDataFolder(this); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); var ipAddress = IPAddress.Parse("::ffff:192.168.0.1"); var endpoint = new IPEndPoint(ipAddress, 80); @@ -279,7 +278,6 @@ public void PeerBanning_Add_WhiteListed_Peer_Does_Not_Get_Banned() var dataFolder = CreateDataFolder(this); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); var ipAddress = IPAddress.Parse("::ffff:192.168.0.1"); var endpoint = new IPEndPoint(ipAddress, 80); @@ -323,7 +321,6 @@ public void PeerBanning_Add_Peers_To_Address_Manager_And_Ban_IP_Range() var dataFolder = CreateDataFolder(this); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); var ipAddress80 = IPAddress.Parse("::ffff:192.168.0.1"); var endpoint80 = new IPEndPoint(ipAddress80, 80); @@ -366,7 +363,6 @@ public void PeerBanning_SavingAndLoading_BannedPeerToAddressManager() DataFolder dataFolder = CreateDataFolder(this); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); IPAddress ipAddress = IPAddress.Parse("::ffff:192.168.0.1"); var endpoint = new IPEndPoint(ipAddress, 80); @@ -403,7 +399,6 @@ public void PeerBanning_Resetting_Expired_BannedPeer() DataFolder dataFolder = CreateDataFolder(this); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); IPAddress ipAddress = IPAddress.Parse("::ffff:192.168.0.1"); var endpoint = new IPEndPoint(ipAddress, 80); diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/ProvenBlockHeaders/ProvenHeaderConsenusManagerBehaviorTests.cs b/src/Stratis.Bitcoin.Features.Consensus.Tests/ProvenBlockHeaders/ProvenHeaderConsenusManagerBehaviorTests.cs index 2dd2affb32b..ed48f8d3181 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/ProvenBlockHeaders/ProvenHeaderConsenusManagerBehaviorTests.cs +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/ProvenBlockHeaders/ProvenHeaderConsenusManagerBehaviorTests.cs @@ -5,8 +5,8 @@ using System.Threading.Tasks; using Moq; using NBitcoin; -using Stratis.Bitcoin.Base; using Stratis.Bitcoin.AsyncWork; +using Stratis.Bitcoin.Base; using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Configuration.Settings; @@ -42,7 +42,7 @@ public ProvenHeaderConsenusManagerBehaviorTests() : base(new StratisTest()) this.chainState = new Mock().Object; this.checkpoints = new Mock().Object; this.connectionManagerSettings = new ConnectionManagerSettings(NodeSettings.Default(this.Network)); - this.extendedLoggerFactory = new ExtendedLoggerFactory(); this.extendedLoggerFactory.AddConsoleWithFilters(); + this.extendedLoggerFactory = new ExtendedLoggerFactory(); this.initialBlockDownloadState = new Mock().Object; this.peerBanning = new Mock().Object; this.provenBlockHeaderStore = new Mock().Object; diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/CommonRules/PowCoinViewRuleTests.cs b/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/CommonRules/PowCoinViewRuleTests.cs index 7210e59ceea..7aa70545038 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/CommonRules/PowCoinViewRuleTests.cs +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/CommonRules/PowCoinViewRuleTests.cs @@ -12,7 +12,6 @@ using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; -using Stratis.Bitcoin.Features.Consensus.CoinViews; using Stratis.Bitcoin.Features.Consensus.Rules; using Stratis.Bitcoin.Features.Consensus.Rules.CommonRules; using Stratis.Bitcoin.Signals; @@ -93,7 +92,6 @@ protected void WhenExecutingTheRule(ConsensusRuleBase rule, RuleContext ruleCont rule.Logger = this.logger.Object; var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); var dateTimeProvider = new DateTimeProvider(); diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/TestRulesContext.cs b/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/TestRulesContext.cs index 514c6f68100..caeadc686e1 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/TestRulesContext.cs +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/Rules/TestRulesContext.cs @@ -10,7 +10,6 @@ using Stratis.Bitcoin.Base; using Stratis.Bitcoin.Base.Deployments; using Stratis.Bitcoin.Configuration; -using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; @@ -175,7 +174,6 @@ public static TestRulesContext CreateAsync(Network network, [CallerMemberName]st testRulesContext.NodeSettings = new NodeSettings(network, args: new[] { $"-datadir={dataDir}" }); testRulesContext.LoggerFactory = testRulesContext.NodeSettings.LoggerFactory; - testRulesContext.LoggerFactory.AddConsoleWithFilters(); testRulesContext.DateTimeProvider = DateTimeProvider.Default; network.Consensus.Options = new ConsensusOptions(); diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj b/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj index 7e7de04a521..0009721c553 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.Consensus.Tests Stratis.Bitcoin.Features.Consensus.Tests true - 2.1.1 false false false diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index ec222a0b368..18652235d4b 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -26,8 +26,11 @@ - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Rules/CheckTxOutDustRuleTests.cs b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Rules/CheckTxOutDustRuleTests.cs index edfff73b487..b553d29ac7b 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Rules/CheckTxOutDustRuleTests.cs +++ b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Rules/CheckTxOutDustRuleTests.cs @@ -23,7 +23,6 @@ public CheckTxOutDustRuleTests() this.network = new StratisMain(); this.chainIndexer = new ChainIndexer(this.network); this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); this.nodeSettings = NodeSettings.Default(this.network); this.txMempool = new Mock().Object; } diff --git a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj index bbb0511f8d0..a37f32fb1fa 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.MemoryPool.Tests Stratis.Bitcoin.Features.MemoryPool.Tests true - 2.1.1 false false false @@ -27,7 +26,7 @@ - + all diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 61566493956..16f2e50875a 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -22,12 +22,15 @@ Stratis Group Ltd. - - - + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.Miner.Tests/Controllers/MiningControllerTest.cs b/src/Stratis.Bitcoin.Features.Miner.Tests/Controllers/MiningControllerTest.cs index 8df8d36cb73..41359447b49 100644 --- a/src/Stratis.Bitcoin.Features.Miner.Tests/Controllers/MiningControllerTest.cs +++ b/src/Stratis.Bitcoin.Features.Miner.Tests/Controllers/MiningControllerTest.cs @@ -38,7 +38,6 @@ public MiningControllerTest() this.fullNode.Setup(i => i.Network).Returns(this.network); this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); this.fullNode.Setup(i => i.NodeService(false)).Returns(this.loggerFactory); } diff --git a/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj b/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj index 3780342afa3..aaecfdfa26c 100644 --- a/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj @@ -2,11 +2,10 @@ false - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.Miner.Tests Stratis.Bitcoin.Features.Miner.Tests true - 2.1.1 false false false @@ -22,7 +21,7 @@ - + all diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 418c4f1d05b..c75387d589e 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -26,9 +26,12 @@ - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj b/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj index 05c12c19224..7c07f893629 100644 --- a/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.Notifications.Tests Stratis.Bitcoin.Features.Notifications.Tests true - 2.1.1 false false false @@ -27,7 +26,7 @@ - + all diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index 58727991437..c170243f8fb 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -19,13 +19,16 @@ Stratis Group Ltd. - - - - + + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index 6a7d48d4030..491c7c69ca6 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 Stratis.Bitcoin.Features.PoA.IntegrationTests.Common Stratis.Bitcoin.Features.PoA.IntegrationTests.Common false diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/Stratis.Bitcoin.Features.PoA.IntegrationTests.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/Stratis.Bitcoin.Features.PoA.IntegrationTests.csproj index b336b9779bc..c1873d80176 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/Stratis.Bitcoin.Features.PoA.IntegrationTests.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/Stratis.Bitcoin.Features.PoA.IntegrationTests.csproj @@ -2,13 +2,12 @@ Exe - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj b/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj index bf8acf89334..3cac4be5fcc 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj @@ -2,8 +2,7 @@ Exe - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index 387914f26fa..384b114eeef 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -20,7 +20,10 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/Controller/RPCControllerTest.cs b/src/Stratis.Bitcoin.Features.RPC.Tests/Controller/RPCControllerTest.cs index 45e48828f22..97f87c45752 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/Controller/RPCControllerTest.cs +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/Controller/RPCControllerTest.cs @@ -6,7 +6,6 @@ using System.Text; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Controllers; @@ -187,7 +186,7 @@ public void CallByName_RpcMethodNotFound_ReturnsErrorResult() this.controller.ControllerContext.HttpContext = new DefaultHttpContext(); this.controller.ControllerContext.HttpContext.Request.Query = new QueryCollection(values); - var body = JObject.FromObject(new {methodName = "getblockheader"}); + var body = JObject.FromObject(new { methodName = "getblockheader" }); IActionResult controllerResult = this.controller.CallByName(body); var errorResult = Assert.IsType(controllerResult); diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs index ad468941c65..debbf54c568 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs @@ -15,7 +15,7 @@ public void ConfigureMvcReplacesJsonFormattedWithRPCJsonOutputFormatter() ArrayPool charpool = ArrayPool.Create(); var options = new MvcOptions(); options.OutputFormatters.Clear(); - options.OutputFormatters.Add(new JsonOutputFormatter(settings, charpool)); + options.OutputFormatters.Add(new NewtonsoftJsonOutputFormatter(settings, charpool, options)); RPCJsonMvcOptionsSetup.ConfigureMvc(options, settings, null, charpool, null); diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj b/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj index a723f39f8bc..adb0242a142 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.RPC.Tests Stratis.Bitcoin.Features.RPC.Tests true - 2.1.1 false false false @@ -27,8 +26,10 @@ - - + + + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 7c5db20d5e1..cb9271909b0 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -19,21 +19,24 @@ Stratis Group Ltd. - - - - - - - - - - - + + + + + + + + + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.Features.SignalR/Program.cs b/src/Stratis.Bitcoin.Features.SignalR/Program.cs index 8846bb8ce6f..15e193b6c8d 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Program.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/Program.cs @@ -18,6 +18,7 @@ public static IWebHost Initialize(IEnumerable services, FullN Uri uri = settings.SignalRUri; webHostBuilder + .UseKestrel(o => o.AllowSynchronousIO = true) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/src/Stratis.Bitcoin.Features.SignalR/Startup.cs b/src/Stratis.Bitcoin.Features.SignalR/Startup.cs index 0769e042b13..6683bf46cd6 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Startup.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/Startup.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Stratis.Bitcoin.Utilities.JsonConverters; @@ -19,7 +20,7 @@ public void ConfigureServices(IServiceCollection services) "CorsPolicy", builder => { - var allowedDomains = new[] {"http://localhost", "http://localhost:4200"}; + var allowedDomains = new[] { "http://localhost", "http://localhost:4200" }; builder .WithOrigins(allowedDomains) @@ -28,7 +29,7 @@ public void ConfigureServices(IServiceCollection services) .AllowCredentials(); }); }); - services.AddSignalR().AddJsonProtocol(options => + services.AddSignalR().AddNewtonsoftJsonProtocol(options => { var settings = new JsonSerializerSettings(); Serializer.RegisterFrontConverters(settings); @@ -36,16 +37,21 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider) { + app.UseRouting(); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); - app.UseSignalR(route => { route.MapHub("/events-hub"); }); + app.UseEndpoints(endpoints => + { + endpoints.MapHub("/events-hub"); + }); } } } \ No newline at end of file diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index a5b9a2c216b..34eac29bc0c 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,19 +1,22 @@  - - netcoreapp2.1 - 2.1.1 - 3.0.6.0-beta - - - - - - - - - - - - + + netcoreapp3.1 + 3.0.6.0-beta + + + + + + + + + + + + + + + + diff --git a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/CanGetSenderRuleTest.cs b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/CanGetSenderRuleTest.cs index 552285038d1..9e19ceb0249 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/CanGetSenderRuleTest.cs +++ b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/CanGetSenderRuleTest.cs @@ -11,7 +11,6 @@ using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; -using Stratis.Bitcoin.Features.Consensus.CoinViews; using Stratis.Bitcoin.Features.Consensus.Rules; using Stratis.Bitcoin.Features.MemoryPool; using Stratis.Bitcoin.Features.MemoryPool.Interfaces; @@ -38,7 +37,6 @@ public class CanGetSenderRuleTest public CanGetSenderRuleTest() { var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); this.network = new SmartContractsRegTest(); this.senderRetriever = new Mock(); diff --git a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/TestRulesContext.cs b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/TestRulesContext.cs index 06434996db3..c3ce831ec43 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/TestRulesContext.cs +++ b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Consensus/Rules/TestRulesContext.cs @@ -7,11 +7,9 @@ using Stratis.Bitcoin.Base; using Stratis.Bitcoin.Base.Deployments; using Stratis.Bitcoin.Configuration; -using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; -using Stratis.Bitcoin.Features.Consensus; using Stratis.Bitcoin.Features.Consensus.Rules; using Stratis.Bitcoin.Features.SmartContracts.ReflectionExecutor.Consensus.Rules; using Stratis.Bitcoin.Features.SmartContracts.Rules; @@ -90,7 +88,6 @@ public static TestRulesContext CreateAsync(Network network, [CallerMemberName]st testRulesContext.NodeSettings = new NodeSettings(network, args: new[] { $"-datadir={dataDir}" }); testRulesContext.LoggerFactory = testRulesContext.NodeSettings.LoggerFactory; - testRulesContext.LoggerFactory.AddConsoleWithFilters(); testRulesContext.DateTimeProvider = DateTimeProvider.Default; network.Consensus.Options = new ConsensusOptions(); diff --git a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj index 0899c274132..fa4eb137d44 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.SmartContracts.Tests Stratis.Bitcoin.Features.SmartContracts.Tests true - 2.1.1 false false false diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 4e5754bd7dc..88c17532159 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 2.1.1 1.0.2.0-beta Stratis Group Ltd. @@ -11,10 +11,10 @@ bin\Debug\netcoreapp2.1\Stratis.Bitcoin.Features.SmartContracts.xml - - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj b/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj index 74d8c62e78c..68d0b88a0e3 100644 --- a/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Features.Wallet.Tests Stratis.Bitcoin.Features.Wallet.Tests true - 2.1.1 false false false @@ -27,8 +26,8 @@ - - + + all diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index e9f37af6246..5aa9ce7631a 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -25,14 +25,17 @@ - - - - + + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/EnvironmentMockUpHelpers/CoreNode.cs b/src/Stratis.Bitcoin.IntegrationTests.Common/EnvironmentMockUpHelpers/CoreNode.cs index d1934287ecf..1a4ad7d79e7 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/EnvironmentMockUpHelpers/CoreNode.cs +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/EnvironmentMockUpHelpers/CoreNode.cs @@ -106,7 +106,6 @@ public CoreNode(NodeRunner runner, NodeConfigParameters configParameters, string this.ConfigParameters.SetDefaultValueIfUndefined("apiport", randomFoundPorts[2].ToString()); this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); CreateConfigFile(this.ConfigParameters); } diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index f4432b3d028..58a480dd7f2 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 Stratis.Bitcoin.IntegrationTests.Common Stratis.Bitcoin.IntegrationTests.Common false diff --git a/src/Stratis.Bitcoin.IntegrationTests/MinerTests.cs b/src/Stratis.Bitcoin.IntegrationTests/MinerTests.cs index ce023cad304..fef4149a0cc 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/MinerTests.cs +++ b/src/Stratis.Bitcoin.IntegrationTests/MinerTests.cs @@ -147,7 +147,6 @@ public async Task InitializeAsync() IDateTimeProvider dateTimeProvider = DateTimeProvider.Default; var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); var inMemoryCoinView = new InMemoryCoinView(this.ChainIndexer.Tip.HashBlock); var nodeStats = new NodeStats(dateTimeProvider, loggerFactory); diff --git a/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj b/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj index d4bdc0dba0a..efb37a89184 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj @@ -5,11 +5,10 @@ - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.IntegrationTests Stratis.Bitcoin.IntegrationTests true - 2.1.1 false false false @@ -54,7 +53,7 @@ - + all diff --git a/src/Stratis.Bitcoin.Tests.Common/Logging/LogsTestBase.cs b/src/Stratis.Bitcoin.Tests.Common/Logging/LogsTestBase.cs index a9048e5577e..f9a817cd620 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Logging/LogsTestBase.cs +++ b/src/Stratis.Bitcoin.Tests.Common/Logging/LogsTestBase.cs @@ -1,6 +1,7 @@ using System; +using System.Collections.Generic; +using FluentAssertions; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Internal; using Moq; using NBitcoin; using Stratis.Bitcoin.AsyncWork; @@ -50,29 +51,43 @@ private void Initialise() protected void AssertLog(Mock logger, LogLevel logLevel, string exceptionMessage, string message) where T : Exception { - logger.Verify(f => f.Log(logLevel, - It.IsAny(), - It.Is(l => ((FormattedLogValues)l)[0].Value.ToString().EndsWith(message)), - It.Is(t => t.Message.Equals(exceptionMessage)), - It.IsAny>())); + logger + .Setup(f => f.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny())) + .Callback(new InvocationAction(invocation => + { + if ((LogLevel)invocation.Arguments[0] == logLevel) + { + invocation.Arguments[2].ToString().Should().EndWith(message); + ((T)invocation.Arguments[3]).Message.Should().Be(exceptionMessage); + } + })); } protected void AssertLog(Mock> logger, LogLevel logLevel, string exceptionMessage, string message) where T : Exception { - logger.Verify(f => f.Log(logLevel, - It.IsAny(), - It.Is(l => ((FormattedLogValues)l)[0].Value.ToString().EndsWith(message)), - It.Is(t => t.Message.Equals(exceptionMessage)), - It.IsAny>())); + logger + .Setup(f => f.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny())) + .Callback(new InvocationAction(invocation => + { + if ((LogLevel)invocation.Arguments[0] == logLevel) + { + invocation.Arguments[2].ToString().Should().EndWith(message); + ((T)invocation.Arguments[3]).Message.Should().Be(exceptionMessage); + } + })); } protected void AssertLog(Mock logger, LogLevel logLevel, string message) { - logger.Verify(f => f.Log(logLevel, - It.IsAny(), - It.Is(l => ((FormattedLogValues)l)[0].Value.ToString().EndsWith(message)), - It.IsAny(), - It.IsAny>())); + logger + .Setup(f => f.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny())) + .Callback(new InvocationAction(invocation => + { + if ((LogLevel)invocation.Arguments[0] == logLevel) + { + invocation.Arguments[2].ToString().Should().EndWith(message); + } + })); } /* TODO: Re-factor @@ -90,7 +105,7 @@ protected void AssertLog(Mock> logger, LogLevel logLevel, stri { logger.Verify(f => f.Log(logLevel, It.IsAny(), - It.Is(l => ((FormattedLogValues)l)[0].Value.ToString().EndsWith(message)), + It.Is(l => ((IReadOnlyList>)l)[0].Value.ToString().EndsWith(message)), null, It.IsAny>())); } @@ -105,4 +120,4 @@ protected IAsyncProvider CreateAsyncProvider() return asyncProvider; } } -} +} \ No newline at end of file diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index 1b50b284dc2..2d9424af248 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 Stratis.Bitcoin.Tests.Common Stratis.Bitcoin.Tests.Common false @@ -18,8 +17,8 @@ - - + + all diff --git a/src/Stratis.Bitcoin.Tests.Wallet.Common/Stratis.Bitcoin.Tests.Wallet.Common.csproj b/src/Stratis.Bitcoin.Tests.Wallet.Common/Stratis.Bitcoin.Tests.Wallet.Common.csproj index e51cdb00920..96a22b1c32e 100644 --- a/src/Stratis.Bitcoin.Tests.Wallet.Common/Stratis.Bitcoin.Tests.Wallet.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Wallet.Common/Stratis.Bitcoin.Tests.Wallet.Common.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 Stratis.Bitcoin.Tests.Wallet.Common Stratis.Bitcoin.Tests.Wallet.Common false diff --git a/src/Stratis.Bitcoin.Tests/Base/ConsensusManagerBehaviorTestsHelper.cs b/src/Stratis.Bitcoin.Tests/Base/ConsensusManagerBehaviorTestsHelper.cs index c76e02e7a26..40ed3d0cc0e 100644 --- a/src/Stratis.Bitcoin.Tests/Base/ConsensusManagerBehaviorTestsHelper.cs +++ b/src/Stratis.Bitcoin.Tests/Base/ConsensusManagerBehaviorTestsHelper.cs @@ -52,7 +52,6 @@ public class ConsensusManagerBehaviorTestsHelper public ConsensusManagerBehaviorTestsHelper() { this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); } private readonly ExtendedLoggerFactory loggerFactory; diff --git a/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerBehaviorTests.cs b/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerBehaviorTests.cs index 35f6c7408a0..78bef108c7d 100644 --- a/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerBehaviorTests.cs +++ b/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerBehaviorTests.cs @@ -22,7 +22,6 @@ public BlockPullerBehaviorTests() ibdState.Setup(x => x.IsInitialBlockDownload()).Returns(() => true); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); this.behavior = new BlockPullerBehavior(puller.Object, ibdState.Object, DateTimeProvider.Default, loggerFactory); } @@ -77,7 +76,6 @@ public void SpeedCalculatedCorrectlyWhenSeveralBehaviorsStall() ibdState.Setup(x => x.IsInitialBlockDownload()).Returns(() => true); var loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); behaviors.Add(new BlockPullerBehavior(puller.Object, ibdState.Object, DateTimeProvider.Default, loggerFactory)); } diff --git a/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerTestsHelper.cs b/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerTestsHelper.cs index 50b27ca88ea..c9759ad2038 100644 --- a/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerTestsHelper.cs +++ b/src/Stratis.Bitcoin.Tests/BlockPulling/BlockPullerTestsHelper.cs @@ -42,7 +42,6 @@ public class BlockPullerTestsHelper public BlockPullerTestsHelper() { this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); this.CallbacksCalled = new Dictionary(); this.ChainState = new ChainState() { ConsensusTip = ChainedHeadersHelper.CreateGenesisChainedHeader() }; diff --git a/src/Stratis.Bitcoin.Tests/P2P/EnforcePeerVersionCheckBehaviorTests.cs b/src/Stratis.Bitcoin.Tests/P2P/EnforcePeerVersionCheckBehaviorTests.cs index 2942b217538..bd5add34cc7 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/EnforcePeerVersionCheckBehaviorTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/EnforcePeerVersionCheckBehaviorTests.cs @@ -48,7 +48,7 @@ private INetworkPeer CreateNetworkPeer(ProtocolVersion version) return networkPeer.Object; } - + private void Disconnected(Mock peer, string reason, Exception exception) { peer.SetupGet(n => n.State).Returns(NetworkPeerState.Offline); @@ -70,7 +70,6 @@ public void IncompatibileNodesDisconnectAfterHardFork() // Create behaviour using the test wraper which exposes protected properties and methods ExtendedLoggerFactory loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); EnforcePeerVersionCheckBehaviorWrapper behavior = new EnforcePeerVersionCheckBehaviorWrapper(chain, nodeSettings, this.Network, loggerFactory); // Intentionally set Peer Version to 0 as its value it shouldn't be used anythere in the test. @@ -114,7 +113,6 @@ public void CompatibileNodesStayConnectedAfterHardFork() // Create behaviour using the test wraper which exposes protected properties and methods ExtendedLoggerFactory loggerFactory = new ExtendedLoggerFactory(); - loggerFactory.AddConsoleWithFilters(); EnforcePeerVersionCheckBehaviorWrapper behavior = new EnforcePeerVersionCheckBehaviorWrapper(chain, nodeSettings, this.Network, loggerFactory); // Intentionally set Peer Version to 0 as its value it shouldn't be used anythere in the test. diff --git a/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs b/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs index ba524ae989a..7515645f9ed 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs @@ -28,7 +28,6 @@ public NetworkPeerServerTests(ITestOutputHelper output) { this.testOutput = output; this.extendedLoggerFactory = new ExtendedLoggerFactory(); - this.extendedLoggerFactory.AddConsoleWithFilters(); } [Theory] diff --git a/src/Stratis.Bitcoin.Tests/P2P/PeerAddressManagerBehaviourTests.cs b/src/Stratis.Bitcoin.Tests/P2P/PeerAddressManagerBehaviourTests.cs index 5472676941e..f5207bdc24f 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/PeerAddressManagerBehaviourTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/PeerAddressManagerBehaviourTests.cs @@ -29,7 +29,6 @@ public sealed class PeerAddressManagerBehaviourTests : LogsTestBase public PeerAddressManagerBehaviourTests() { this.extendedLoggerFactory = new ExtendedLoggerFactory(); - this.extendedLoggerFactory.AddConsoleWithFilters(); this.connectionManagerSettings = new ConnectionManagerSettings(NodeSettings.Default(this.Network)); this.signals = new Bitcoin.Signals.Signals(this.extendedLoggerFactory, null); this.asyncProvider = new AsyncProvider(this.extendedLoggerFactory, this.signals, new NodeLifetime()); diff --git a/src/Stratis.Bitcoin.Tests/P2P/PeerConnectorTests.cs b/src/Stratis.Bitcoin.Tests/P2P/PeerConnectorTests.cs index 8e64ff871d6..5e12e041ca1 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/PeerConnectorTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/PeerConnectorTests.cs @@ -31,7 +31,6 @@ public sealed class PeerConnectorTests : LogsTestBase public PeerConnectorTests() { this.extendedLoggerFactory = new ExtendedLoggerFactory(); - this.extendedLoggerFactory.AddConsoleWithFilters(); this.nodeLifetime = new NodeLifetime(); this.signals = new Mock().Object; diff --git a/src/Stratis.Bitcoin.Tests/P2P/PeerSelectorTests.cs b/src/Stratis.Bitcoin.Tests/P2P/PeerSelectorTests.cs index fd7a865cd4d..1335f82ddf5 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/PeerSelectorTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/PeerSelectorTests.cs @@ -23,7 +23,6 @@ public sealed class PeerSelectorTests : LogsTestBase public PeerSelectorTests() { this.extendedLoggerFactory = new ExtendedLoggerFactory(); - this.extendedLoggerFactory.AddConsoleWithFilters(); this.connectionManagerSettings = new ConnectionManagerSettings(NodeSettings.Default(new StratisRegTest())); } diff --git a/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj b/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj index 76d2a026c46..0aa4af3bfd0 100644 --- a/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj +++ b/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.Bitcoin.Tests Stratis.Bitcoin.Tests true - 2.1.1 false false false @@ -27,8 +26,9 @@ - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Tests/Utilities/AsyncProviderTest.cs b/src/Stratis.Bitcoin.Tests/Utilities/AsyncProviderTest.cs index 58ba1dba897..0eb274f9103 100644 --- a/src/Stratis.Bitcoin.Tests/Utilities/AsyncProviderTest.cs +++ b/src/Stratis.Bitcoin.Tests/Utilities/AsyncProviderTest.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using FluentAssertions; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Internal; using Moq; using Stratis.Bitcoin.AsyncWork; using Stratis.Bitcoin.Utilities; @@ -17,9 +17,9 @@ namespace Stratis.Bitcoin.Tests.Utilities public class AsyncProviderTest { /// Source of randomness. - private Random random = new Random(); - private AsyncProvider asyncProvider; - private Mock mockLogger; + private readonly Random random = new Random(); + private readonly AsyncProvider asyncProvider; + private readonly Mock mockLogger; public AsyncProviderTest() { @@ -452,7 +452,7 @@ public async Task AsyncProvider_AsyncQueue_CanDisposeFromCallback_Async() [Fact] - public async Task AsyncProvider_AsyncLoop_ExceptionInLoopThrowsCriticalException() + public async Task AsyncProvider_AsyncLoop_ExceptionInLoopThrowsCriticalExceptionAsync() { var asyncLoop = this.asyncProvider.CreateAndRunAsyncLoop("TestLoop", async token => { @@ -466,11 +466,16 @@ public async Task AsyncProvider_AsyncLoop_ExceptionInLoopThrowsCriticalException protected void AssertLog(Mock logger, LogLevel logLevel, string exceptionMessage, string message) where T : Exception { - logger.Verify(f => f.Log(logLevel, - It.IsAny(), - It.Is(l => ((FormattedLogValues)l)[0].Value.ToString().EndsWith(message)), - It.Is(t => t.Message.Equals(exceptionMessage)), - It.IsAny>())); + logger + .Setup(f => f.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny())) + .Callback(new InvocationAction(invocation => + { + if ((LogLevel)invocation.Arguments[0] == logLevel) + { + invocation.Arguments[2].ToString().Should().EndWith(message); + ((T)invocation.Arguments[3]).Message.Should().Be(exceptionMessage); + } + })); } } -} +} \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Configuration/Logging/LoggingConfiguration.cs b/src/Stratis.Bitcoin/Configuration/Logging/LoggingConfiguration.cs index cc7c1a0d887..de33ae4ba2c 100644 --- a/src/Stratis.Bitcoin/Configuration/Logging/LoggingConfiguration.cs +++ b/src/Stratis.Bitcoin/Configuration/Logging/LoggingConfiguration.cs @@ -11,8 +11,7 @@ using NLog.Targets; using NLog.Targets.Wrappers; using Stratis.Bitcoin.Configuration.Settings; -using Stratis.Bitcoin.Utilities; -using TracerAttributes; +using LogLevel = Microsoft.Extensions.Logging.LogLevel; namespace Stratis.Bitcoin.Configuration.Logging { @@ -21,23 +20,38 @@ namespace Stratis.Bitcoin.Configuration.Logging /// public class ExtendedLoggerFactory : LoggerFactory { - private const string NLogConfigFileName = "NLog.config"; - /// Configuration of console logger. - public ConsoleLoggerSettings ConsoleSettings { get; set; } + public ILoggingBuilder ConsoleSettings { get; set; } /// Provider of console logger. public ConsoleLoggerProvider ConsoleLoggerProvider { get; set; } - /// Loads the NLog.config file from the , if it exists. - public void LoadNLogConfiguration(DataFolder dataFolder) + public static ILoggerFactory Create() { - if (dataFolder == null) - return; + return ExtendedLoggerFactory.Create(builder => + { + builder.AddFilter("Default", LogLevel.Information) + .AddFilter("System", LogLevel.Warning) + .AddFilter("Microsoft", LogLevel.Warning) + .AddFilter("Microsoft.AspNetCore", LogLevel.Error) + .AddConsole(); + } + ); + } - string configPath = Path.Combine(dataFolder.RootPath, NLogConfigFileName); - if (File.Exists(configPath)) - this.ConfigureNLog(configPath); + /// Loads the NLog.config file from the , if it exists. + public static ILoggerFactory Create(LogSettings settings) + { + return ExtendedLoggerFactory.Create(builder => + { + LoggingConfiguration.ConfigureConsoleFilters(builder, settings); + builder.AddFilter("Default", LogLevel.Information) + .AddFilter("System", LogLevel.Warning) + .AddFilter("Microsoft", LogLevel.Warning) + .AddFilter("Microsoft.AspNetCore", LogLevel.Error) + .AddConsole(); + } + ); } } @@ -49,6 +63,8 @@ public static class LoggingConfiguration /// Width of a column for pretty console/log outputs. public const int ColumnLength = 24; + private const string NLogConfigFileName = "NLog.config"; + /// Currently used node's log settings. private static LogSettings logSettings; @@ -108,6 +124,17 @@ static LoggingConfiguration() LogManager.ConfigurationReloaded += NLogConfigurationReloaded; } + /// Loads the NLog.config file from the , if it exists. + public static void LoadNLogConfiguration(this ILoggerFactory loggerFactory, DataFolder dataFolder) + { + if (dataFolder == null) + return; + + string configPath = Path.Combine(dataFolder.RootPath, NLogConfigFileName); + if (File.Exists(configPath)) + loggerFactory.ConfigureNLog(configPath); + } + /// /// Event handler to be called when logging gets reloaded. /// @@ -221,36 +248,9 @@ public static void AddFilters(this ILoggerFactory loggerFactory, LogSettings set /// /// Configure the console logger and set it to filter logs not related to the fullnode. /// - /// The logger factory to add the console logger. - public static void AddConsoleWithFilters(this ILoggerFactory loggerFactory) - { - var consoleLoggerSettings = new ConsoleLoggerSettings - { - Switches = - { - {"Default", Microsoft.Extensions.Logging.LogLevel.Information}, - {"System", Microsoft.Extensions.Logging.LogLevel.Warning}, - {"Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning}, - {"Microsoft.AspNetCore", Microsoft.Extensions.Logging.LogLevel.Error} - } - }; - - var consoleLoggerProvider = new ConsoleLoggerProvider(consoleLoggerSettings); - loggerFactory.AddProvider(consoleLoggerProvider); - - var extendedLoggerFactory = loggerFactory as ExtendedLoggerFactory; - Guard.NotNull(extendedLoggerFactory, nameof(extendedLoggerFactory)); - extendedLoggerFactory.ConsoleLoggerProvider = consoleLoggerProvider; - extendedLoggerFactory.ConsoleSettings = consoleLoggerSettings; - } - - /// - /// Configure the console logger and set it to filter logs not related to the fullnode. - /// - /// Not used. - /// Console settings to filter. + /// Logging builder. /// Settings that hold potential debug arguments, if null no debug arguments will be loaded."/> - public static void ConfigureConsoleFilters(this ILoggerFactory loggerFactory, ConsoleLoggerSettings consoleLoggerSettings, LogSettings settings) + public static void ConfigureConsoleFilters(ILoggingBuilder builder, LogSettings settings) { if (settings != null) { @@ -259,7 +259,7 @@ public static void ConfigureConsoleFilters(this ILoggerFactory loggerFactory, Co if (settings.DebugArgs[0] == "1") { // Increase all logging to Debug. - consoleLoggerSettings.Switches.Add($"{nameof(Stratis)}.{nameof(Bitcoin)}", Microsoft.Extensions.Logging.LogLevel.Debug); + builder.AddFilter($"{nameof(Stratis)}.{nameof(Bitcoin)}", Microsoft.Extensions.Logging.LogLevel.Debug); } else { @@ -279,40 +279,13 @@ public static void ConfigureConsoleFilters(this ILoggerFactory loggerFactory, Co if (!usedCategories.Contains(category)) { usedCategories.Add(category); - consoleLoggerSettings.Switches.Add(category.TrimEnd('*').TrimEnd('.'), Microsoft.Extensions.Logging.LogLevel.Debug); + builder.AddFilter(category.TrimEnd('*').TrimEnd('.'), Microsoft.Extensions.Logging.LogLevel.Debug); } } } } } } - - consoleLoggerSettings.Reload(); - } - - /// - /// Obtains configuration of the console logger. - /// - /// Logger factory interface being extended. - /// Console logger settings. - public static ConsoleLoggerSettings GetConsoleSettings(this ILoggerFactory loggerFactory) - { - var extendedLoggerFactory = loggerFactory as ExtendedLoggerFactory; - Guard.NotNull(extendedLoggerFactory, nameof(extendedLoggerFactory)); - return extendedLoggerFactory.ConsoleSettings; - } - - /// - /// Obtains configuration of the console logger provider. - /// - /// Logger factory interface being extended. - /// Console logger provider. - [NoTrace] - public static ConsoleLoggerProvider GetConsoleLoggerProvider(this ILoggerFactory loggerFactory) - { - var extendedLoggerFactory = loggerFactory as ExtendedLoggerFactory; - Guard.NotNull(extendedLoggerFactory, nameof(extendedLoggerFactory)); - return extendedLoggerFactory.ConsoleLoggerProvider; } } -} +} \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Configuration/NodeSettings.cs b/src/Stratis.Bitcoin/Configuration/NodeSettings.cs index 7127ef56d16..c1d77047523 100644 --- a/src/Stratis.Bitcoin/Configuration/NodeSettings.cs +++ b/src/Stratis.Bitcoin/Configuration/NodeSettings.cs @@ -108,7 +108,7 @@ public class NodeSettings : IDisposable /// is met. For this reason, the minimum relay transaction fee is usually lower than the minimum fee. /// public FeeRate MinRelayTxFeeRate { get; private set; } - + /// /// If true then the node will add and start the SignalR feature. /// @@ -135,11 +135,8 @@ public NodeSettings(Network network = null, ProtocolVersion protocolVersion = Su string agent = "StratisNode", string[] args = null, NetworksSelector networksSelector = null) { // Create the default logger factory and logger. - var loggerFactory = new ExtendedLoggerFactory(); - this.LoggerFactory = loggerFactory; - this.LoggerFactory.AddConsoleWithFilters(); - this.LoggerFactory.AddNLog(); - this.Logger = this.LoggerFactory.CreateLogger(typeof(NodeSettings).FullName); + var loggerFactory = ExtendedLoggerFactory.Create(); + this.Logger = loggerFactory.CreateLogger(typeof(NodeSettings).FullName); // Record arguments. this.Network = network; @@ -219,7 +216,12 @@ public NodeSettings(Network network = null, ProtocolVersion protocolVersion = Su this.DataFolder = new DataFolder(this.DataDir); // Attempt to load NLog configuration from the DataFolder. - loggerFactory.LoadNLogConfiguration(this.DataFolder); + this.Log = new LogSettings(); + this.Log.Load(this.ConfigReader); + this.LoggerFactory = ExtendedLoggerFactory.Create(this.Log); + this.LoggerFactory.AddNLog(); + this.LoggerFactory.LoadNLogConfiguration(this.DataFolder); + this.Logger = this.LoggerFactory.CreateLogger(typeof(NodeSettings).FullName); // Get the configuration file name for the network if it was not specified on the command line. if (this.ConfigurationFile == null) @@ -231,13 +233,10 @@ public NodeSettings(Network network = null, ProtocolVersion protocolVersion = Su this.ReadConfigurationFile(); } - this.EnableSignalR = this.ConfigReader.GetOrDefault("enableSignalR", false, this.Logger); + this.EnableSignalR = this.ConfigReader.GetOrDefault("enableSignalR", false, this.Logger); // Create the custom logger factory. - this.Log = new LogSettings(); - this.Log.Load(this.ConfigReader); this.LoggerFactory.AddFilters(this.Log, this.DataFolder); - this.LoggerFactory.ConfigureConsoleFilters(this.LoggerFactory.GetConsoleSettings(), this.Log); // Load the configuration. this.LoadConfiguration(); diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index e1ec82c9aaa..9ccc3eeb09b 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -27,7 +27,7 @@ - + @@ -44,13 +44,16 @@ - - + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Stratis.Bitcoin/Utilities/PrefixLogger.cs b/src/Stratis.Bitcoin/Utilities/PrefixLogger.cs index 824a207dcb9..99aaa75a742 100644 --- a/src/Stratis.Bitcoin/Utilities/PrefixLogger.cs +++ b/src/Stratis.Bitcoin/Utilities/PrefixLogger.cs @@ -1,6 +1,5 @@ using System; using Microsoft.Extensions.Logging; -using Stratis.Bitcoin.Configuration.Logging; using TracerAttributes; namespace Stratis.Bitcoin.Utilities @@ -18,16 +17,16 @@ namespace Stratis.Bitcoin.Utilities public class PrefixLogger : ILogger { /// Internal NLog logger instance. - private NLog.Logger logger; + private readonly NLog.Logger logger; /// Internal console logger instance. - private ILogger consoleLogger; + private readonly ILogger consoleLogger; /// Prefix to put in front of every message. - private string prefix; + private readonly string prefix; /// Wrapper class type for the NLog callsite to skip it. - private Type wrapperType; + private readonly Type wrapperType; /// /// Creates a logger instance with given prefix. @@ -38,9 +37,9 @@ public class PrefixLogger : ILogger public PrefixLogger(ILoggerFactory loggerFactory, string categoryName, string prefix = null) { this.logger = NLog.LogManager.GetLogger(categoryName); - this.consoleLogger = loggerFactory.GetConsoleLoggerProvider().CreateLogger(categoryName); + this.consoleLogger = loggerFactory.CreateLogger(categoryName); - this.prefix = prefix != null ? prefix : string.Empty; + this.prefix = prefix ?? string.Empty; this.wrapperType = typeof(PrefixLogger); } diff --git a/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj b/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj index 7329614a82a..c31211d430e 100644 --- a/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj +++ b/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.1 false diff --git a/src/Stratis.Feature.PoA.Tokenless.Tests/TokenlessTestHelper.cs b/src/Stratis.Feature.PoA.Tokenless.Tests/TokenlessTestHelper.cs index 877d9e09f29..d2f37355bd9 100644 --- a/src/Stratis.Feature.PoA.Tokenless.Tests/TokenlessTestHelper.cs +++ b/src/Stratis.Feature.PoA.Tokenless.Tests/TokenlessTestHelper.cs @@ -44,7 +44,6 @@ public TokenlessTestHelper() this.Network = new TokenlessNetwork(); this.NodeSettings = NodeSettings.Default(this.Network); this.LoggerFactory = new ExtendedLoggerFactory(); - this.LoggerFactory.AddConsoleWithFilters(); this.blockRepository = new Mock().Object; this.CallDataSerializer = new NoGasCallDataSerializer(new ContractPrimitiveSerializer(this.Network)); diff --git a/src/Stratis.Feature.PoA.Tokenless/Stratis.Feature.PoA.Tokenless.csproj b/src/Stratis.Feature.PoA.Tokenless/Stratis.Feature.PoA.Tokenless.csproj index d166a9144a3..aa508c925a5 100644 --- a/src/Stratis.Feature.PoA.Tokenless/Stratis.Feature.PoA.Tokenless.csproj +++ b/src/Stratis.Feature.PoA.Tokenless/Stratis.Feature.PoA.Tokenless.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.1 latest diff --git a/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj b/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj index 38b50b03843..08c589c83d2 100644 --- a/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj @@ -1,11 +1,10 @@ - + - netcoreapp2.1 + netcoreapp3.1 Stratis.Features.SQLiteWalletRepository.Tests Stratis.Features.SQLiteWalletRepository.Tests true - 2.1.1 false false false @@ -27,8 +26,8 @@ - - + + all diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index 59ecb291d26..558314cd34d 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -28,15 +28,15 @@ - + - - - + + + - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.CLR.Tests/ContractExecutorTestContext.cs b/src/Stratis.SmartContracts.CLR.Tests/ContractExecutorTestContext.cs index 7b4e05cc7e8..a551e640453 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/ContractExecutorTestContext.cs +++ b/src/Stratis.SmartContracts.CLR.Tests/ContractExecutorTestContext.cs @@ -23,7 +23,7 @@ public class ContractExecutorTestContext public ILoggerFactory LoggerFactory { get; } public StateRepositoryRoot State { get; } public SmartContractValidator Validator { get; } - public IAddressGenerator AddressGenerator {get;} + public IAddressGenerator AddressGenerator { get; } public ContractAssemblyLoader AssemblyLoader { get; } public IContractModuleDefinitionReader ModuleDefinitionReader { get; } public IContractPrimitiveSerializer ContractPrimitiveSerializer { get; } @@ -39,7 +39,6 @@ public ContractExecutorTestContext() this.Network = new SmartContractsRegTest(); this.KeyEncodingStrategy = BasicKeyEncodingStrategy.Default; this.LoggerFactory = new ExtendedLoggerFactory(); - this.LoggerFactory.AddConsoleWithFilters(); this.State = new StateRepositoryRoot(new NoDeleteSource(new MemoryDictionarySource())); this.ContractPrimitiveSerializer = new ContractPrimitiveSerializer(this.Network); this.Serializer = new Serializer(this.ContractPrimitiveSerializer); diff --git a/src/Stratis.SmartContracts.CLR.Tests/ContractRefundProcessorTests.cs b/src/Stratis.SmartContracts.CLR.Tests/ContractRefundProcessorTests.cs index b5807544ac6..0f497ae6336 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/ContractRefundProcessorTests.cs +++ b/src/Stratis.SmartContracts.CLR.Tests/ContractRefundProcessorTests.cs @@ -16,7 +16,6 @@ public sealed class ContractRefundProcessorTests public ContractRefundProcessorTests() { this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); this.network = new SmartContractsRegTest(); this.refundProcessor = new ContractRefundProcessor(this.loggerFactory); } diff --git a/src/Stratis.SmartContracts.CLR.Tests/ContractTransferProcessorTests.cs b/src/Stratis.SmartContracts.CLR.Tests/ContractTransferProcessorTests.cs index cd62b7e11a0..e6e5be371fc 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/ContractTransferProcessorTests.cs +++ b/src/Stratis.SmartContracts.CLR.Tests/ContractTransferProcessorTests.cs @@ -22,7 +22,6 @@ public class ContractTransferProcessorTests public ContractTransferProcessorTests() { this.loggerFactory = new ExtendedLoggerFactory(); - this.loggerFactory.AddConsoleWithFilters(); this.network = new SmartContractsRegTest(); this.transferProcessor = new ContractTransferProcessor(this.loggerFactory, this.network); } @@ -248,7 +247,7 @@ public void HasBalance_TxValue1_TransferValue0() Assert.Equal(txContextMock.Object.TransactionHash, internalTransaction.Inputs[0].PrevOut.Hash); Assert.Equal(txContextMock.Object.Nvout, internalTransaction.Inputs[0].PrevOut.N); Assert.Equal(new uint256(1), internalTransaction.Inputs[1].PrevOut.Hash); - Assert.Equal((uint) 1, internalTransaction.Inputs[1].PrevOut.N); + Assert.Equal((uint)1, internalTransaction.Inputs[1].PrevOut.N); Assert.True(internalTransaction.Outputs[0].ScriptPubKey.IsSmartContractInternalCall()); Assert.Equal(200, internalTransaction.Outputs[0].Value); @@ -296,7 +295,7 @@ public void HasBalance_TxValue0_TransferValue1() Assert.Single(internalTransaction.Inputs); Assert.Equal(2, internalTransaction.Outputs.Count); Assert.Equal(new uint256(1), internalTransaction.Inputs[0].PrevOut.Hash); - Assert.Equal((uint) 1, internalTransaction.Inputs[0].PrevOut.N); + Assert.Equal((uint)1, internalTransaction.Inputs[0].PrevOut.N); string output1Address = PayToPubkeyHashTemplate.Instance.ExtractScriptPubKeyParameters(internalTransaction.Outputs[0].ScriptPubKey).GetAddress(this.network).ToString(); Assert.Equal(receiverAddress.ToBase58Address(this.network), output1Address); Assert.Equal(75, internalTransaction.Outputs[0].Value); @@ -459,7 +458,7 @@ public void Execution_Failure_With_Value_No_Transfers_Creates_Refund() Assert.Single(refundTransaction.Outputs); Assert.Equal(new uint256(123), refundTransaction.Inputs[0].PrevOut.Hash); Assert.Equal((uint)1, refundTransaction.Inputs[0].PrevOut.N); - Assert.Equal(txContextMock.Object.TxOutValue, (ulong) refundTransaction.Outputs[0].Value); + Assert.Equal(txContextMock.Object.TxOutValue, (ulong)refundTransaction.Outputs[0].Value); string outputAddress = PayToPubkeyHashTemplate.Instance.ExtractScriptPubKeyParameters(refundTransaction.Outputs[0].ScriptPubKey).GetAddress(this.network).ToString(); Assert.Equal(txContextMock.Object.Sender.ToBase58Address(this.network), outputAddress); diff --git a/src/Stratis.SmartContracts.CLR.Tests/Stratis.SmartContracts.CLR.Tests.csproj b/src/Stratis.SmartContracts.CLR.Tests/Stratis.SmartContracts.CLR.Tests.csproj index 1027bab6505..4cd2fa6dc53 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/Stratis.SmartContracts.CLR.Tests.csproj +++ b/src/Stratis.SmartContracts.CLR.Tests/Stratis.SmartContracts.CLR.Tests.csproj @@ -1,14 +1,13 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 false - + all diff --git a/src/Stratis.SmartContracts.CLR.Validation.Tests/Stratis.SmartContracts.CLR.Validation.Tests.csproj b/src/Stratis.SmartContracts.CLR.Validation.Tests/Stratis.SmartContracts.CLR.Validation.Tests.csproj index ea4b334f3b3..65e3abd423d 100644 --- a/src/Stratis.SmartContracts.CLR.Validation.Tests/Stratis.SmartContracts.CLR.Validation.Tests.csproj +++ b/src/Stratis.SmartContracts.CLR.Validation.Tests/Stratis.SmartContracts.CLR.Validation.Tests.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 false diff --git a/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj b/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj index b7d27dfc54b..2aa6b97a0e6 100644 --- a/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj +++ b/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 1.0.2.0-beta Stratis Group Ltd. @@ -11,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj b/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj index 9ddce807614..6b7b7cd4245 100644 --- a/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj +++ b/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 1.0.2.0 1.0.2.0 1.0.2.0-beta @@ -14,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.Core.Tests/Stratis.SmartContracts.Core.Tests.csproj b/src/Stratis.SmartContracts.Core.Tests/Stratis.SmartContracts.Core.Tests.csproj index 77bec80ab85..74eb3f6ec27 100644 --- a/src/Stratis.SmartContracts.Core.Tests/Stratis.SmartContracts.Core.Tests.csproj +++ b/src/Stratis.SmartContracts.Core.Tests/Stratis.SmartContracts.Core.Tests.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 false diff --git a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj index 6e4c6fc7e4e..f11ded0641c 100644 --- a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj +++ b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 1.0.2.0-beta Stratis Group Ltd. Stratis Group Ltd. @@ -10,14 +9,14 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj b/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj index 41e850bfe89..3f6a2e9fde5 100644 --- a/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj +++ b/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.SmartContracts.IntegrationTests Stratis.SmartContracts.IntegrationTests true - 2.1.1 false false false diff --git a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj index e9ac27ecdc2..d0814ec2fbf 100644 --- a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj +++ b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj @@ -1,14 +1,13 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 1.0.2.0-beta Stratis Group Ltd. - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj b/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj index 32031a9bd3f..29a203297e0 100644 --- a/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj +++ b/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj @@ -1,14 +1,13 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 1.0.2.0-beta Stratis Group Ltd. - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.Tests.Common/Stratis.SmartContracts.Tests.Common.csproj b/src/Stratis.SmartContracts.Tests.Common/Stratis.SmartContracts.Tests.Common.csproj index 5e0ded87f4f..6d22565b620 100644 --- a/src/Stratis.SmartContracts.Tests.Common/Stratis.SmartContracts.Tests.Common.csproj +++ b/src/Stratis.SmartContracts.Tests.Common/Stratis.SmartContracts.Tests.Common.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 0.0.1-beta diff --git a/src/Stratis.SmartContracts.Tokenless/Stratis.SmartContracts.Tokenless.csproj b/src/Stratis.SmartContracts.Tokenless/Stratis.SmartContracts.Tokenless.csproj index 8eab2c5448e..8ad63cd0509 100644 --- a/src/Stratis.SmartContracts.Tokenless/Stratis.SmartContracts.Tokenless.csproj +++ b/src/Stratis.SmartContracts.Tokenless/Stratis.SmartContracts.Tokenless.csproj @@ -1,8 +1,7 @@  - netcoreapp2.1 - 2.1.1 + netcoreapp3.1 diff --git a/src/Stratis.TokenlessD/Stratis.TokenlessD.csproj b/src/Stratis.TokenlessD/Stratis.TokenlessD.csproj index 26eeecb4c8c..6331e522670 100644 --- a/src/Stratis.TokenlessD/Stratis.TokenlessD.csproj +++ b/src/Stratis.TokenlessD/Stratis.TokenlessD.csproj @@ -1,11 +1,10 @@  - netcoreapp2.1 + netcoreapp3.1 Stratis.TokenlessD Exe Stratis.TokenlessD - 2.1.1 false false false @@ -31,9 +30,9 @@ - - - + + + \ No newline at end of file From 270bcceb7855a159ee71869fc5911283486c3cdf Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 4 Mar 2020 12:12:24 +0000 Subject: [PATCH 2/8] Upgraded test Nugets --- ...s.Bitcoin.Features.BlockStore.Tests.csproj | 1 - ...is.Bitcoin.Features.Consensus.Tests.csproj | 2 +- ...s.Bitcoin.Features.MemoryPool.Tests.csproj | 2 +- ...tratis.Bitcoin.Features.Miner.Tests.csproj | 2 +- ...itcoin.Features.Notifications.Tests.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.Tests.csproj | 4 +-- ...tcoin.Features.SmartContracts.Tests.csproj | 2 +- ...ratis.Bitcoin.Features.Wallet.Tests.csproj | 2 +- .../Stratis.Bitcoin.IntegrationTests.csproj | 8 ++--- .../Stratis.Bitcoin.Tests.csproj | 2 +- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 31 ++++++++++--------- ...Stratis.Feature.PoA.Tokenless.Tests.csproj | 5 ++- ...atures.SQLiteWalletRepository.Tests.csproj | 4 +-- ...tis.SmartContracts.IntegrationTests.csproj | 4 +-- 14 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj b/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj index d11d1c3dcc7..ea96ec353fa 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore.Tests/Stratis.Bitcoin.Features.BlockStore.Tests.csproj @@ -5,7 +5,6 @@ Stratis.Bitcoin.Features.BlockStore.Tests Stratis.Bitcoin.Features.BlockStore.Tests true - 2.1.1 false false false diff --git a/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj b/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj index 0009721c553..0bcf58b20ec 100644 --- a/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus.Tests/Stratis.Bitcoin.Features.Consensus.Tests.csproj @@ -26,7 +26,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj index a37f32fb1fa..3567e1722cd 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj @@ -27,7 +27,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj b/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj index aaecfdfa26c..8c0ce3fbe41 100644 --- a/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Miner.Tests/Stratis.Bitcoin.Features.Miner.Tests.csproj @@ -22,7 +22,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj b/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj index 7c07f893629..660e1c4b1a8 100644 --- a/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications.Tests/Stratis.Bitcoin.Features.Notifications.Tests.csproj @@ -27,7 +27,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj b/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj index 3cac4be5fcc..a0272addc9f 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/Stratis.Bitcoin.Features.PoA.Tests.csproj @@ -6,13 +6,13 @@ - + all runtime; build; native; contentfiles; analyzers - + diff --git a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj index fa4eb137d44..87cb083de19 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts.Tests/Stratis.Bitcoin.Features.SmartContracts.Tests.csproj @@ -16,7 +16,7 @@ - + all diff --git a/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj b/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj index 68d0b88a0e3..587ae2f831d 100644 --- a/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet.Tests/Stratis.Bitcoin.Features.Wallet.Tests.csproj @@ -28,7 +28,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj b/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj index efb37a89184..d2ff057da93 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests/Stratis.Bitcoin.IntegrationTests.csproj @@ -31,9 +31,9 @@ - - - + + + @@ -54,7 +54,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj b/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj index 0aa4af3bfd0..8ef8834d847 100644 --- a/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj +++ b/src/Stratis.Bitcoin.Tests/Stratis.Bitcoin.Tests.csproj @@ -27,7 +27,7 @@ - + all diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 9ccc3eeb09b..1067a74e9ca 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -26,29 +26,32 @@ - + - - + + - - - - - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + - + - + all diff --git a/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj b/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj index c31211d430e..c26641065af 100644 --- a/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj +++ b/src/Stratis.Feature.PoA.Tokenless.Tests/Stratis.Feature.PoA.Tokenless.Tests.csproj @@ -1,13 +1,12 @@ - + netcoreapp3.1 - false - + all diff --git a/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj b/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj index 08c589c83d2..05d7b3c16c4 100644 --- a/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository.Tests/Stratis.Features.SQLiteWalletRepository.Tests.csproj @@ -28,8 +28,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj b/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj index 3f6a2e9fde5..468aea23aa4 100644 --- a/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj +++ b/src/Stratis.SmartContracts.IntegrationTests/Stratis.SmartContracts.IntegrationTests.csproj @@ -35,8 +35,8 @@ - - + + all runtime; build; native; contentfiles; analyzers From 3213b26f347642eb8a4d6ff216e88d45b82c2a7a Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 4 Mar 2020 13:05:32 +0000 Subject: [PATCH 3/8] RPC not building --- .../RPCJsonMvcOptionsSetupTest.cs | 4 +--- .../RPCJsonOutputFormatterTest.cs | 10 ++++------ .../Stratis.Bitcoin.Features.RPC.Tests.csproj | 1 - src/Stratis.Bitcoin.Features.RPC/RPCFeature.cs | 10 +++------- .../RPCJsonMvcOptionsSetup.cs | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 1 - 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs index debbf54c568..5da144989d1 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonMvcOptionsSetupTest.cs @@ -1,6 +1,5 @@ using System.Buffers; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Formatters; using Newtonsoft.Json; using Xunit; @@ -15,8 +14,7 @@ public void ConfigureMvcReplacesJsonFormattedWithRPCJsonOutputFormatter() ArrayPool charpool = ArrayPool.Create(); var options = new MvcOptions(); options.OutputFormatters.Clear(); - options.OutputFormatters.Add(new NewtonsoftJsonOutputFormatter(settings, charpool, options)); - + options.OutputFormatters.Add(new JsonOutputFormatter(settings, charpool, options)); RPCJsonMvcOptionsSetup.ConfigureMvc(options, settings, null, charpool, null); Assert.Single(options.OutputFormatters); diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonOutputFormatterTest.cs b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonOutputFormatterTest.cs index 8b1993fe4f8..2f926377b12 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonOutputFormatterTest.cs +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/RPCJsonOutputFormatterTest.cs @@ -1,5 +1,4 @@ -using System.Buffers; -using System.IO; +using System.IO; using System.Text; using System.Threading.Tasks; using FluentAssertions; @@ -47,7 +46,7 @@ public void WriteResponseBodyAsyncWritesContextToResponseBody() var formatter = new RPCJsonOutputFormatter(this.settings); Task task = formatter.WriteResponseBodyAsync(context, Encoding.UTF8); task.Wait(); - + using (var reader = new StreamReader(bodyStream)) { bodyStream.Position = 0; @@ -60,10 +59,9 @@ public void WriteResponseBodyAsyncWritesContextToResponseBody() private static DefaultHttpContext SetupDefaultContextWithResponseBodyStream(Stream bodyStream) { var defaultContext = new DefaultHttpContext(); - var response = new HttpResponseFeature(); - response.Body = bodyStream; + var response = new StreamResponseBodyFeature(bodyStream); var featureCollection = new FeatureCollection(); - featureCollection.Set(response); + featureCollection.Set(response); defaultContext.Initialize(featureCollection); return defaultContext; } diff --git a/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj b/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj index adb0242a142..6a2473cd44c 100644 --- a/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj +++ b/src/Stratis.Bitcoin.Features.RPC.Tests/Stratis.Bitcoin.Features.RPC.Tests.csproj @@ -28,7 +28,6 @@ - all diff --git a/src/Stratis.Bitcoin.Features.RPC/RPCFeature.cs b/src/Stratis.Bitcoin.Features.RPC/RPCFeature.cs index ff3a4a9f52d..4822b456976 100644 --- a/src/Stratis.Bitcoin.Features.RPC/RPCFeature.cs +++ b/src/Stratis.Bitcoin.Features.RPC/RPCFeature.cs @@ -7,7 +7,6 @@ using NBitcoin; using Stratis.Bitcoin.Builder; using Stratis.Bitcoin.Builder.Feature; -using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Configuration.Logging; namespace Stratis.Bitcoin.Features.RPC @@ -16,19 +15,16 @@ public class RPCFeature : FullNodeFeature { private readonly FullNode fullNode; - private readonly NodeSettings nodeSettings; - private readonly ILogger logger; private readonly IFullNodeBuilder fullNodeBuilder; private readonly RpcSettings rpcSettings; - public RPCFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, NodeSettings nodeSettings, ILoggerFactory loggerFactory, RpcSettings rpcSettings) + public RPCFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, ILoggerFactory loggerFactory, RpcSettings rpcSettings) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; - this.nodeSettings = nodeSettings; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.rpcSettings = rpcSettings; } @@ -65,7 +61,7 @@ public override Task InitializeAsync() // TODO: The web host wants to create IServiceProvider, so build (but not start) // earlier, if you want to use dependency injection elsewhere this.fullNode.RPCHost = new WebHostBuilder() - .UseKestrel() + .UseKestrel(o => o.AllowSynchronousIO = true) .ForFullNode(this.fullNode) .UseUrls(this.rpcSettings.GetUrls()) .UseIISIntegration() @@ -107,7 +103,7 @@ public override Task InitializeAsync() { this.logger.LogInformation("RPC Server is off based on configuration."); } - + return Task.CompletedTask; } } diff --git a/src/Stratis.Bitcoin.Features.RPC/RPCJsonMvcOptionsSetup.cs b/src/Stratis.Bitcoin.Features.RPC/RPCJsonMvcOptionsSetup.cs index 24605bae9a3..de764e12adb 100644 --- a/src/Stratis.Bitcoin.Features.RPC/RPCJsonMvcOptionsSetup.cs +++ b/src/Stratis.Bitcoin.Features.RPC/RPCJsonMvcOptionsSetup.cs @@ -33,4 +33,4 @@ public static void ConfigureMvc(MvcOptions options, JsonSerializerSettings seria options.OutputFormatters.Add(new RPCJsonOutputFormatter(serializerSettings)); } } -} +} \ No newline at end of file diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index cb9271909b0..56b2d0df8ab 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -24,7 +24,6 @@ - From a2262ee5f71ecbc07c20bd4cc035ed695af3652a Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 5 Mar 2020 08:15:34 +0000 Subject: [PATCH 4/8] Remove RPC tests project --- .../VotingAndMiningTests.cs | 2 +- src/Stratis.DLT.sln | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/VotingAndMiningTests.cs b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/VotingAndMiningTests.cs index f5ebdc7ac88..99d07f661fe 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/VotingAndMiningTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests/VotingAndMiningTests.cs @@ -261,7 +261,7 @@ public void NodeCanLoadFederationKey() CoreNode node2 = builder.CreatePoANode(network).Start(); Assert.False(node2.FullNode.NodeService().IsFederationMember); - Assert.Equal(node2.FullNode.NodeService().CurrentFederationKey, null); + Assert.Null(node2.FullNode.NodeService().CurrentFederationKey); } } diff --git a/src/Stratis.DLT.sln b/src/Stratis.DLT.sln index 4f0f80145b1..b1fdde7e62a 100644 --- a/src/Stratis.DLT.sln +++ b/src/Stratis.DLT.sln @@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Api.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Features.RPC", "Stratis.Bitcoin.Features.RPC\Stratis.Bitcoin.Features.RPC.csproj", "{5E0010F1-50B8-4FC5-A9C2-38D7DF73A0D2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Features.RPC.Tests", "Stratis.Bitcoin.Features.RPC.Tests\Stratis.Bitcoin.Features.RPC.Tests.csproj", "{1B33E5B8-7162-4DA9-834F-4BE5E236CEBD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Features.Miner", "Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj", "{22B296FE-26B4-4B84-8CF5-614F9D3716A6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Features.Wallet", "Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj", "{6650A6CC-3B56-4D86-8DAA-FD0C8830113A}" @@ -138,7 +136,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CertificateAuthority.Tests" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CertificateAuthority.API", "CertificateAuthority.API\CertificateAuthority.API.csproj", "{5A0A1334-49E2-4EE1-94E5-91E65D8805F6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CertificateAuthority.Tests.Common", "CertificateAuthority.Tests.Common\CertificateAuthority.Tests.Common.csproj", "{7A1A920F-88C7-4087-90FA-CE3E086A2ED2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CertificateAuthority.Tests.Common", "CertificateAuthority.Tests.Common\CertificateAuthority.Tests.Common.csproj", "{7A1A920F-88C7-4087-90FA-CE3E086A2ED2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -166,10 +164,6 @@ Global {5E0010F1-50B8-4FC5-A9C2-38D7DF73A0D2}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E0010F1-50B8-4FC5-A9C2-38D7DF73A0D2}.Release|Any CPU.ActiveCfg = Release|Any CPU {5E0010F1-50B8-4FC5-A9C2-38D7DF73A0D2}.Release|Any CPU.Build.0 = Release|Any CPU - {1B33E5B8-7162-4DA9-834F-4BE5E236CEBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B33E5B8-7162-4DA9-834F-4BE5E236CEBD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1B33E5B8-7162-4DA9-834F-4BE5E236CEBD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1B33E5B8-7162-4DA9-834F-4BE5E236CEBD}.Release|Any CPU.Build.0 = Release|Any CPU {22B296FE-26B4-4B84-8CF5-614F9D3716A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {22B296FE-26B4-4B84-8CF5-614F9D3716A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {22B296FE-26B4-4B84-8CF5-614F9D3716A6}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -367,7 +361,6 @@ Global {94FEB14E-D123-486D-A24D-D2BE725D96E3} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2} {E538B76A-513F-46D5-9F14-E35E79B484CA} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2} {5E0010F1-50B8-4FC5-A9C2-38D7DF73A0D2} = {15D29FFD-6142-4DC5-AFFD-10BA0CA55C45} - {1B33E5B8-7162-4DA9-834F-4BE5E236CEBD} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2} {22B296FE-26B4-4B84-8CF5-614F9D3716A6} = {15D29FFD-6142-4DC5-AFFD-10BA0CA55C45} {6650A6CC-3B56-4D86-8DAA-FD0C8830113A} = {15D29FFD-6142-4DC5-AFFD-10BA0CA55C45} {42F81858-3CE9-4C9B-BA36-378FE36600E1} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2} From 4e3c8e82cadc9fa75290bd5fd85fec038050647d Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 5 Mar 2020 11:11:44 +0000 Subject: [PATCH 5/8] Whitespace formatting --- .../AsyncWork/IAsyncProvider.cs | 2 +- .../Consensus/ConsensusManager.cs | 2 +- .../Controllers/Models/HashModel.cs | 4 +-- src/Stratis.Bitcoin/Models/RecipientModel.cs | 2 +- .../Models/TxFeeEstimateRequest.cs | 27 +++++++++---------- .../P2P/Peer/NetworkPeerConnection.cs | 2 +- .../P2P/Peer/NetworkPeerFactory.cs | 2 +- 7 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Stratis.Bitcoin/AsyncWork/IAsyncProvider.cs b/src/Stratis.Bitcoin/AsyncWork/IAsyncProvider.cs index bfaa90c819b..5376232ba7d 100644 --- a/src/Stratis.Bitcoin/AsyncWork/IAsyncProvider.cs +++ b/src/Stratis.Bitcoin/AsyncWork/IAsyncProvider.cs @@ -126,7 +126,7 @@ public interface IAsyncProvider /// Having a single entry point for COMMON SERVICES allows us to speed up changes. /// ISignals Signals { get; } - + /// /// Returns a list of friendly names of all loops, as well as their current status. /// diff --git a/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs b/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs index 8a6477d7fc5..137197099a5 100644 --- a/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs +++ b/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs @@ -677,7 +677,7 @@ private async Task FullyValidateLockedAsync(ChainedHeader n // Add peers that needed to be banned as a result of a failure to connect blocks. // Otherwise they get lost as we are returning a different ConnnectBlocksResult. // We also need to set the ban reason and ban time otherwise it is not known why - // connecting the new chain failed and hence why the peer is being disconnected in + // connecting the new chain failed and hence why the peer is being disconnected in // peer banning. reconnectionResult.BanReason = connectBlockResult.BanReason; reconnectionResult.BanDurationSeconds = connectBlockResult.BanDurationSeconds; diff --git a/src/Stratis.Bitcoin/Controllers/Models/HashModel.cs b/src/Stratis.Bitcoin/Controllers/Models/HashModel.cs index 946aa7a553b..985c5dd24d0 100644 --- a/src/Stratis.Bitcoin/Controllers/Models/HashModel.cs +++ b/src/Stratis.Bitcoin/Controllers/Models/HashModel.cs @@ -4,12 +4,12 @@ namespace Stratis.Bitcoin.Controllers.Models { /// /// A class containing the necessary parameters for a wallet resynchronization request - /// which takes the hash of the block to resync after. + /// which takes the hash of the block to resync after. /// public class HashModel { /// - /// The hash of the block to resync after. + /// The hash of the block to resync after. /// [Required(AllowEmptyStrings = false)] public string Hash { get; set; } diff --git a/src/Stratis.Bitcoin/Models/RecipientModel.cs b/src/Stratis.Bitcoin/Models/RecipientModel.cs index f52e30916dd..61be28e5777 100644 --- a/src/Stratis.Bitcoin/Models/RecipientModel.cs +++ b/src/Stratis.Bitcoin/Models/RecipientModel.cs @@ -10,7 +10,7 @@ public class RecipientModel /// The destination address. /// [Required(ErrorMessage = "A destination address is required.")] - [IsBitcoinAddress()] + [IsBitcoinAddress] public string DestinationAddress { get; set; } /// diff --git a/src/Stratis.Bitcoin/Models/TxFeeEstimateRequest.cs b/src/Stratis.Bitcoin/Models/TxFeeEstimateRequest.cs index 3ceab8693f9..5eb8e3e2261 100644 --- a/src/Stratis.Bitcoin/Models/TxFeeEstimateRequest.cs +++ b/src/Stratis.Bitcoin/Models/TxFeeEstimateRequest.cs @@ -1,74 +1,71 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using Stratis.Bitcoin.Utilities.ValidationAttributes; using Stratis.Bitcoin.Validations; namespace Stratis.Bitcoin.Models { - /// /// A class containing the necessary parameters for a transaction fee estimate request. /// - /// + /// public class TxFeeEstimateRequest : RequestModel { /// /// The name of the wallet containing the UTXOs to use in the transaction. - /// + /// [Required(ErrorMessage = "The name of the wallet is missing.")] public string WalletName { get; set; } /// /// The name of the account containing the UTXOs to use in the transaction. - /// + /// public string AccountName { get; set; } /// /// A list of outpoints to use as inputs for the transaction. - /// + /// public List Outpoints { get; set; } /// /// A list of transaction recipients. For each recipient, specify the Pubkey script and the amount the /// recipient will receive in STRAT (or a sidechain coin). If the transaction was realized, /// both the values would be used to create the UTXOs for the transaction recipients. - /// + /// [Required(ErrorMessage = "A list of recipients is required.")] [MinLength(1)] public List Recipients { get; set; } /// /// A string containing any OP_RETURN output data to store as part of the transaction. - /// + /// public string OpReturnData { get; set; } /// /// The funds in STRAT (or a sidechain coin) to include with the OP_RETURN output. Currently, specifying /// some funds helps OP_RETURN outputs be relayed around the network. - /// + /// [MoneyFormat(isRequired: false, ErrorMessage = "The op return amount is not in the correct format.")] public string OpReturnAmount { get; set; } /// /// The type of fee to use when working out the fee for the transaction. Specify "low", "medium", or "high". - /// + /// public string FeeType { get; set; } /// /// A flag that specifies whether to include the unconfirmed amounts as inputs to the transaction. /// If this flag is not set, at least one confirmation is required for each input. - /// + /// /// A flag that specifies whether to shuffle the transaction outputs for increased privacy. Randomizing the /// the order in which the outputs appear when the transaction is being built stops it being trivial to /// determine whether a transaction output is payment or change. This helps defeat unsophisticated - /// chain analysis algorithms. + /// chain analysis algorithms. /// Defaults to true. - /// + /// public bool? ShuffleOutputs { get; set; } /// diff --git a/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs b/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs index c469bd5cb47..5758d071659 100644 --- a/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs +++ b/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs @@ -505,7 +505,7 @@ private async Task ReadMagicAsync(byte[] magic, CancellationToken cancellation) message = Message.ReadNext(memoryStream, this.network, protocolVersion, cancellation, this.payloadProvider, out PerformanceCounter counter); } - return(message, rawMessage.Length); + return (message, rawMessage.Length); } /// diff --git a/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerFactory.cs b/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerFactory.cs index 9b1c9f17a1c..b8ec9496e9d 100644 --- a/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerFactory.cs +++ b/src/Stratis.Bitcoin/P2P/Peer/NetworkPeerFactory.cs @@ -109,7 +109,7 @@ public class NetworkPeerFactory : INetworkPeerFactory /// Callback that is invoked just before a message is to be sent to a peer, or null when nothing needs to be called. private Action onSendingMessage; - private IPeerAddressManager peerAddressManager; + private readonly IPeerAddressManager peerAddressManager; public NetworkPeerFactory(Network network, IDateTimeProvider dateTimeProvider, From c7a7921d658bb5455e769ed36d69dc06c7b74b43 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 5 Mar 2020 11:43:52 +0000 Subject: [PATCH 6/8] Update NetworkPeerServerTests.cs --- .../P2P/NetworkPeerServerTests.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs b/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs index 7515645f9ed..891b5bc3f20 100644 --- a/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs +++ b/src/Stratis.Bitcoin.Tests/P2P/NetworkPeerServerTests.cs @@ -57,15 +57,31 @@ public void Validate_AllowClientConnection_State(bool inIBD, bool isWhiteListed, peerAddressManager.Setup(pam => pam.FindPeersByIp(It.IsAny())).Returns(new List()); var networkPeerServer = new NetworkPeerServer(this.Network, - endpointAddNode, endpointAddNode, ProtocolVersion.PROTOCOL_VERSION, this.extendedLoggerFactory, - networkPeerFactory.Object, initialBlockDownloadState.Object, connectionManagerSettings, asyncProvider, peerAddressManager.Object, DateTimeProvider.Default); + endpointAddNode, + endpointAddNode, + ProtocolVersion.PROTOCOL_VERSION, + this.extendedLoggerFactory, + networkPeerFactory.Object, + initialBlockDownloadState.Object, + connectionManagerSettings, + asyncProvider, + peerAddressManager.Object, + DateTimeProvider.Default); // Mimic external client const int portNumber = 80; var client = new TcpClient("www.stratisplatform.com", portNumber); + string ip = string.Empty; var ipandport = client.Client.RemoteEndPoint.ToString(); - var ip = ipandport.Replace(ipandport.Substring(ipandport.IndexOf(':')), ""); + if (client.Client.RemoteEndPoint.AddressFamily == AddressFamily.InterNetwork) + { + ip = ipandport.Replace(ipandport.Substring(ipandport.IndexOf(':')), ""); + } + else + { + ip = ipandport.Substring(1, ipandport.LastIndexOf(']') - 1); + } var endpointDiscovered = new IPEndPoint(IPAddress.Parse(ip), portNumber); From 70a91c6baa3c1750c578ded28a662ce7a2fc9d64 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 5 Mar 2020 12:56:40 +0000 Subject: [PATCH 7/8] Trigger CI --- src/Stratis.TokenlessD/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stratis.TokenlessD/Program.cs b/src/Stratis.TokenlessD/Program.cs index 49a339ffaab..0bf9f3b702e 100644 --- a/src/Stratis.TokenlessD/Program.cs +++ b/src/Stratis.TokenlessD/Program.cs @@ -52,7 +52,7 @@ public static async Task Main(string[] args) } catch (Exception ex) { - Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.ToString()); + Console.WriteLine("There was a problem initializing the node : '{0}'", ex.ToString()); } } } From 1d30bd162325b094e7466094299107026abefb29 Mon Sep 17 00:00:00 2001 From: Jordan Andrews Date: Fri, 6 Mar 2020 11:18:52 +1100 Subject: [PATCH 8/8] Determinism test fixes --- .../DeterminismValidationTests.cs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Stratis.SmartContracts.CLR.Tests/DeterminismValidationTests.cs b/src/Stratis.SmartContracts.CLR.Tests/DeterminismValidationTests.cs index e1ec244d103..68398db5e03 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/DeterminismValidationTests.cs +++ b/src/Stratis.SmartContracts.CLR.Tests/DeterminismValidationTests.cs @@ -135,14 +135,19 @@ public void ValidateAnonymousClassesDisallowed() [Fact] public void Validate_Determinism_AppDomain() { - // AppDomain should not be available - // We do not compile contracts with a reference to System.Runtime.Extensions + // AppDomain is available in the public namespace string adjustedSource = TestString.Replace(ReplaceCodeString, @"var test = AppDomain.CurrentDomain; var test2 = test.Id;").Replace(ReplaceReferencesString, ""); - ContractCompilationResult compilationResult = ContractCompiler.Compile(adjustedSource); - Assert.False(compilationResult.Success); + Assert.True(compilationResult.Success); + + // But it shouldn't make it through determinism validation. + byte[] assemblyBytes = compilationResult.Compilation; + IContractModuleDefinition moduleDefinition = ContractDecompiler.GetModuleDefinition(assemblyBytes).Value; + SmartContractValidationResult result = this.validator.Validate(moduleDefinition.ModuleDefinition); + Assert.False(result.IsValid); } + #endregion #region Async @@ -404,12 +409,17 @@ public void Validate_Determinism_DynamicTypeAllowed() [Fact] public void Validate_Determinism_Environment() { - // Environment should not be available - // We do not compile contracts with a reference to System.Runtime.Extensions + // Environment is available string adjustedSource = TestString.Replace(ReplaceCodeString, "int test = Environment.TickCount;").Replace(ReplaceReferencesString, ""); - ContractCompilationResult compilationResult = ContractCompiler.Compile(adjustedSource); - Assert.False(compilationResult.Success); + Assert.True(compilationResult.Success); + + // But will not pass determinism validation. + byte[] assemblyBytes = compilationResult.Compilation; + IContractModuleDefinition moduleDefinition = ContractDecompiler.GetModuleDefinition(assemblyBytes).Value; + SmartContractValidationResult result = this.validator.Validate(moduleDefinition.ModuleDefinition); + + Assert.False(result.IsValid); } #endregion