10000 Changed the dependency to the Microsoft NuGet package by DavidGershony · Pull Request #424 · block-core/angor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Changed the dependency to the Microsoft NuGet package #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.310"
"version": "9.0.301"
}
}
9 changes: 5 additions & 4 deletions src/Angor.Test/Angor.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.JSInterop" Version="8.0.11" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
<PackageReference Include="Microsoft.JSInterop" Version="9.0.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="System.Text.Json" Version="9.0.6" />
<PackageReference Include="xunit" Version="2.9.2" />

<PackageReference Include="Blockcore.Core" Version="1.1.41" />
<PackageReference Include="NBitcoin" Version="7.0.46" />
<PackageReference Include="NBitcoin" Version="9.0.0" />

<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
72 changes: 0 additions & 72 deletions src/Angor.Test/Services/TestSignService.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Angor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36D68A4A-B9A8-4A20-89F0-702E08EB1377}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
..\global.json = ..\global.json
..\LICENSE = ..\LICENSE
..\package-lock.json = ..\package-lock.json
..\package.json = ..\package.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Angor.Shared;
using Angor.Shared.Models;

namespace Angor.Contexts.Wallet.Infrastructure.Impl;
namespace Angor.Contests.CrossCutting;

public class NetworkStorage : INetworkStorage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Serilog.Extensions.Logging" />
<PackageReference Include="Moq" />
<PackageReference Include="Serilog.Sinks.XUnit" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
Expand All @@ -22,6 +23,7 @@

<ItemGroup>
<ProjectReference Include="..\Angor.Contexts.Funding\Angor.Contexts.Funding.csproj" />
<ProjectReference Include="..\Angor.Contexts.Integration.WalletFunding\Angor.Contexts.Integration.WalletFunding.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Angor.Contexts.Funding.Projects.Domain;
using Angor.Contexts.Funding.Shared;
using Angor.Contexts.Funding.Tests.TestDoubles;
using Angor.Shared;
using CSharpFunctionalExtensions;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
Expand All @@ -21,6 +20,24 @@ public void Service_can_be_created()
CreateSut();
}


[Fact]
public void Handlers_can_be_created()
{
// Arrange
var provider = GetServiceProvider();
var handlers = typeof(InvestmentAppService).Assembly.DefinedTypes.Where(t => t.IsClass && t.Name.EndsWith("Handler")).ToList();

// Act
var result = handlers
.Select(typeInfo => Result.Try(() => ActivatorUtilities.CreateInstance(provider, typeInfo))
.TapError(err => output.WriteLine($"Handler {typeInfo} failed to create. Please, check {nameof(FundingContextServices)}. Error: {err}")))
.Combine();

// Asert
Assert.True(result.IsSuccess);
}

[Fact]
public async Task Create_investment_draft()
{
Expand Down Expand Up @@ -81,18 +98,24 @@ public async Task Approve_investment()
// Assert
Assert.True(approveResult.IsSuccess);
}

private IInvestmentAppService CreateSut()
{
var serviceProvider = GetServiceProvider();
var projectAppService = serviceProvider.GetRequiredService<IInvestmentAppService>();

return projectAppService!;
}

private ServiceProvider GetServiceProvider()
{
var serviceCollection = new ServiceCollection();

var logger = new LoggerConfiguration().WriteTo.TestOutput(output).CreateLogger();
FundingContextServices.Register(serviceCollection, logger);
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", "", sp.GetRequiredService<IDerivationOperations>()));
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", ""));

var serviceProvider = serviceCollection.BuildServiceProvider();
var projectAppService = serviceProvider.GetService<IInvestmentAppService>();

return projectAppService!;
return serviceProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Angor.Contexts.Funding.Projects.Domain;
using Angor.Contexts.Funding.Shared;
using Angor.Contexts.Funding.Tests.TestDoubles;
using Angor.Shared;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Xunit.Abstractions;
Expand All @@ -26,14 +25,13 @@ public async Task Decrypt_Nostr_message()
Assert.NotEmpty(clientKeyResult.Value);
}


