File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -46,3 +46,34 @@ func TestOfflineRouterStorage(t *testing.T) {
46
46
}
47
47
}
48
48
49
+ func TestOfflineRouterLocal (t * testing.T ) {
50
+ ctx := context .Background ()
51
+
52
+ nds := ds .NewMapDatastore ()
53
+ privkey , _ , _ := testutil .RandTestKeyPair (128 )
54
+ offline := NewOfflineRouter (nds , privkey )
55
+
56
+ id , _ := testutil .RandPeerID ()
57
+ _ , err := offline .FindPeer (ctx , id )
58
+ if err != ErrOffline {
59
+ t .Fatal ("OfflineRouting should alert that its offline" )
60
+ }
61
+
62
+ cid , _ := testutil .RandCidV0 ()
63
+ pChan := offline .FindProvidersAsync (ctx , cid , 1 )
64
+ p , ok := <- pChan
65
+ if ok {
66
+ t .Fatalf ("FindProvidersAsync did not return a closed channel. Instead we got %+v !" , p )
67
+ }
68
+
69
+ cid , _ = testutil .RandCidV0 ()
70
+ err = offline .Provide (ctx , cid )
71
+ if err != ErrOffline {
72
+ t .Fatal ("OfflineRouting should alert that its offline" )
73
+ }
74
+
75
+ err = offline .Bootstrap (ctx )
76
+ if err != nil {
77
+ t .Fatal ("You shouldn't be able to bootstrap offline routing." )
78
+ }
79
+ }
You can’t perform that action at this time.
0 commit comments