github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/blockservice/test/mock.go (about) 1 package bstest 2 3 import ( 4 . "github.com/ipfs/go-ipfs/blockservice" 5 bitswap "github.com/ipfs/go-ipfs/exchange/bitswap" 6 tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet" 7 mockrouting "github.com/ipfs/go-ipfs/routing/mock" 8 delay "github.com/ipfs/go-ipfs/thirdparty/delay" 9 ) 10 11 // Mocks returns |n| connected mock Blockservices 12 func Mocks(n int) []*BlockService { 13 net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0)) 14 sg := bitswap.NewTestSessionGenerator(net) 15 16 instances := sg.Instances(n) 17 18 var servs []*BlockService 19 for _, i := range instances { 20 servs = append(servs, New(i.Blockstore(), i.Exchange)) 21 } 22 return servs 23 }