Commit 3ca26062 authored by Zander Mackie's avatar Zander Mackie

Testing the rest of the interface

License: MIT
Signed-off-by: default avatarZander Mackie <zmackie@gmail.com>
parent eac4ce04
......@@ -46,3 +46,34 @@ func TestOfflineRouterStorage(t *testing.T) {
}
}
func TestOfflineRouterLocal(t *testing.T) {
ctx := context.Background()
nds := ds.NewMapDatastore()
privkey, _, _ := testutil.RandTestKeyPair(128)
offline := NewOfflineRouter(nds, privkey)
id, _ := testutil.RandPeerID()
_, err := offline.FindPeer(ctx, id)
if err != ErrOffline {
t.Fatal("OfflineRouting should alert that its offline")
}
cid, _ := testutil.RandCidV0()
pChan := offline.FindProvidersAsync(ctx, cid, 1)
p, ok := <-pChan
if ok {
t.Fatalf("FindProvidersAsync did not return a closed channel. Instead we got %+v !", p)
}
cid, _ = testutil.RandCidV0()
err = offline.Provide(ctx, cid)
if err != ErrOffline {
t.Fatal("OfflineRouting should alert that its offline")
}
err = offline.Bootstrap(ctx)
if err != nil {
t.Fatal("You shouldn't be able to bootstrap offline routing.")
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment