Skip to content

Commit f0c5016

Browse files
test: mars node is not always available; use any bootstrap peer
1 parent 91c56b9 commit f0c5016

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

test/CoreApi/DhtApiTest.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,28 @@ namespace Ipfs.Api
1111
[TestClass]
1212
public class DhtApiTest
1313
{
14-
const string marsId = "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3";
15-
const string marsPublicKey = "CAASogEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKGUtbRQf+a9SBHFEruNAUatS/tsGUnHuCtifGrlbYPELD3UyyhWf/FYczBCavx3i8hIPEW2jQv4ehxQxi/cg9SHswZCQblSi0ucwTBFr8d40JEiyB9CcapiMdFQxdMgGvXEOQdLz1pz+UPUDojkdKZq8qkkeiBn7KlAoGEocnmpAgMBAAE=";
1614
const string helloWorldID = "QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o";
1715

1816
[TestMethod]
1917
public async Task FindPeer()
2018
{
2119
var ipfs = TestFixture.Ipfs;
22-
var peer = await ipfs.Dht.FindPeerAsync(marsId);
20+
Peer node;
21+
foreach (var peer in await ipfs.Bootstrap.ListAsync())
22+
{
23+
try
24+
{
25+
node = await ipfs.Dht.FindPeerAsync(peer.PeerId);
26+
}
27+
catch (Exception)
28+
{
29+
continue;
30+
}
2331

24-
// If DHT can't find a peer, it will return a 'closer' peer.
25-
Assert.IsNotNull(peer);
32+
// If DHT can't find a peer, it will return a 'closer' peer.
33+
Assert.IsNotNull(peer);
34+
break;
35+
}
2636
}
2737

2838
[TestMethod]

test/CoreApi/GenericApiTest.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
using Newtonsoft.Json.Linq;
33
using System;
44
using System.Text;
5-
5+
using System.Threading.Tasks;
6+
67
namespace Ipfs.Api
78
{
89
[TestClass]
910
public class GenericApiTest
1011
{
11-
const string marsId = "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3";
12-
1312
[TestMethod]
1413
public void Local_Node_Info()
1514
{
@@ -19,11 +18,23 @@ public void Local_Node_Info()
1918
}
2019

2120
[TestMethod]
22-
public void Mars_Node_Info()
21+
public async Task Peer_Node_Info()
2322
{
2423
var ipfs = TestFixture.Ipfs;
25-
var node = ipfs.IdAsync(marsId).Result;
26-
Assert.IsInstanceOfType(node, typeof(Peer));
24+
Peer node;
25+
foreach (var peer in await ipfs.Bootstrap.ListAsync())
26+
{
27+
try
28+
{
29+
node = await ipfs.IdAsync(peer.PeerId);
30+
}
31+
catch (Exception)
32+
{
33+
continue;
34+
}
35+
Assert.IsInstanceOfType(node, typeof(Peer));
36+
break;
37+
}
2738
}
2839

2940
[TestMethod]

0 commit comments

Comments
 (0)