(t *testing.T, ctx context.Context, fullIdentity bool, online bool, n int)
| 32 | type NodeProvider struct{} |
| 33 | |
| 34 | func (NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdentity bool, online bool, n int) ([]coreiface.CoreAPI, error) { |
| 35 | mn := mocknet.New() |
| 36 | |
| 37 | nodes := make([]*core.IpfsNode, n) |
| 38 | apis := make([]coreiface.CoreAPI, n) |
| 39 | |
| 40 | for i := range n { |
| 41 | var ident config.Identity |
| 42 | if fullIdentity { |
| 43 | sk, pk, err := crypto.GenerateKeyPair(crypto.RSA, 2048) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | |
| 48 | id, err := peer.IDFromPublicKey(pk) |
| 49 | if err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | |
| 53 | kbytes, err := crypto.MarshalPrivateKey(sk) |
| 54 | if err != nil { |
| 55 | return nil, err |
| 56 | } |
| 57 | |
| 58 | ident = config.Identity{ |
| 59 | PeerID: id.String(), |
| 60 | PrivKey: base64.StdEncoding.EncodeToString(kbytes), |
| 61 | } |
| 62 | } else { |
| 63 | ident = config.Identity{ |
| 64 | PeerID: testPeerID, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | c := config.Config{} |
| 69 | c.Addresses.Swarm = []string{fmt.Sprintf("/ip4/18.0.%d.1/tcp/4001", i)} |
| 70 | c.Identity = ident |
| 71 | c.Experimental.FilestoreEnabled = true |
| 72 | c.AutoTLS.Enabled = config.False // disable so no /ws listener is added |
| 73 | // For provider tests, avoid that content gets |
| 74 | // auto-provided without calling "provide" (unless pinned). |
| 75 | c.Provide.Strategy = config.NewOptionalString("roots") |
| 76 | |
| 77 | ds := syncds.MutexWrap(datastore.NewMapDatastore()) |
| 78 | r := &repo.Mock{ |
| 79 | C: c, |
| 80 | D: ds, |
| 81 | K: keystore.NewMemKeystore(), |
| 82 | F: filestore.NewFileManager(ds, filepath.Dir(os.TempDir())), |
| 83 | } |
| 84 | |
| 85 | node, err := core.NewNode(ctx, &core.BuildCfg{ |
| 86 | Routing: libp2p.DHTServerOption, |
| 87 | Repo: r, |
| 88 | Host: mock.MockHostOption(mn), |
| 89 | Online: online, |
| 90 | ExtraOpts: map[string]bool{ |
| 91 | "pubsub": true, |
nothing calls this directly
no test coverage detected