Skip to content

Commit

Permalink
Testing the rest of the interface
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Zander Mackie <[email protected]>
  • Loading branch information
zmackie committed Dec 17, 2016
1 parent 058bfc3 commit 834f223
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions routing/offline/offline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

0 comments on commit 834f223

Please sign in to comment.