MCPcopy
hub / github.com/ipfs/kubo / MockCmdsCtx

Function MockCmdsCtx

core/mock/mock.go:51–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49}
50
51func MockCmdsCtx() (commands.Context, error) {
52 // Generate Identity
53 ident, err := testutil.RandIdentity()
54 if err != nil {
55 return commands.Context{}, err
56 }
57 p := ident.ID()
58
59 conf := config.Config{
60 Identity: config.Identity{
61 PeerID: p.String(),
62 },
63 }
64
65 r := &repo.Mock{
66 D: syncds.MutexWrap(datastore.NewMapDatastore()),
67 C: conf,
68 }
69
70 node, err := core.NewNode(context.Background(), &core.BuildCfg{
71 Repo: r,
72 })
73 if err != nil {
74 return commands.Context{}, err
75 }
76
77 return commands.Context{
78 ConfigRoot: "/tmp/.mockipfsconfig",
79 ConstructNode: func() (*core.IpfsNode, error) {
80 return node, nil
81 },
82 }, nil
83}
84
85func MockPublicNode(ctx context.Context, mn mocknet.Mocknet) (*core.IpfsNode, error) {
86 ds := syncds.MutexWrap(datastore.NewMapDatastore())

Callers

nothing calls this directly

Calls 3

NewNodeFunction · 0.92
IDMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected