Skip to content

Commit

Permalink
test: add extra test for client
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jul 18, 2022
1 parent 4a32ef8 commit 9d5bcf7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Oxide.Ext.GamingApiTests/GamingApiNatsTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Asyncapi.Nats.Client;
using NATS.Client;
using NATS.Client.JetStream;
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Threading;

namespace Oxide.Ext.GamingApi.Tests
Expand Down Expand Up @@ -58,5 +61,36 @@ public void replyToRustApiprocessServersServerIdEventsStartedTest()
blackhawkNats.PublishToV0RustServersServerIdEventsStarted("101");
}




[Test()]
public void randomTest()
{
Options opts = ConnectionFactory.GetDefaultOptions();

opts.Url = "nats://localhost:4222";
EventHandler<UserSignatureEventArgs> sigEh = (sender, args) =>
{
// get a private key seed from your environment.
string seed = "SUAHZGQCK3PKMY5JBY2PBJUK2SA2IAGNX7VXYQJ75MLIU2IWQE235OBLJM";

// Generate a NkeyPair
NkeyPair kp = Nkeys.FromSeed(seed);

// Sign the nonce and return the result in the SignedNonce
// args property. This must be set.
args.SignedNonce = kp.Sign(args.ServerNonce);
};
opts.SetNkey("UCI2NCSIEV3DXLYYR5KQXYCZ7CIW4KYXHLSGXJOZ7TSRRKHP2BM5IVMU", sigEh);
var c = new ConnectionFactory().CreateConnection(opts);
IJetStream js = c.CreateJetStreamContext();
var message = new Asyncapi.Nats.Client.Models.ChatMessage();
message.PlayerName = "test";
var json = JsonSerializer.Serialize(message);
var bytes = Encoding.UTF8.GetBytes(json);
js.Publish("v0.rust.servers.101.events.player.123.chatted", bytes);
}

}
}

0 comments on commit 9d5bcf7

Please sign in to comment.