Skip to content

Commit

Permalink
Api.ServerSpec: Let tests pass on both Wine and Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Nov 13, 2019
1 parent e991a1c commit 8937f69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ ioToListenError hostPreference portOpt e
| isDoesNotExistError e =
Just (ListenErrorHostDoesNotExist hostPreference)
-- Bad hostname (bind: WSAEOPNOTSUPP) -- Windows
| isUserError e && hasDescription "10045" =
| isUserError e && (hasDescription "11001" || hasDescription "10045") =
Just (ListenErrorHostDoesNotExist hostPreference)
-- Address is valid, but can't be used for listening -- Linux
| show (ioeGetErrorType e) == "invalid argument" =
Expand All @@ -389,7 +389,8 @@ ioToListenError hostPreference portOpt e
| show (ioeGetErrorType e) == "unsupported operation" =
Just (ListenErrorInvalidAddress hostPreference)
-- Address is valid, but can't be used for listening -- Windows
| isOtherError e && hasDescription "WSAEINVAL" =
| isOtherError e &&
(hasDescription "WSAEINVAL" || hasDescription "WSAEADDRNOTAVAIL") =
Just (ListenErrorInvalidAddress hostPreference)
-- Listening on an unavailable or privileged port -- Windows
| isOtherError e && hasDescription "WSAEACCESS" =
Expand Down
1 change: 1 addition & 0 deletions lib/core/test/unit/Cardano/Wallet/Api/ServerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ spec = describe "API Server" $ do
res `shouldBe` Left ListenErrorOperationNotPermitted

it "handles port in use" $ do
skipOnWindows "Windows permits listening on same port multiple times"
withListeningSocket "127.0.0.1" ListenOnRandomPort $ \case
Right (port, _) ->
withListeningSocket "127.0.0.1" (ListenOnPort port) $ \res ->
Expand Down

0 comments on commit 8937f69

Please sign in to comment.