Don't import mocknet in builder.go
This commit is contained in:
parent
0a9ef94da5
commit
4797e6a473
@ -6,8 +6,6 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
|
||||
"github.com/ipfs/go-datastore"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
exchange "github.com/ipfs/go-ipfs-exchange-interface"
|
||||
@ -242,17 +240,6 @@ func New(ctx context.Context, opts ...Option) (api.API, error) {
|
||||
|
||||
// In-memory / testing
|
||||
|
||||
func MockHost(mn mocknet.Mocknet) Option {
|
||||
return Options(
|
||||
applyIf(func(s *settings) bool { return !s.online },
|
||||
Error(errors.New("MockHost must be specified after Online")),
|
||||
),
|
||||
|
||||
Override(new(lp2p.RawHost), lp2p.MockHost),
|
||||
Override(new(mocknet.Mocknet), mn),
|
||||
)
|
||||
}
|
||||
|
||||
func randomIdentity() Option {
|
||||
sk, pk, err := ci.GenerateKeyPair(ci.RSA, 512)
|
||||
if err != nil {
|
||||
|
19
node/testopts.go
Normal file
19
node/testopts.go
Normal file
@ -0,0 +1,19 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/node/modules/lp2p"
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
)
|
||||
|
||||
func MockHost(mn mocknet.Mocknet) Option {
|
||||
return Options(
|
||||
applyIf(func(s *settings) bool { return !s.online },
|
||||
Error(errors.New("MockHost must be specified after Online")),
|
||||
),
|
||||
|
||||
Override(new(lp2p.RawHost), lp2p.MockHost),
|
||||
Override(new(mocknet.Mocknet), mn),
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user