Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Conversation

@Stebalien
Copy link
Member

No description provided.

@djdv
Copy link
Contributor

djdv commented Sep 19, 2019

These test are only being run on Linux, they fail on Windows.

--- FAIL: TestFromUnix (0.00s)
    convert_test.go:19: failed to convert: /unix/c:/foo/bar != /unix/\c:\foo\bar
--- FAIL: TestUnixSockets (0.00s)
    net_test.go:92: listen unix /C:\Users\DOMINI~1\AppData\Local\Temp\manettest213534587\listen.sock: bind: An invalid argument was supplied.

I'm seeing similar behavior even with same slashed paths, in the 9P branch.

10:33:05.029 ERROR plugin/fil: 9P listen error: listen unix /t:/ipfs/filesystem.9p.sock: bind: An invalid argument was supplied.
 filesystem.go:102

Error: listen unix /t:/ipfs/filesystem.9p.sock: bind: An invalid argument was supplied.

Edit:
Worth pointing out that binding to the socket with the drive letter is omitted, succeeds.
e.g.
/unix/foo/bar will succeed and be placed at $currentWorkingDrive\foo\bar typically C:\foo\bar

* Convert to windows paths when converting from a multiaddr to a net.Addr
* Convert from windows paths when converting from a net.Addr to a multiaddr

Also, don't "clean". `filepath.Clean` is _usually_ correct but not _technically_
correct in all cases. We should leave cleaning to the application.
@Stebalien
Copy link
Member Author

Hm. We really need to get windows tests working. Could you test it now?

@djdv
Copy link
Contributor

djdv commented Sep 19, 2019

Better, but not best. The string seems to be converted correctly, but we still need to see where/why this is failing with a seemingly correct argument.

--- FAIL: TestToUnix (0.00s)
    convert_test.go:43: naddr.Address() == \c:\foo\bar != /c:/foo/bar
--- FAIL: TestUnixSockets (0.00s)
    net_test.go:92: listen unix \C:\Users\DOMINI~1\AppData\Local\Temp\manettest809459775\listen.sock: bind: An invalid argument was supplied.
FAIL
exit status 1
FAIL    github.com/multiformats/go-multiaddr-net        0.086s

Edit: The other test is upset with the slash differences now though.

@djdv
Copy link
Contributor

djdv commented Sep 19, 2019

I'm wondering if the leading slash is being passed to something, or if that's just the target component of the multiaddr being returned in an error. \C:\ vs C:\ is going to cause problems.

We can either add Windows specific logic to detect and strip this leading slash, or potentially convert to UNC path syntax \\?\... if these are valid targets for UDS in the WINAPI.

@Stebalien
Copy link
Member Author

I'm wondering if the leading slash is being passed to something, or if that's just the target component of the multiaddr being returned in an error.

The leading slash is coming from the multiaddr. We start with /unix/c:/foobar, extract /c:/foobar, then convert the slashes to \c:\foobar (using filepath.FromSlash). We should probably just replace the leading \ with \\?\ on windows.

@djdv
Copy link
Contributor

djdv commented Sep 21, 2019

Attempting to upgrade the addr string to a UNC path did not seem to resolve this.
I'm wondering where these shortpaths (see: anno DOMINI~1) are coming from and if they're the actual source of the issue. Nope

--- FAIL: TestUnixSockets (0.00s)
    net_test.go:99: path:\\?\C:\Users\DOMINI~1\AppData\Local\Temp\manettest945165231\listen.sock
    net_test.go:100: listen unix \\\?\C:\Users\DOMINI~1\AppData\Local\Temp\manettest945165231\listen.sock: bind: An invalid argument was supplied.

@djdv
Copy link
Contributor

djdv commented Sep 21, 2019

@Stebalien I don't have push permissions for this brach
This appears to fix the underlying issue.

Regardless of the source argument, we were passing /... to the underlying Listener call.
addr:C:\path -> /C:\path

>git diff HEAD~
diff --git a/convert.go b/convert.go
index 1f936e6..1c006a9 100644
--- a/convert.go
+++ b/convert.go
@@ -4,6 +4,7 @@ import (
        "fmt"
        "net"
        "path/filepath"
+       "runtime"

        ma "github.com/multiformats/go-multiaddr"
 )
@@ -143,6 +144,10 @@ func DialArgs(m ma.Multiaddr) (string, string, error) {
                        case ma.P_UNIX:
                                network = "unix"
                                ip = c.Value()
+                               // strip leading multiaddr slash
+                               if runtime.GOOS == "windows" {
+                                       ip = ip[1:]
+                               }
                                return false
                        }
                case "ip4":

With that applied, the string tests are still unhappy

--- FAIL: TestToUnix (0.00s)
    convert_test.go:43: naddr.Address() == c:\foo\bar != /c:/foo/bar
FAIL
exit status 1
FAIL    github.com/multiformats/go-multiaddr-net        0.091s

Reverting d66032c
Presents:

go test
--- FAIL: TestFromUnix (0.00s)
    convert_test.go:19: failed to convert: /unix/c:/foo/bar != /unix/\c:\foo\bar
--- FAIL: TestToUnix (0.00s)
    convert_test.go:43: naddr.Address() == c:/foo/bar != /c:/foo/bar
FAIL
exit status 1
FAIL    github.com/multiformats/go-multiaddr-net        0.084s

Additonal context:
/ and \ are analogous to the root of the current working drive on Windows, so /C:/ is equivalent to C:/C:/

@Stebalien
Copy link
Member Author

@djdv I think I've fixed the tests. I've also added you to the org.

@djdv
Copy link
Contributor

djdv commented Sep 28, 2019

The compare string was being escaped, I used a backtick to preserve the literal \.
And also changed the drive letter to a capital 'C' to match api-native input.

Copy link
Contributor

@djdv djdv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing in CI and on Windows

@Stebalien Stebalien merged commit c9acf9f into master Sep 30, 2019
@Stebalien
Copy link
Member Author

Thanks!

1 similar comment
@Stebalien
Copy link
Member Author

Thanks!

@Stebalien Stebalien deleted the feat/test-unix branch September 30, 2019 14:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants