Skip to content

Commit 066e74f

Browse files
test(pubsub): make the topic unique
This should avoid timing issues on the CI server
1 parent 9b52660 commit 066e74f

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

test/CoreApi/PubSubApiTest.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,19 @@ public void Subscribed_Topics()
3737
// TODO: Assert.IsTrue(peers.Length > 0);
3838
}
3939

40-
[TestMethod]
41-
public void Publish()
42-
{
43-
var ipfs = TestFixture.Ipfs;
44-
ipfs.PubSub.Publish("foo", "hello world test").Wait();
45-
// TODO: test if published
46-
}
47-
4840
[TestMethod]
4941
public async Task Subscribe()
5042
{
5143
int messageCount = 0;
5244
var ipfs = TestFixture.Ipfs;
53-
var topic = "net-ipfs-api-test";
45+
var topic = "net-ipfs-api-test-" + Guid.NewGuid().ToString();
5446
await ipfs.PubSub.Subscribe(topic, msg =>
5547
{
5648
Interlocked.Increment(ref messageCount);
5749
});
58-
await ipfs.PubSub.Publish(topic, "hello world");
59-
await ipfs.PubSub.Publish(topic, "hello world");
60-
await Task.Delay(5000);
50+
await ipfs.PubSub.Publish(topic, "hello world!");
51+
await ipfs.PubSub.Publish(topic, "hello world!!");
52+
await Task.Delay(1000);
6153
Assert.AreEqual(2, messageCount);
6254
}
6355

@@ -66,20 +58,20 @@ public async Task Unsubscribe()
6658
{
6759
int messageCount = 0;
6860
var ipfs = TestFixture.Ipfs;
69-
var topic = "net-ipfs-api-test";
61+
var topic = "net-ipfs-api-test-" + Guid.NewGuid().ToString();
7062
var cs = new CancellationTokenSource();
7163
await ipfs.PubSub.Subscribe(topic, msg =>
7264
{
7365
Interlocked.Increment(ref messageCount);
7466
}, cs.Token);
75-
await ipfs.PubSub.Publish(topic, "hello world");
76-
await ipfs.PubSub.Publish(topic, "hello world");
77-
await Task.Delay(5000);
67+
await ipfs.PubSub.Publish(topic, "hello world!");
68+
await ipfs.PubSub.Publish(topic, "hello world!!");
69+
await Task.Delay(1000);
7870
Assert.AreEqual(2, messageCount);
7971

8072
cs.Cancel();
81-
await ipfs.PubSub.Publish(topic, "hello world");
82-
await Task.Delay(2000);
73+
await ipfs.PubSub.Publish(topic, "hello world!!!");
74+
await Task.Delay(1000);
8375
Assert.AreEqual(2, messageCount);
8476
}
8577
}

0 commit comments

Comments
 (0)