FASTER relay
This commit is contained in:
24
BasicTests/BasicTests.csproj
Normal file
24
BasicTests/BasicTests.csproj
Normal file
@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
|
||||
<PackageReference Include="NUnit" Version="3.13.3"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NostrRelay\NostrRelay.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
1
BasicTests/GlobalUsings.cs
Normal file
1
BasicTests/GlobalUsings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using NUnit.Framework;
|
44
BasicTests/NostrBufTests.cs
Normal file
44
BasicTests/NostrBufTests.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Newtonsoft.Json;
|
||||
using Nostr.Client.Json;
|
||||
using Nostr.Client.Messages;
|
||||
using NostrRelay;
|
||||
|
||||
namespace BasicTests;
|
||||
|
||||
public class Tests
|
||||
{
|
||||
private NostrEvent _testEvent = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var json =
|
||||
"{\"id\":\"0552df8c6617c8919f1872ce8a0b2834f3f28100e4bf07be8b4aa262e9d59321\",\"pubkey\":\"27154fb873badf69c3ea83a0da6e65d6a150d2bf8f7320fc3314248d74645c64\",\"created_at\":1705062495,\"kind\":1,\"tags\":[[\"r\",\"https://www.coindesk.com/business/2024/01/12/bitcoin-miner-outflows-hit-six-year-highs-ahead-of-halving-sparking-mixed-signals/\"]],\"content\":\"‚Miner outflow has hit a multi-year high as tens of thousands of bitcoin (BTC), worth over $1 billion, have been sent to exchanges.‘\\n\\nhttps://www.coindesk.com/business/2024/01/12/bitcoin-miner-outflows-hit-six-year-highs-ahead-of-halving-sparking-mixed-signals/\",\"sig\":\"ba2523600bea47637bcced3b75ec446253dca184783a98ec807bf0a4fc90031152c225e7a39392bb3af23ceafc64aa67d9c10874e8ec6d2c1af268235a554d93\"}";
|
||||
|
||||
_testEvent = JsonConvert.DeserializeObject<NostrEvent>(json, NostrSerializer.Settings)!;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNostrBuf()
|
||||
{
|
||||
var data = NostrBuf.Encode(_testEvent);
|
||||
Assert.That(data.Length, Is.EqualTo(NostrBuf.CalculateSize(_testEvent)));
|
||||
|
||||
var ev = NostrBuf.Decode(data);
|
||||
Assert.That(ev.Id, Is.EqualTo(_testEvent.Id));
|
||||
Assert.That(ev.Pubkey, Is.EqualTo(_testEvent.Pubkey));
|
||||
Assert.That(ev.Sig, Is.EqualTo(_testEvent.Sig));
|
||||
Assert.That(ev.CreatedAt, Is.EqualTo(_testEvent.CreatedAt));
|
||||
Assert.That(ev.Kind, Is.EqualTo(_testEvent.Kind));
|
||||
Assert.That(ev.Tags!.Count, Is.EqualTo(_testEvent.Tags!.Count));
|
||||
for (var tx = 0; tx < ev.Tags.Count; tx++)
|
||||
{
|
||||
Assert.That(ev.Tags[tx].TagIdentifier, Is.EqualTo(_testEvent.Tags[tx].TagIdentifier));
|
||||
Assert.That(ev.Tags[tx].AdditionalData.Length, Is.EqualTo(_testEvent.Tags[tx].AdditionalData.Length));
|
||||
for (var ty = 0; ty < ev.Tags[tx].AdditionalData.Length; ty++)
|
||||
{
|
||||
Assert.That(ev.Tags[tx].AdditionalData[ty], Is.EqualTo(_testEvent.Tags[tx].AdditionalData[ty]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user