提交 c044d9c3 作者: Jeromy 提交者: Brian Tiger Chow

move mock routing tests to proper directory

上级 414ff341
package mockrouter package mock
import ( import (
"errors" "errors"
......
package bitswap package mock
import ( import (
"bytes" "bytes"
...@@ -6,13 +6,12 @@ import ( ...@@ -6,13 +6,12 @@ import (
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
"github.com/jbenet/go-ipfs/peer" "github.com/jbenet/go-ipfs/peer"
mock "github.com/jbenet/go-ipfs/routing/mock"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
func TestKeyNotFound(t *testing.T) { func TestKeyNotFound(t *testing.T) {
vrs := mock.VirtualRoutingServer() vrs := VirtualRoutingServer()
empty := vrs.Providers(u.Key("not there")) empty := vrs.Providers(u.Key("not there"))
if len(empty) != 0 { if len(empty) != 0 {
t.Fatal("should be empty") t.Fatal("should be empty")
...@@ -25,7 +24,7 @@ func TestSetAndGet(t *testing.T) { ...@@ -25,7 +24,7 @@ func TestSetAndGet(t *testing.T) {
ID: pid, ID: pid,
} }
k := u.Key("42") k := u.Key("42")
rs := mock.VirtualRoutingServer() rs := VirtualRoutingServer()
err := rs.Announce(p, k) err := rs.Announce(p, k)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -44,7 +43,7 @@ func TestSetAndGet(t *testing.T) { ...@@ -44,7 +43,7 @@ func TestSetAndGet(t *testing.T) {
func TestClientFindProviders(t *testing.T) { func TestClientFindProviders(t *testing.T) {
peer := &peer.Peer{ID: []byte("42")} peer := &peer.Peer{ID: []byte("42")}
rs := mock.VirtualRoutingServer() rs := VirtualRoutingServer()
client := rs.Client(peer) client := rs.Client(peer)
k := u.Key("hello") k := u.Key("hello")
...@@ -78,7 +77,7 @@ func TestClientFindProviders(t *testing.T) { ...@@ -78,7 +77,7 @@ func TestClientFindProviders(t *testing.T) {
} }
func TestClientOverMax(t *testing.T) { func TestClientOverMax(t *testing.T) {
rs := mock.VirtualRoutingServer() rs := VirtualRoutingServer()
k := u.Key("hello") k := u.Key("hello")
numProvidersForHelloKey := 100 numProvidersForHelloKey := 100
for i := 0; i < numProvidersForHelloKey; i++ { for i := 0; i < numProvidersForHelloKey; i++ {
...@@ -112,7 +111,7 @@ func TestClientOverMax(t *testing.T) { ...@@ -112,7 +111,7 @@ func TestClientOverMax(t *testing.T) {
// TODO does dht ensure won't receive self as a provider? probably not. // TODO does dht ensure won't receive self as a provider? probably not.
func TestCanceledContext(t *testing.T) { func TestCanceledContext(t *testing.T) {
rs := mock.VirtualRoutingServer() rs := VirtualRoutingServer()
k := u.Key("hello") k := u.Key("hello")
t.Log("async'ly announce infinite stream of providers for key") t.Log("async'ly announce infinite stream of providers for key")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论