@@ -17,9 +17,24 @@ module Test.Cardano.Db.Mock.Config (
17
17
fingerprintRoot ,
18
18
getDBSyncPGPass ,
19
19
getPoolLayer ,
20
+
21
+ -- * Configs
20
22
mkConfig ,
21
23
mkSyncNodeConfig ,
22
24
mkConfigDir ,
25
+ configPruneForceTxIn ,
26
+ configPrune ,
27
+ configConsume ,
28
+ configBootstrap ,
29
+ configPlutusDisable ,
30
+ configMultiAssetsDisable ,
31
+ configShelleyDisable ,
32
+ configRemoveJsonFromSchema ,
33
+ configRemoveJsonFromSchemaFalse ,
34
+ configLedgerIgnore ,
35
+ configMetadataEnable ,
36
+ configMetadataDisable ,
37
+ configMetadataKeys ,
23
38
mkFingerPrint ,
24
39
mkMutableDir ,
25
40
mkDBSyncEnv ,
@@ -51,14 +66,14 @@ import qualified Cardano.Db as DB
51
66
import Cardano.DbSync
52
67
import Cardano.DbSync.Config
53
68
import Cardano.DbSync.Config.Cardano
54
- import Cardano.DbSync.Config.Types ( SyncInsertOptions ( .. ), TxOutConfig ( .. ), UseTxOutAddress ( .. ))
69
+ import Cardano.DbSync.Config.Types
55
70
import Cardano.DbSync.Error (runOrThrowIO )
56
71
import Cardano.DbSync.Types (CardanoBlock , MetricSetters (.. ))
57
72
import Cardano.Mock.ChainSync.Server
58
73
import Cardano.Mock.Forging.Interpreter
59
74
import Cardano.Node.Protocol.Shelley (readLeaderCredentials )
60
75
import Cardano.Node.Types (ProtocolFilepaths (.. ))
61
- import Cardano.Prelude (ReaderT , panic , stderr , textShow )
76
+ import Cardano.Prelude (NonEmpty ( (:|) ), ReaderT , panic , stderr , textShow )
62
77
import Cardano.SMASH.Server.PoolDataLayer
63
78
import Control.Concurrent.Async (Async , async , cancel , poll )
64
79
import Control.Concurrent.STM (atomically )
@@ -118,7 +133,6 @@ data CommandLineArgs = CommandLineArgs
118
133
, claFullMode :: Bool
119
134
, claMigrateConsumed :: Bool
120
135
, claPruneTxOut :: Bool
121
- , claBootstrap :: Bool
122
136
}
123
137
124
138
data WithConfigArgs = WithConfigArgs
@@ -281,10 +295,65 @@ mkSyncNodeParams staticDir mutableDir CommandLineArgs {..} = do
281
295
, enpMaybeRollback = Nothing
282
296
}
283
297
298
+ ------------------------------------------------------------------------------
299
+ -- Custom Configs
300
+ ------------------------------------------------------------------------------
284
301
mkConfigFile :: FilePath -> FilePath -> ConfigFile
285
302
mkConfigFile staticDir cliConfigFilename =
286
303
ConfigFile $ staticDir </> cliConfigFilename
287
304
305
+ configPruneForceTxIn :: SyncNodeConfig -> SyncNodeConfig
306
+ configPruneForceTxIn cfg = do
307
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn True )}}
308
+
309
+ configPrune :: SyncNodeConfig -> SyncNodeConfig
310
+ configPrune cfg = do
311
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn False )}}
312
+
313
+ configConsume :: SyncNodeConfig -> SyncNodeConfig
314
+ configConsume cfg = do
315
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutConsumed (ForceTxIn False )}}
316
+
317
+ configBootstrap :: SyncNodeConfig -> SyncNodeConfig
318
+ configBootstrap cfg = do
319
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutBootstrap (ForceTxIn False )}}
320
+
321
+ configPlutusDisable :: SyncNodeConfig -> SyncNodeConfig
322
+ configPlutusDisable cfg = do
323
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioPlutus = PlutusDisable }}
324
+
325
+ configMultiAssetsDisable :: SyncNodeConfig -> SyncNodeConfig
326
+ configMultiAssetsDisable cfg = do
327
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMultiAsset = MultiAssetDisable }}
328
+
329
+ configShelleyDisable :: SyncNodeConfig -> SyncNodeConfig
330
+ configShelleyDisable cfg = do
331
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioShelley = ShelleyDisable }}
332
+
333
+ configRemoveJsonFromSchema :: SyncNodeConfig -> SyncNodeConfig
334
+ configRemoveJsonFromSchema cfg = do
335
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig True }}
336
+
337
+ configRemoveJsonFromSchemaFalse :: SyncNodeConfig -> SyncNodeConfig
338
+ configRemoveJsonFromSchemaFalse cfg = do
339
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False }}
340
+
341
+ configLedgerIgnore :: SyncNodeConfig -> SyncNodeConfig
342
+ configLedgerIgnore cfg = do
343
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioLedger = LedgerIgnore }}
344
+
345
+ configMetadataEnable :: SyncNodeConfig -> SyncNodeConfig
346
+ configMetadataEnable cfg = do
347
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataEnable }}
348
+
349
+ configMetadataDisable :: SyncNodeConfig -> SyncNodeConfig
350
+ configMetadataDisable cfg = do
351
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataDisable }}
352
+
353
+ configMetadataKeys :: SyncNodeConfig -> SyncNodeConfig
354
+ configMetadataKeys cfg = do
355
+ cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataKeys $ 1 :| [] }}
356
+
288
357
initCommandLineArgs :: CommandLineArgs
289
358
initCommandLineArgs =
290
359
CommandLineArgs
@@ -303,7 +372,6 @@ initCommandLineArgs =
303
372
, claFullMode = True
304
373
, claMigrateConsumed = False
305
374
, claPruneTxOut = False
306
- , claBootstrap = False
307
375
}
308
376
309
377
emptyMetricsSetters :: MetricSetters
@@ -379,7 +447,7 @@ withFullConfigAndLogs =
379
447
withCustomConfig ::
380
448
CommandLineArgs ->
381
449
-- | custom SyncNodeConfig
382
- Maybe SyncNodeConfig ->
450
+ Maybe ( SyncNodeConfig -> SyncNodeConfig ) ->
383
451
-- | config filepath
384
452
FilePath ->
385
453
-- | test label
@@ -400,7 +468,7 @@ withCustomConfig =
400
468
withCustomConfigAndDropDB ::
401
469
CommandLineArgs ->
402
470
-- | custom SyncNodeConfig
403
- Maybe SyncNodeConfig ->
471
+ Maybe ( SyncNodeConfig -> SyncNodeConfig ) ->
404
472
-- | config filepath
405
473
FilePath ->
406
474
-- | test label
@@ -422,7 +490,7 @@ withCustomConfigAndDropDB =
422
490
withCustomConfigAndLogs ::
423
491
CommandLineArgs ->
424
492
-- | custom SyncNodeConfig
425
- Maybe SyncNodeConfig ->
493
+ Maybe ( SyncNodeConfig -> SyncNodeConfig ) ->
426
494
-- | config filepath
427
495
FilePath ->
428
496
-- | test label
@@ -443,7 +511,7 @@ withCustomConfigAndLogs =
443
511
withCustomConfigAndLogsAndDropDB ::
444
512
CommandLineArgs ->
445
513
-- | custom SyncNodeConfig
446
- Maybe SyncNodeConfig ->
514
+ Maybe ( SyncNodeConfig -> SyncNodeConfig ) ->
447
515
-- | config filepath
448
516
FilePath ->
449
517
-- | test label
@@ -465,7 +533,7 @@ withFullConfig' ::
465
533
WithConfigArgs ->
466
534
CommandLineArgs ->
467
535
-- | custom SyncNodeConfig
468
- Maybe SyncNodeConfig ->
536
+ Maybe ( SyncNodeConfig -> SyncNodeConfig ) ->
469
537
-- | config filepath
470
538
FilePath ->
471
539
-- | test label
@@ -479,7 +547,9 @@ withFullConfig' WithConfigArgs {..} cmdLineArgs mSyncNodeConfig configFilePath t
479
547
-- check if custom syncNodeConfigs have been passed or not
480
548
syncNodeConfig <-
481
549
case mSyncNodeConfig of
482
- Just snc -> pure snc
550
+ Just updateFn -> do
551
+ initConfigFile <- mkSyncNodeConfig configFilePath cmdLineArgs
552
+ pure $ updateFn initConfigFile
483
553
Nothing -> mkSyncNodeConfig configFilePath cmdLineArgs
484
554
485
555
cfg <- mkConfig configFilePath mutableDir cmdLineArgs syncNodeConfig
0 commit comments