Setting up basic test for waku
This commit is contained in:
parent
12f6710a56
commit
3776f46c02
@ -32,8 +32,6 @@ namespace WakuPlugin
|
|||||||
{
|
{
|
||||||
AddEnvVar("WAKUNODE2_DISCV5_BOOTSTRAP_NODE", config.BootstrapEnr);
|
AddEnvVar("WAKUNODE2_DISCV5_BOOTSTRAP_NODE", config.BootstrapEnr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEnvVar("WAKUNODE2_TOPICS", "test_topics_plz");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ namespace WakuPlugin
|
|||||||
public interface IWakuNode : IHasContainer
|
public interface IWakuNode : IHasContainer
|
||||||
{
|
{
|
||||||
DebugInfoResponse DebugInfo();
|
DebugInfoResponse DebugInfo();
|
||||||
|
void SubscribeToTopic(string topic);
|
||||||
|
void SendMessage(string topic, string message);
|
||||||
|
string[] GetMessages(string topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WakuNode : IWakuNode
|
public class WakuNode : IWakuNode
|
||||||
@ -25,6 +28,22 @@ namespace WakuPlugin
|
|||||||
return Http().HttpGetJson<DebugInfoResponse>("debug/v1/info");
|
return Http().HttpGetJson<DebugInfoResponse>("debug/v1/info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SubscribeToTopic(string topic)
|
||||||
|
{
|
||||||
|
var response = Http().HttpPostString("relay/v1/subscriptions", topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendMessage(string topic, string message)
|
||||||
|
{
|
||||||
|
var response = Http().HttpPostString($"relay/v1/messages/{topic}", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] GetMessages(string topic)
|
||||||
|
{
|
||||||
|
var response = Http().HttpGetString($"relay/v1/messages/{topic}");
|
||||||
|
return new[] { "" };
|
||||||
|
}
|
||||||
|
|
||||||
private IHttp Http()
|
private IHttp Http()
|
||||||
{
|
{
|
||||||
return tools.CreateHttp(Container.Address, "");
|
return tools.CreateHttp(Container.Address, "");
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public interface IWakuSetup
|
public interface IWakuSetup
|
||||||
{
|
{
|
||||||
|
IWakuSetup WithName(string name);
|
||||||
IWakuSetup WithBootstrapNode(IWakuNode node);
|
IWakuSetup WithBootstrapNode(IWakuNode node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,16 +8,20 @@ namespace WakuTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void Hi()
|
public void Hi()
|
||||||
{
|
{
|
||||||
var node1 = Ci.StartWakuNode();
|
var bootNode = Ci.StartWakuNode(s => s.WithName("BootstrapNode"));
|
||||||
|
var node = Ci.StartWakuNode(s => s.WithName("Waku1").WithBootstrapNode(bootNode));
|
||||||
|
|
||||||
var info1 = node1.DebugInfo();
|
var topic = "cheeseWheels";
|
||||||
Assert.That(info1.enrUri, Is.Not.Empty);
|
var message = "hmm, cheese...";
|
||||||
|
|
||||||
var node2 = Ci.StartWakuNode(s => s.WithBootstrapNode(node1));
|
bootNode.SubscribeToTopic(topic);
|
||||||
var info2 = node2.DebugInfo();
|
node.SubscribeToTopic(topic);
|
||||||
Assert.That(info2.enrUri, Is.Not.Empty);
|
|
||||||
|
|
||||||
|
node.SendMessage(topic, message);
|
||||||
|
|
||||||
|
var received = bootNode.GetMessages(topic);
|
||||||
|
|
||||||
|
CollectionAssert.Contains(received, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user