5
5
module Test.Cardano.Db.Mock.Config (
6
6
Config (.. ),
7
7
DBSyncEnv (.. ),
8
+ TxOutParam (.. ),
8
9
babbageConfigDir ,
9
10
alonzoConfigDir ,
10
11
emptyMetricsSetters ,
@@ -29,6 +30,7 @@ module Test.Cardano.Db.Mock.Config (
29
30
startDBSync ,
30
31
withDBSyncEnv ,
31
32
withFullConfig ,
33
+ withTxOutParamConfig ,
32
34
withFullConfig' ,
33
35
) where
34
36
@@ -89,6 +91,12 @@ data DBSyncEnv = DBSyncEnv
89
91
, dbSyncThreadVar :: TMVar (Async () )
90
92
}
91
93
94
+ -- used for testing of tx out pruning feature
95
+ data TxOutParam = TxOutParam
96
+ { paramMigrateConsumed :: Bool ,
97
+ paramPruneTxOut :: Bool
98
+ }
99
+
92
100
babbageConfigDir :: FilePath
93
101
babbageConfigDir = " config"
94
102
@@ -195,14 +203,14 @@ setupTestsDir dir = do
195
203
0
196
204
Nothing
197
205
198
- mkConfig :: FilePath -> FilePath -> IO Config
199
- mkConfig staticDir mutableDir = do
206
+ mkConfig :: FilePath -> FilePath -> Maybe TxOutParam -> IO Config
207
+ mkConfig staticDir mutableDir mTxOutParam = do
200
208
config <- readSyncNodeConfig $ ConfigFile (staticDir </> " test-db-sync-config.json" )
201
209
genCfg <- either (error . Text. unpack . renderSyncNodeError) id <$> runExceptT (readCardanoGenesisConfig config)
202
210
let pInfoDbSync = mkProtocolInfoCardano genCfg []
203
211
creds <- mkShelleyCredentials $ staticDir </> " pools" </> " bulk1.creds"
204
212
let pInfoForger = mkProtocolInfoCardano genCfg creds
205
- syncPars <- mkSyncNodeParams staticDir mutableDir
213
+ syncPars <- mkSyncNodeParams staticDir mutableDir mTxOutParam
206
214
pure $ Config (Consensus. pInfoConfig pInfoDbSync) pInfoDbSync pInfoForger syncPars
207
215
208
216
mkShelleyCredentials :: FilePath -> IO [ShelleyLeaderCredentials StandardCrypto ]
@@ -220,8 +228,8 @@ mkShelleyCredentials bulkFile = do
220
228
}
221
229
222
230
-- | staticDir can be shared by tests running in parallel. mutableDir not.
223
- mkSyncNodeParams :: FilePath -> FilePath -> IO SyncNodeParams
224
- mkSyncNodeParams staticDir mutableDir = do
231
+ mkSyncNodeParams :: FilePath -> FilePath -> Maybe TxOutParam -> IO SyncNodeParams
232
+ mkSyncNodeParams staticDir mutableDir mTxOutParam = do
225
233
pgconfig <- orDie Db. renderPGPassError $ newExceptT Db. readPGPassDefault
226
234
pure $
227
235
SyncNodeParams
@@ -242,8 +250,8 @@ mkSyncNodeParams staticDir mutableDir = do
242
250
, enpHasOfflineData = True
243
251
, enpTurboMode = False
244
252
, enpFullMode = True
245
- , enpMigrateConsumed = False
246
- , enpPruneTxOut = False
253
+ , enpMigrateConsumed = maybe False paramMigrateConsumed mTxOutParam
254
+ , enpPruneTxOut = maybe False paramPruneTxOut mTxOutParam
247
255
, enpSnEveryFollowing = 35
248
256
, enpSnEveryLagging = 35
249
257
, enpMaybeRollback = Nothing
@@ -265,19 +273,30 @@ withFullConfig ::
265
273
IOManager ->
266
274
[(Text , Text )] ->
267
275
IO a
268
- withFullConfig = withFullConfig' True
276
+ withFullConfig = withFullConfig' True Nothing
277
+
278
+ withTxOutParamConfig ::
279
+ TxOutParam ->
280
+ FilePath ->
281
+ FilePath ->
282
+ (Interpreter -> ServerHandle IO CardanoBlock -> DBSyncEnv -> IO a ) ->
283
+ IOManager ->
284
+ [(Text , Text )] ->
285
+ IO a
286
+ withTxOutParamConfig txOutParam = withFullConfig' True (Just txOutParam)
269
287
270
288
withFullConfig' ::
271
289
Bool ->
290
+ Maybe TxOutParam ->
272
291
FilePath ->
273
292
FilePath ->
274
293
(Interpreter -> ServerHandle IO CardanoBlock -> DBSyncEnv -> IO a ) ->
275
294
IOManager ->
276
295
[(Text , Text )] ->
277
296
IO a
278
- withFullConfig' hasFingerprint config testLabel action iom migr = do
297
+ withFullConfig' hasFingerprint mTxOutParam config testLabel action iom migr = do
279
298
recreateDir mutableDir
280
- cfg <- mkConfig configDir mutableDir
299
+ cfg <- mkConfig configDir mutableDir mTxOutParam
281
300
fingerFile <- if hasFingerprint then Just <$> prepareFingerprintFile testLabel else pure Nothing
282
301
let dbsyncParams = syncNodeParams cfg
283
302
-- Set to True to disable logging, False to enable it.
0 commit comments