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_TOPICS", "test_topics_plz");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ namespace WakuPlugin
|
|||
public interface IWakuNode : IHasContainer
|
||||
{
|
||||
DebugInfoResponse DebugInfo();
|
||||
void SubscribeToTopic(string topic);
|
||||
void SendMessage(string topic, string message);
|
||||
string[] GetMessages(string topic);
|
||||
}
|
||||
|
||||
public class WakuNode : IWakuNode
|
||||
|
@ -25,6 +28,22 @@ namespace WakuPlugin
|
|||
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()
|
||||
{
|
||||
return tools.CreateHttp(Container.Address, "");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
public interface IWakuSetup
|
||||
{
|
||||
IWakuSetup WithName(string name);
|
||||
IWakuSetup WithBootstrapNode(IWakuNode node);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,20 @@ namespace WakuTests
|
|||
[Test]
|
||||
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();
|
||||
Assert.That(info1.enrUri, Is.Not.Empty);
|
||||
var topic = "cheeseWheels";
|
||||
var message = "hmm, cheese...";
|
||||
|
||||
var node2 = Ci.StartWakuNode(s => s.WithBootstrapNode(node1));
|
||||
var info2 = node2.DebugInfo();
|
||||
Assert.That(info2.enrUri, Is.Not.Empty);
|
||||
bootNode.SubscribeToTopic(topic);
|
||||
node.SubscribeToTopic(topic);
|
||||
|
||||
node.SendMessage(topic, message);
|
||||
|
||||
var received = bootNode.GetMessages(topic);
|
||||
|
||||
CollectionAssert.Contains(received, message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue