1
+ {-# LANGUAGE OverloadedLabels #-}
2
+
1
3
module Hydra.OptionsSpec where
2
4
3
5
import Hydra.Prelude
4
6
import Test.Hydra.Prelude
5
7
8
+ import Control.Lens ((.~) )
9
+ import Data.Generics.Labels ()
6
10
import Hydra.Cardano.Api (
7
11
ChainPoint (.. ),
8
12
NetworkId (.. ),
@@ -139,27 +143,21 @@ spec = parallel $
139
143
defaultRunOptions
140
144
{ chainConfig =
141
145
Direct
142
- defaultDirectChainConfig
143
- { networkId = Testnet (NetworkMagic 0 )
144
- }
146
+ (defaultDirectChainConfig & # networkId .~ Testnet (NetworkMagic 0 ))
145
147
}
146
148
[" --testnet-magic" , " -1" ] -- Word32 overflow expected
147
149
`shouldParse` Run
148
150
defaultRunOptions
149
151
{ chainConfig =
150
152
Direct
151
- defaultDirectChainConfig
152
- { networkId = Testnet (NetworkMagic 4294967295 )
153
- }
153
+ (defaultDirectChainConfig & # networkId .~ Testnet (NetworkMagic 4294967295 ))
154
154
}
155
155
[" --testnet-magic" , " 123" ]
156
156
`shouldParse` Run
157
157
defaultRunOptions
158
158
{ chainConfig =
159
159
Direct
160
- defaultDirectChainConfig
161
- { networkId = Testnet (NetworkMagic 123 )
162
- }
160
+ (defaultDirectChainConfig & # networkId .~ Testnet (NetworkMagic 123 ))
163
161
}
164
162
165
163
it " parses --mainnet option" $ do
@@ -168,9 +166,7 @@ spec = parallel $
168
166
defaultRunOptions
169
167
{ chainConfig =
170
168
Direct
171
- defaultDirectChainConfig
172
- { networkId = Mainnet
173
- }
169
+ (defaultDirectChainConfig & # networkId .~ Mainnet )
174
170
}
175
171
176
172
it " parses --contestation-period option as a number of seconds" $ do
@@ -184,18 +180,14 @@ spec = parallel $
184
180
defaultRunOptions
185
181
{ chainConfig =
186
182
Direct
187
- defaultDirectChainConfig
188
- { contestationPeriod = UnsafeContestationPeriod 1
189
- }
183
+ (defaultDirectChainConfig & # contestationPeriod .~ UnsafeContestationPeriod 1 )
190
184
}
191
185
[" --contestation-period" , " 300s" ]
192
186
`shouldParse` Run
193
187
defaultRunOptions
194
188
{ chainConfig =
195
189
Direct
196
- defaultDirectChainConfig
197
- { contestationPeriod = UnsafeContestationPeriod 300
198
- }
190
+ (defaultDirectChainConfig & # contestationPeriod .~ UnsafeContestationPeriod 300 )
199
191
}
200
192
it " parses --deposit-deadline option as a number of seconds" $ do
201
193
shouldNotParse [" --deposit-deadline" , " abc" ]
@@ -208,18 +200,14 @@ spec = parallel $
208
200
defaultRunOptions
209
201
{ chainConfig =
210
202
Direct
211
- defaultDirectChainConfig
212
- { depositDeadline = UnsafeDepositDeadline 1
213
- }
203
+ (defaultDirectChainConfig & # depositDeadline .~ UnsafeDepositDeadline 1 )
214
204
}
215
205
[" --deposit-deadline" , " 300s" ]
216
206
`shouldParse` Run
217
207
defaultRunOptions
218
208
{ chainConfig =
219
209
Direct
220
- defaultDirectChainConfig
221
- { depositDeadline = UnsafeDepositDeadline 300
222
- }
210
+ (defaultDirectChainConfig & # depositDeadline .~ UnsafeDepositDeadline 300 )
223
211
}
224
212
225
213
it " parses --mainnet flag" $ do
@@ -228,9 +216,7 @@ spec = parallel $
228
216
defaultRunOptions
229
217
{ chainConfig =
230
218
Direct
231
- defaultDirectChainConfig
232
- { networkId = Mainnet
233
- }
219
+ (defaultDirectChainConfig & # networkId .~ Mainnet )
234
220
}
235
221
236
222
it " parses --node-socket as a filepath" $
@@ -239,9 +225,7 @@ spec = parallel $
239
225
defaultRunOptions
240
226
{ chainConfig =
241
227
Direct
242
- defaultDirectChainConfig
243
- { nodeSocket = " foo.sock"
244
- }
228
+ (defaultDirectChainConfig & # nodeSocket .~ " foo.sock" )
245
229
}
246
230
247
231
it " parses --cardano-signing-key option as a filepath" $
@@ -250,9 +234,7 @@ spec = parallel $
250
234
defaultRunOptions
251
235
{ chainConfig =
252
236
Direct
253
- defaultDirectChainConfig
254
- { cardanoSigningKey = " ./alice-cardano.sk"
255
- }
237
+ (defaultDirectChainConfig & # cardanoSigningKey .~ " ./alice-cardano.sk" )
256
238
}
257
239
258
240
it " parses --cardano-verification-key option as a filepath" $
@@ -261,9 +243,7 @@ spec = parallel $
261
243
defaultRunOptions
262
244
{ chainConfig =
263
245
Direct
264
- defaultDirectChainConfig
265
- { cardanoVerificationKeys = [" ./alice-cardano.vk" ]
266
- }
246
+ (defaultDirectChainConfig & # cardanoVerificationKeys .~ [" ./alice-cardano.vk" ])
267
247
}
268
248
269
249
it " parses --ledger-protocol-parameters-file as a filepath" $
0 commit comments