Commit 5284b7cc authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(mdag, bserv, bs) mocks, etc.

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 3a1aa2fa
...@@ -7,13 +7,10 @@ import ( ...@@ -7,13 +7,10 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
bserv "github.com/jbenet/go-ipfs/blockservice" blockservice "github.com/jbenet/go-ipfs/blockservice"
bs "github.com/jbenet/go-ipfs/exchange/bitswap"
tn "github.com/jbenet/go-ipfs/exchange/bitswap/testnet"
imp "github.com/jbenet/go-ipfs/importer" imp "github.com/jbenet/go-ipfs/importer"
chunk "github.com/jbenet/go-ipfs/importer/chunk" chunk "github.com/jbenet/go-ipfs/importer/chunk"
. "github.com/jbenet/go-ipfs/merkledag" . "github.com/jbenet/go-ipfs/merkledag"
"github.com/jbenet/go-ipfs/routing/mock"
uio "github.com/jbenet/go-ipfs/unixfs/io" uio "github.com/jbenet/go-ipfs/unixfs/io"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
...@@ -79,20 +76,8 @@ func makeTestDag(t *testing.T) *Node { ...@@ -79,20 +76,8 @@ func makeTestDag(t *testing.T) *Node {
} }
func TestBatchFetch(t *testing.T) { func TestBatchFetch(t *testing.T) {
net := tn.VirtualNetwork()
rs := mock.VirtualRoutingServer()
sg := bs.NewSessionGenerator(net, rs)
instances := sg.Instances(5)
var servs []*bserv.BlockService
var dagservs []DAGService var dagservs []DAGService
for _, i := range instances { for _, bsi := range blockservice.Mocks(t, 5) {
bsi, err := bserv.New(i.Blockstore, i.Exchange)
if err != nil {
t.Fatal(err)
}
servs = append(servs, bsi)
dagservs = append(dagservs, NewDAGService(bsi)) dagservs = append(dagservs, NewDAGService(bsi))
} }
t.Log("finished setup.") t.Log("finished setup.")
......
package merkledag
import (
"testing"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
dssync "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
"github.com/jbenet/go-ipfs/blocks/blockstore"
bsrv "github.com/jbenet/go-ipfs/blockservice"
"github.com/jbenet/go-ipfs/exchange/offline"
)
func Mock(t testing.TB) DAGService {
bstore := blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore()))
bserv, err := bsrv.New(bstore, offline.Exchange(bstore))
if err != nil {
t.Fatal(err)
}
return NewDAGService(bserv)
}
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