| 49 | } |
| 50 | |
| 51 | func 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 | |
| 85 | func MockPublicNode(ctx context.Context, mn mocknet.Mocknet) (*core.IpfsNode, error) { |
| 86 | ds := syncds.MutexWrap(datastore.NewMapDatastore()) |