Testing the rest of the interface
License: MIT Signed-off-by: Zander Mackie <zmackie@gmail.com>
Zander Mackie committed
Dec 14, 2016 at 07:25 UTC
834f22328cb3c24051d706b88aa24d6976f195ca
1 file changed
+31
routing/offline/offline_test.go
+31
@@ -46,3 +46,34 @@ func TestOfflineRouterStorage(t *testing.T) {
46
}
47
}
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
+}