private NostrDecrypter CreateSut()
{
var serviceCollection = new ServiceCollection();

var logger = new LoggerConfiguration().WriteTo.TestOutput(output).CreateLogger();
FundingContextServices.Register(serviceCollection, logger);
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", "", sp.GetRequiredService<IDerivationOperations>()));
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", ""));

var serviceProvider = serviceCollection.BuildServiceProvider();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Angor.Contexts.Funding.Projects.Infrastructure.Interfaces;
using Angor.Contexts.Funding.Shared;
using Angor.Contexts.Funding.Tests.TestDoubles;
using Angor.Shared;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Xunit.Abstractions;
Expand Down Expand Up @@ -39,7 +38,7 @@ private IProjectAppService CreateSut()

var logger = new LoggerConfiguration().WriteTo.TestOutput(output).CreateLogger();
FundingContextServices.Register(serviceCollection, logger);
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", "", sp.GetRequiredService<IDerivationOperations>()));
serviceCollection.AddSingleton<ISeedwordsProvider>(sp => new TestingSeedwordsProvider("oven suggest panda hip orange cheap kite focus cross never tornado forget", ""));

var serviceProvider = serviceCollection.BuildServiceProvider();
var projectAppService = serviceProvider.GetService<IProjectAppService>();
Expand Down
67 changes: 67 additions & 0 deletions src/Angor/Avalonia/Angor.Contexts.Funding.Tests/SigningTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Angor.Contexts.Funding.Shared;
using Angor.Contexts.Funding.Tests.TestDoubles;
using Angor.Contexts.Integration.WalletFunding;
using Angor.Contexts.Wallet.Infrastructure.Impl;
using Angor.Contexts.Wallet.Infrastructure.Interfaces;
using Angor.Shared.Networks;
using Angor.Shared.Services;
using Blockcore.NBitcoin;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using NBitcoin;
using Nostr.Client.Client;
using Nostr.Client.Communicator;
using Nostr.Client.Keys;
using Serilog;
using Xunit.Abstractions;
using Key = NBitcoin.Key;

namespace Angor.Contexts.Funding.Tests;

public class SigningTests(ITestOutputHelper output)
{
[Fact]
public void Create_sign_service()
{
CreateSignService();
}

[Fact]
public async Task Post_investment_should_return_ok()
{
// Arrange
var sut = CreateSignService();
var founderNostrPubKey = NostrPrivateKey.GenerateNew().DerivePublicKey().Hex;
var founderPubKey = new Key().PubKey.ToHex();
var keyIdenfier = new KeyIdentifier(WalletAppService.SingleWalletId.Value, founderPubKey);

// Act
var result = await sut.PostInvestmentRequest(keyIdenfier, "TEST", founderNostrPubKey);

// Assert
Assert.True(result.IsSuccess);
}

private ISignaturesService CreateSignService()
{
var logger1 = new LoggerConfiguration()
.WriteTo.TestOutput(output)
.CreateLogger();


var walletSensitiveDateProvider = new TestSensitiveWalletDataProvider(
"print foil moment average quarter keep amateur shell tray roof acoustic where",
""
);

var serviceCollection = new ServiceCollection();
FundingContextServices.Register(serviceCollection, logger1);
serviceCollection.AddSingleton<ISeedwordsProvider, SeedwordsProvider>();
serviceCollection.AddSingleton<ISensitiveWalletDataProvider>(walletSensitiveDateProvider);
var provider = serviceCollection.BuildServiceProvider();

return provider.GetRequiredService<ISignaturesService>();
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
using Angor.Contexts.Funding;
using Angor.Contexts.Funding.Shared;
using Angor.Shared;
using Angor.Shared.Models;
using CSharpFunctionalExtensions;

namespace Angor.Contexts.Funding.Tests.TestDoubles;

public class TestingSeedwordsProvider : ISeedwordsProvider
{
private readonly IDerivationOperations derivationOperations;
private readonly string seed;
private readonly string passphrase;

public TestingSeedwordsProvider(string seed, string passphrase, IDerivationOperations derivationOperations)
public TestingSeedwordsProvider(string seed, string passphrase)
{
this.seed = seed;
this.passphrase = passphrase;
this.derivationOperations = derivationOperations;
}

public async Task<Result<string>> InvestorKey(Guid walletId, string founderKey)
{
return Result.Try(() => DeriveInvestorKey(founderKey));
}

public async Task<Result<(string Words, Maybe<string> Passphrase)>> GetSensitiveData(Guid walletId)
{
return (seed, passphrase);
}

private string DeriveInvestorKey(string founderKey)
{
return derivationOperations.DeriveInvestorKey(new WalletWords()
{
Words = seed,
Passphrase = passphrase
}, founderKey);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Angor.Contexts.Wallet.Domain;
using Angor.Contexts.Wallet.Infrastructure.Impl;
using Angor.Contexts.Wallet.Infrastructure.Interfaces;
using CSharpFunctionalExtensions;

namespace Angor.Contexts.Funding.Tests;

public class TestSensitiveWalletDataProvider : ISensitiveWalletDataProvider
{
private readonly string seed;
private readonly string passphrase;

public TestSensitiveWalletDataProvider(string seed, string passphrase)
{
this.seed = seed;
this.passphrase = passphrase;
}

public async Task<Result<(string seed, Maybe<string> passphrase)>> RequestSensitiveData(WalletId walletId)
{
if (walletId == WalletAppService.SingleWalletId)
{
return (seed, passphrase);
}

return Result.Failure<(string seed, Maybe<string> passphrase)>("Invalid id");
}

public void SetSensitiveData(WalletId id, (string seed, Maybe<string> passphrase) data)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private Task<Result> PerformSignatureApproval(SignatureItem signature, WalletWor

var encryptedContent = await encryption.EncryptNostrContentAsync(nostrPrivateKeyHex, signatureInvestorNostrPubKey, sigJson);

signService.SendSignaturesToInvestor(encryptedContent, nostrPrivateKeyHex, signatureInvestorNostrPubKey, signatureEventId);
signService.PostInvestmentRequestApproval(encryptedContent, nostrPrivateKeyHex, signatureInvestorNostrPubKey, signatureEventId);
});
}

Expand Down
Loading
0