File tree Expand file tree Collapse file tree 5 files changed +13
-35
lines changed Expand file tree Collapse file tree 5 files changed +13
-35
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ environment:
3030
3131# tools we need for bulding/testing/deploying
3232install :
33+ - dotnet --version
3334 - choco install gitversion.portable -y
3435 - nuget update -self
3536 - choco install docfx -y
Original file line number Diff line number Diff line change 2727 </PropertyGroup >
2828
2929 <ItemGroup >
30- <PackageReference Include =" Ipfs.Core" Version =" 0.35.0 " />
30+ <PackageReference Include =" Ipfs.Core" Version =" 0.35.2 " />
3131 <PackageReference Include =" Newtonsoft.Json" Version =" 11.0.2" />
3232 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'netstandard14'" />
3333 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'net45'" />
Original file line number Diff line number Diff line change 33using System ;
44using System . Linq ;
55using System . Text ;
6+ using System . Threading ;
67using System . Threading . Tasks ;
78
89namespace Ipfs . Api
@@ -17,29 +18,17 @@ public class DhtApiTest
1718 public async Task FindPeer ( )
1819 {
1920 var ipfs = TestFixture . Ipfs ;
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- }
31-
32- // If DHT can't find a peer, it will return a 'closer' peer.
33- Assert . IsNotNull ( peer ) ;
34- break ;
35- }
21+ var cts = new CancellationTokenSource ( TimeSpan . FromMinutes ( 2 ) ) ;
22+ var mars = await ipfs . Dht . FindPeerAsync ( "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3" , cts . Token ) ;
23+ Assert . IsNotNull ( mars ) ;
3624 }
3725
3826 [ TestMethod ]
3927 public async Task FindProviders ( )
4028 {
4129 var ipfs = TestFixture . Ipfs ;
42- var providers = await ipfs . Dht . FindProvidersAsync ( helloWorldID ) ;
30+ var cts = new CancellationTokenSource ( TimeSpan . FromMinutes ( 2 ) ) ;
31+ var providers = await ipfs . Dht . FindProvidersAsync ( helloWorldID , 1 , cts . Token ) ;
4332 Assert . AreNotEqual ( 0 , providers . Count ( ) ) ;
4433 }
4534
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ public void Api_Exists()
2525 public async Task Resolve ( )
2626 {
2727 IpfsClient ipfs = TestFixture . Ipfs ;
28- var path = await ipfs . Dns . ResolveAsync ( "ipfs.io" , recursive : true ) ;
28+ var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 30 ) ) ;
29+ var path = await ipfs . Dns . ResolveAsync ( "ipfs.io" , recursive : true , cancel : cts . Token ) ;
2930 StringAssert . StartsWith ( path , "/ipfs/" ) ;
3031 }
3132
Original file line number Diff line number Diff line change @@ -20,22 +20,9 @@ public void Local_Node_Info()
2020 [ TestMethod ]
2121 public async Task Peer_Node_Info ( )
2222 {
23- var ipfs = TestFixture . Ipfs ;
24- Peer node ;
25- var peers = await ipfs . Bootstrap . ListAsync ( ) ;
26- foreach ( var peer in peers )
27- {
28- try
29- {
30- node = await ipfs . IdAsync ( peer . PeerId ) ;
31- }
32- catch ( Exception )
33- {
34- continue ;
35- }
36- Assert . IsInstanceOfType ( node , typeof ( Peer ) ) ;
37- return ;
38- }
23+ var ipfs = TestFixture . Ipfs ;
24+ var mars = await ipfs . IdAsync ( "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3" ) ;
25+ Assert . IsNotNull ( mars ) ;
3926 }
4027
4128 [ TestMethod ]
You can’t perform that action at this time.
0 commit comments