-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from lazyledger/hlib/zero-bootstrapping
- Loading branch information
Showing
19 changed files
with
400 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,54 @@ | ||
package ipfs | ||
|
||
import ( | ||
"io" | ||
"context" | ||
|
||
nilrouting "github.com/ipfs/go-ipfs-routing/none" | ||
"github.com/ipfs/go-ipfs/core" | ||
coremock "github.com/ipfs/go-ipfs/core/mock" | ||
ipld "github.com/ipfs/go-ipld-format" | ||
mdutils "github.com/ipfs/go-merkledag/test" | ||
coreiface "github.com/ipfs/interface-go-ipfs-core" | ||
"github.com/libp2p/go-libp2p-core/routing" | ||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" | ||
|
||
"github.com/lazyledger/lazyledger-core/ipfs/plugin" | ||
) | ||
|
||
// Mock provides simple mock IPFS API useful for testing | ||
func Mock() APIProvider { | ||
return func() (coreiface.APIDagService, io.Closer, error) { | ||
dom := dagOnlyMock{mdutils.Mock()} | ||
return func() (coreiface.APIDagService, *core.IpfsNode, error) { | ||
plugin.EnableNMT() | ||
|
||
nd, err := MockNode() | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
return dom, dom, nil | ||
return dagOnlyMock{nd.DAG}, nd, nil | ||
} | ||
} | ||
|
||
func MockNode() (*core.IpfsNode, error) { | ||
ctx := context.TODO() | ||
nd, err := core.NewNode(ctx, &core.BuildCfg{ | ||
Online: true, | ||
Host: coremock.MockHostOption(mocknet.New(ctx)), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
nd.Routing = MockRouting() | ||
return nd, err | ||
} | ||
|
||
func MockRouting() routing.Routing { | ||
croute, _ := nilrouting.ConstructNilRouting(context.TODO(), nil, nil, nil) | ||
return croute | ||
} | ||
|
||
type dagOnlyMock struct { | ||
ipld.DAGService | ||
} | ||
|
||
func (dom dagOnlyMock) Dag() coreiface.APIDagService { return dom } | ||
func (dagOnlyMock) Close() error { return nil } | ||
func (dom dagOnlyMock) Pinning() ipld.NodeAdder { return dom } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package ipfs | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/ipfs/go-ipfs/core" | ||
coreiface "github.com/ipfs/interface-go-ipfs-core" | ||
) | ||
|
||
// APIProvider allows customizable IPFS core APIs. | ||
type APIProvider func() (coreiface.APIDagService, io.Closer, error) | ||
type APIProvider func() (coreiface.APIDagService, *core.IpfsNode, error) |
Oops, something went wrong.