Skip to content

Commit 4ecf4fd

Browse files
committed
Reduce length of temporary socket filenames
1 parent 2e8a54a commit 4ecf4fd

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

cardano-api/cardano-api.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ test-suite cardano-api-test
333333
containers,
334334
data-default,
335335
directory,
336-
filepath,
337336
hedgehog >=1.1,
338337
hedgehog-extras,
339338
hedgehog-quickcheck,
@@ -366,7 +365,7 @@ test-suite cardano-api-test
366365
Test.Cardano.Api.Genesis
367366
Test.Cardano.Api.GovAnchorValidation
368367
Test.Cardano.Api.IO
369-
Test.Cardano.Api.IPCMock
368+
Test.Cardano.Api.IPC
370369
Test.Cardano.Api.Json
371370
Test.Cardano.Api.KeysByron
372371
Test.Cardano.Api.Ledger

cardano-api/test/cardano-api-test/Test/Cardano/Api/IPCMock.hs renamed to cardano-api/test/cardano-api-test/Test/Cardano/Api/IPC.hs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{-# LANGUAGE NumericUnderscores #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
66

7-
module Test.Cardano.Api.IPCMock
7+
module Test.Cardano.Api.IPC
88
( tests
99
)
1010
where
@@ -27,7 +27,6 @@ import Lens.Micro ((&))
2727
import Network.Socket
2828
import Network.Socket.ByteString (sendAll)
2929
import System.Directory (removeFile)
30-
import System.FilePath ((</>))
3130

3231
import Test.Cardano.Ledger.Common (HasCallStack, when)
3332

@@ -51,7 +50,8 @@ prop_mockInteractionWithNode =
5150
-- We make a query to obtain the current era
5251
eEra <-
5352
mockNode
54-
(work </> "ms1")
53+
work
54+
"ms1"
5555
"test/cardano-api-test/files/input/ipc-mock/server-client-1.raw"
5656
( \socketFile ->
5757
H.evalIO $
@@ -84,7 +84,8 @@ prop_mockInteractionWithNode =
8484
-- We make a query to obtain the UTxOs for the given address
8585
eUtxo <-
8686
mockNode
87-
(work </> "ms2")
87+
work
88+
"ms2"
8889
"test/cardano-api-test/files/input/ipc-mock/server-client-2.raw"
8990
( \socketFile ->
9091
H.evalIO $
@@ -172,7 +173,8 @@ prop_mockInteractionWithNode =
172173

173174
result <-
174175
mockNode
175-
(work </> "ms3")
176+
work
177+
"ms3"
176178
"test/cardano-api-test/files/input/ipc-mock/server-client-3.raw"
177179
( \socketFile ->
178180
H.evalIO $ Api.submitTxToNodeLocal (connectionInfo (File socketFile)) (Api.TxInMode sbe signedTx)
@@ -185,7 +187,7 @@ prop_mockInteractionWithNode =
185187
tests :: TestTree
186188
tests =
187189
testGroup
188-
"Test.Cardano.Api.IPCMock"
190+
"Test.Cardano.Api.IPC"
189191
[ testProperty "Test mock interation with node" prop_mockInteractionWithNode
190192
]
191193

@@ -209,17 +211,18 @@ mockNode
209211
=> FilePath
210212
-- ^ Directory to create the socket file in.
211213
-> FilePath
214+
-- ^ Name of the unix socket file to create
215+
-> FilePath
212216
-- ^ File to read the raw replay data from.
213217
-> (FilePath -> m a)
214218
-- ^ Action to run while the server is being mocked.
215219
-> m a
216-
mockNode work rawReplayData action = do
220+
mockNode work fileName rawReplayData action = do
217221
actionFinished :: MVar () <- H.evalIO newEmptyMVar
218222
bracket
219223
-- Server set-up (resource acquisition)
220224
( do
221-
_ <- H.createDirectoryIfMissing work
222-
socketFile <- H.noteTempFile work "mock-node.socket"
225+
socketFile <- H.noteTempFile work fileName
223226
sock <- H.evalIO $ do
224227
sock <- socket AF_UNIX Stream defaultProtocol
225228
bind sock (SockAddrUnix socketFile)

cardano-api/test/cardano-api-test/cardano-api-test.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Test.Cardano.Api.Experimental qualified
1717
import Test.Cardano.Api.Genesis qualified
1818
import Test.Cardano.Api.GovAnchorValidation qualified
1919
import Test.Cardano.Api.IO qualified
20-
import Test.Cardano.Api.IPCMock qualified
20+
import Test.Cardano.Api.IPC qualified
2121
import Test.Cardano.Api.Json qualified
2222
import Test.Cardano.Api.KeysByron qualified
2323
import Test.Cardano.Api.Ledger qualified
@@ -54,7 +54,7 @@ tests =
5454
, Test.Cardano.Api.Experimental.tests
5555
, Test.Cardano.Api.Genesis.tests
5656
, Test.Cardano.Api.IO.tests
57-
, Test.Cardano.Api.IPCMock.tests
57+
, Test.Cardano.Api.IPC.tests
5858
, Test.Cardano.Api.Json.tests
5959
, Test.Cardano.Api.KeysByron.tests
6060
, Test.Cardano.Api.Ledger.tests

0 commit comments

Comments
 (0)