// printing self is special cased as we get values differently. func printSelf(node *core.IpfsNode) (interface{}, error) { info := new(IdOutput) info.ID = node.Identity.Pretty() if node.PrivateKey == nil { if err := node.LoadPrivateKey(); err != nil { return nil, err } } pk := node.PrivateKey.GetPublic() pkb, err := ic.MarshalPublicKey(pk) if err != nil { return nil, err } info.PublicKey = base64.StdEncoding.EncodeToString(pkb) if node.PeerHost != nil { for _, a := range node.PeerHost.Addrs() { s := a.String() + "/ipfs/" + info.ID info.Addresses = append(info.Addresses, s) } } info.ProtocolVersion = identify.IpfsVersion info.AgentVersion = identify.ClientVersion return info, nil }
func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.Mount) { maybeSkipFuseTests(t) var err error if node == nil { node, err = core.NewNode(context.Background(), nil) if err != nil { t.Fatal(err) } err = node.LoadPrivateKey() if err != nil { t.Fatal(err) } node.Routing = offroute.NewOfflineRouter(node.Repo.Datastore(), node.PrivateKey) node.Namesys = namesys.NewNameSystem(node.Routing, node.Repo.Datastore(), 0) err = InitializeKeyspace(node, node.PrivateKey) if err != nil { t.Fatal(err) } } fs, err := NewFileSystem(node, node.PrivateKey, "", "") if err != nil { t.Fatal(err) } mnt, err := fstest.MountedT(t, fs) if err != nil { t.Fatal(err) } return node, mnt }