-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #10019 from djdv/uds-client
fix(rpc): cross-platform support for /unix/ socket maddrs in Addresses.API
- Loading branch information
Showing
5 changed files
with
109 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"path" | ||
"testing" | ||
|
||
rpcapi "github.com/ipfs/kubo/client/rpc" | ||
"github.com/ipfs/kubo/config" | ||
"github.com/ipfs/kubo/test/cli/harness" | ||
"github.com/multiformats/go-multiaddr" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRPCUnixSocket(t *testing.T) { | ||
node := harness.NewT(t).NewNode().Init() | ||
|
||
sockDir := node.Dir | ||
sockAddr := path.Join("/unix", sockDir, "sock") | ||
|
||
node.UpdateConfig(func(cfg *config.Config) { | ||
//cfg.Addresses.API = append(cfg.Addresses.API, sockPath) | ||
cfg.Addresses.API = []string{sockAddr} | ||
}) | ||
t.Log("Starting daemon with unix socket:", sockAddr) | ||
node.StartDaemon() | ||
|
||
unixMaddr, err := multiaddr.NewMultiaddr(sockAddr) | ||
require.NoError(t, err) | ||
|
||
apiClient, err := rpcapi.NewApi(unixMaddr) | ||
require.NoError(t, err) | ||
|
||
var ver struct { | ||
Version string | ||
} | ||
err = apiClient.Request("version").Exec(context.Background(), &ver) | ||
require.NoError(t, err) | ||
require.NotEmpty(t, ver) | ||
t.Log("Got version:", ver.Version) | ||
|
||
var res struct { | ||
ID string | ||
} | ||
err = apiClient.Request("id").Exec(context.Background(), &res) | ||
require.NoError(t, err) | ||
require.NotEmpty(t, res) | ||
t.Log("Got ID:", res.ID) | ||
|
||
node.StopDaemon() | ||
} |