Skip to content

Commit 834f223

Browse files
committed
Testing the rest of the interface
License: MIT Signed-off-by: Zander Mackie <[email protected]>
1 parent 058bfc3 commit 834f223

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

routing/offline/offline_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,34 @@ func TestOfflineRouterStorage(t *testing.T) {
4646
}
4747
}
4848

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+
}

0 commit comments

Comments
 (0)