Skip to content

Commit

Permalink
test: prepare with offline routing test
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed May 2, 2023
1 parent e4c97b1 commit 90567ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions core/coreapi/test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe"

type NodeProvider struct{}

func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) {
func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, online bool, n int) ([]coreiface.CoreAPI, error) {
mn := mocknet.New()

nodes := make([]*core.IpfsNode, n)
Expand Down Expand Up @@ -82,7 +82,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
Routing: libp2p.DHTServerOption,
Repo: r,
Host: mock.MockHostOption(mn),
Online: fullIdentity,
Online: online,
ExtraOpts: map[string]bool{
"pubsub": true,
},
Expand All @@ -102,15 +102,17 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
return nil, err
}

bsinf := bootstrap.BootstrapConfigWithPeers(
[]peer.AddrInfo{
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
},
)
if online {
bsinf := bootstrap.BootstrapConfigWithPeers(
[]peer.AddrInfo{
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
},
)

for _, n := range nodes[1:] {
if err := n.Bootstrap(bsinf); err != nil {
return nil, err
for _, n := range nodes[1:] {
if err := n.Bootstrap(bsinf); err != nil {
return nil, err
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/test/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) {
defer cancel()

// Create a node
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, 1)
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, true, 1)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 90567ed

Please sign in to comment.