utils.go 648 Bytes
Newer Older
1
package mdutils
2 3 4 5 6 7 8 9 10

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"
11
	dag "github.com/jbenet/go-ipfs/merkledag"
12 13
)

14
func Mock(t testing.TB) dag.DAGService {
15 16 17 18 19
	bstore := blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore()))
	bserv, err := bsrv.New(bstore, offline.Exchange(bstore))
	if err != nil {
		t.Fatal(err)
	}
20
	return dag.NewDAGService(bserv)
21
}