mock.go 621 Bytes
Newer Older
1
package bstest
2 3

import (
Jeromy's avatar
Jeromy committed
4
	. "github.com/ipfs/go-blockservice"
Hector Sanjuan's avatar
Hector Sanjuan committed
5

Hector Sanjuan's avatar
Hector Sanjuan committed
6
	testinstance "github.com/ipfs/go-bitswap/testinstance"
Jeromy's avatar
Jeromy committed
7 8 9
	tn "github.com/ipfs/go-bitswap/testnet"
	delay "github.com/ipfs/go-ipfs-delay"
	mockrouting "github.com/ipfs/go-ipfs-routing/mock"
10 11 12
)

// Mocks returns |n| connected mock Blockservices
13
func Mocks(n int) []BlockService {
14
	net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
Hector Sanjuan's avatar
Hector Sanjuan committed
15
	sg := testinstance.NewTestInstanceGenerator(net)
16 17 18

	instances := sg.Instances(n)

19
	var servs []BlockService
20
	for _, i := range instances {
21
		servs = append(servs, New(i.Blockstore(), i.Exchange))
22 23 24
	}
	return servs
}