7
7
8
8
module Test.Cardano.Db.Mock.Unit.Babbage.Config.MigrateConsumedPruneTxOut (
9
9
basicPrune ,
10
+ basicPruneWithAddress ,
10
11
pruneWithSimpleRollback ,
12
+ pruneWithSimpleRollbackWithAddress ,
11
13
pruneWithFullTxRollback ,
14
+ pruneWithFullTxRollbackWithAddress ,
12
15
pruningShouldKeepSomeTx ,
16
+ pruningShouldKeepSomeTxWithAddress ,
13
17
pruneAndRollBackOneBlock ,
18
+ pruneAndRollBackOneBlockWithAddress ,
14
19
noPruneAndRollBack ,
20
+ noPruneAndRollBackWithAddress ,
15
21
pruneSameBlock ,
22
+ pruneSameBlockWithAddress ,
16
23
noPruneSameBlock ,
24
+ noPruneSameBlockWithAddress ,
17
25
migrateAndPruneRestart ,
26
+ migrateAndPruneRestartWithAddress ,
18
27
pruneRestartMissingFlag ,
28
+ pruneRestartMissingFlagWithAddress ,
19
29
bootstrapRestartMissingFlag ,
30
+ bootstrapRestartMissingFlagWithAddress ,
20
31
) where
21
32
22
33
import Cardano.Db (TxOutTableType (.. ))
@@ -41,7 +52,7 @@ import Test.Cardano.Db.Mock.Config (
41
52
startDBSync ,
42
53
stopDBSync ,
43
54
txOutTableTypeFromConfig ,
44
- withCustomConfig ,
55
+ withCustomConfigAndDropDB ,
45
56
)
46
57
import Test.Cardano.Db.Mock.Examples (mockBlock0 , mockBlock1 )
47
58
import Test.Cardano.Db.Mock.UnifiedApi (
@@ -59,8 +70,14 @@ import Test.Tasty.HUnit (Assertion)
59
70
-- Tests
60
71
------------------------------------------------------------------------------
61
72
basicPrune :: IOManager -> [(Text , Text )] -> Assertion
62
- basicPrune = do
63
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
73
+ basicPrune = peformBasicPrune False
74
+
75
+ basicPruneWithAddress :: IOManager -> [(Text , Text )] -> Assertion
76
+ basicPruneWithAddress = peformBasicPrune True
77
+
78
+ peformBasicPrune :: Bool -> IOManager -> [(Text , Text )] -> Assertion
79
+ peformBasicPrune useTxOutAddress = do
80
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
64
81
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
65
82
startDBSync dbSyncEnv
66
83
-- add 50 block
@@ -84,8 +101,14 @@ basicPrune = do
84
101
testLabel = " configPrune"
85
102
86
103
pruneWithSimpleRollback :: IOManager -> [(Text , Text )] -> Assertion
87
- pruneWithSimpleRollback = do
88
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
104
+ pruneWithSimpleRollback = peformPruneWithSimpleRollback False
105
+
106
+ pruneWithSimpleRollbackWithAddress :: IOManager -> [(Text , Text )] -> Assertion
107
+ pruneWithSimpleRollbackWithAddress = peformPruneWithSimpleRollback True
108
+
109
+ peformPruneWithSimpleRollback :: Bool -> IOManager -> [(Text , Text )] -> Assertion
110
+ peformPruneWithSimpleRollback useTxOutAddress = do
111
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
89
112
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
90
113
blk0 <- forgeNext interpreter mockBlock0
91
114
blk1 <- forgeNext interpreter mockBlock1
@@ -110,8 +133,14 @@ pruneWithSimpleRollback = do
110
133
testLabel = " configPruneSimpleRollback"
111
134
112
135
pruneWithFullTxRollback :: IOManager -> [(Text , Text )] -> Assertion
113
- pruneWithFullTxRollback = do
114
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
136
+ pruneWithFullTxRollback = performPruneWithFullTxRollback False
137
+
138
+ pruneWithFullTxRollbackWithAddress :: IOManager -> [(Text , Text )] -> Assertion
139
+ pruneWithFullTxRollbackWithAddress = performPruneWithFullTxRollback True
140
+
141
+ performPruneWithFullTxRollback :: Bool -> IOManager -> [(Text , Text )] -> Assertion
142
+ performPruneWithFullTxRollback useTxOutAddress = do
143
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
115
144
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
116
145
startDBSync dbSyncEnv
117
146
blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer []
@@ -140,8 +169,14 @@ pruneWithFullTxRollback = do
140
169
-- The tx in the last, 2 x securityParam worth of blocks should not be pruned.
141
170
-- In these tests, 2 x securityParam = 20 blocks.
142
171
pruningShouldKeepSomeTx :: IOManager -> [(Text , Text )] -> Assertion
143
- pruningShouldKeepSomeTx = do
144
- withCustomConfig cmdLineArgs (Just configPrune) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
172
+ pruningShouldKeepSomeTx = performPruningShouldKeepSomeTx False
173
+
174
+ pruningShouldKeepSomeTxWithAddress :: IOManager -> [(Text , Text )] -> Assertion
175
+ pruningShouldKeepSomeTxWithAddress = performPruningShouldKeepSomeTx True
176
+
177
+ performPruningShouldKeepSomeTx :: Bool -> IOManager -> [(Text , Text )] -> Assertion
178
+ performPruningShouldKeepSomeTx useTxOutAddress = do
179
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPrune useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
145
180
startDBSync dbSyncEnv
146
181
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
147
182
b1 <- forgeAndSubmitBlocks interpreter mockServer 80
@@ -164,8 +199,14 @@ pruningShouldKeepSomeTx = do
164
199
165
200
-- prune with rollback
166
201
pruneAndRollBackOneBlock :: IOManager -> [(Text , Text )] -> Assertion
167
- pruneAndRollBackOneBlock = do
168
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
202
+ pruneAndRollBackOneBlock = performPruneAndRollBackOneBlock False
203
+
204
+ pruneAndRollBackOneBlockWithAddress :: IOManager -> [(Text , Text )] -> Assertion
205
+ pruneAndRollBackOneBlockWithAddress = performPruneAndRollBackOneBlock True
206
+
207
+ performPruneAndRollBackOneBlock :: Bool -> IOManager -> [(Text , Text )] -> Assertion
208
+ performPruneAndRollBackOneBlock useTxOutAddress = do
209
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
169
210
startDBSync dbSyncEnv
170
211
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
171
212
void $ forgeAndSubmitBlocks interpreter mockServer 98
@@ -197,8 +238,14 @@ pruneAndRollBackOneBlock = do
197
238
198
239
-- consume with rollback
199
240
noPruneAndRollBack :: IOManager -> [(Text , Text )] -> Assertion
200
- noPruneAndRollBack = do
201
- withCustomConfig cmdLineArgs (Just configConsume) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
241
+ noPruneAndRollBack = performNoPruneAndRollBack False
242
+
243
+ noPruneAndRollBackWithAddress :: IOManager -> [(Text , Text )] -> Assertion
244
+ noPruneAndRollBackWithAddress = performNoPruneAndRollBack True
245
+
246
+ performNoPruneAndRollBack :: Bool -> IOManager -> [(Text , Text )] -> Assertion
247
+ performNoPruneAndRollBack useTxOutAddress = do
248
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
202
249
startDBSync dbSyncEnv
203
250
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
204
251
void $ forgeAndSubmitBlocks interpreter mockServer 98
@@ -229,8 +276,14 @@ noPruneAndRollBack = do
229
276
testLabel = " configPruneAndRollBack"
230
277
231
278
pruneSameBlock :: IOManager -> [(Text , Text )] -> Assertion
232
- pruneSameBlock =
233
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
279
+ pruneSameBlock = performPruneSameBlock False
280
+
281
+ pruneSameBlockWithAddress :: IOManager -> [(Text , Text )] -> Assertion
282
+ pruneSameBlockWithAddress = performPruneSameBlock True
283
+
284
+ performPruneSameBlock :: Bool -> IOManager -> [(Text , Text )] -> Assertion
285
+ performPruneSameBlock useTxOutAddress =
286
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
234
287
startDBSync dbSyncEnv
235
288
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
236
289
void $ forgeAndSubmitBlocks interpreter mockServer 76
@@ -255,8 +308,14 @@ pruneSameBlock =
255
308
testLabel = " configPruneSameBlock"
256
309
257
310
noPruneSameBlock :: IOManager -> [(Text , Text )] -> Assertion
258
- noPruneSameBlock =
259
- withCustomConfig cmdLineArgs (Just configConsume) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
311
+ noPruneSameBlock = performNoPruneSameBlock False
312
+
313
+ noPruneSameBlockWithAddress :: IOManager -> [(Text , Text )] -> Assertion
314
+ noPruneSameBlockWithAddress = performNoPruneSameBlock True
315
+
316
+ performNoPruneSameBlock :: Bool -> IOManager -> [(Text , Text )] -> Assertion
317
+ performNoPruneSameBlock useTxOutAddress =
318
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
260
319
startDBSync dbSyncEnv
261
320
let txOutTableType = txOutTableTypeFromConfig dbSyncEnv
262
321
void $ forgeAndSubmitBlocks interpreter mockServer 96
@@ -278,8 +337,14 @@ noPruneSameBlock =
278
337
testLabel = " configNoPruneSameBlock"
279
338
280
339
migrateAndPruneRestart :: IOManager -> [(Text , Text )] -> Assertion
281
- migrateAndPruneRestart = do
282
- withCustomConfig cmdLineArgs (Just configConsume) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
340
+ migrateAndPruneRestart = performMigrateAndPruneRestart False
341
+
342
+ migrateAndPruneRestartWithAddress :: IOManager -> [(Text , Text )] -> Assertion
343
+ migrateAndPruneRestartWithAddress = performMigrateAndPruneRestart True
344
+
345
+ performMigrateAndPruneRestart :: Bool -> IOManager -> [(Text , Text )] -> Assertion
346
+ performMigrateAndPruneRestart useTxOutAddress = do
347
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
283
348
startDBSync dbSyncEnv
284
349
void $ forgeAndSubmitBlocks interpreter mockServer 50
285
350
assertBlockNoBackoff dbSyncEnv 50
@@ -297,8 +362,14 @@ migrateAndPruneRestart = do
297
362
testLabel = " configMigrateAndPruneRestart"
298
363
299
364
pruneRestartMissingFlag :: IOManager -> [(Text , Text )] -> Assertion
300
- pruneRestartMissingFlag = do
301
- withCustomConfig cmdLineArgs (Just configPruneForceTxIn) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
365
+ pruneRestartMissingFlag = performPruneRestartMissingFlag False
366
+
367
+ pruneRestartMissingFlagWithAddress :: IOManager -> [(Text , Text )] -> Assertion
368
+ pruneRestartMissingFlagWithAddress = performPruneRestartMissingFlag True
369
+
370
+ performPruneRestartMissingFlag :: Bool -> IOManager -> [(Text , Text )] -> Assertion
371
+ performPruneRestartMissingFlag useTxOutAddress = do
372
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
302
373
startDBSync dbSyncEnv
303
374
void $ forgeAndSubmitBlocks interpreter mockServer 50
304
375
assertBlockNoBackoff dbSyncEnv 50
@@ -316,8 +387,14 @@ pruneRestartMissingFlag = do
316
387
testLabel = " configPruneRestartMissingFlag"
317
388
318
389
bootstrapRestartMissingFlag :: IOManager -> [(Text , Text )] -> Assertion
319
- bootstrapRestartMissingFlag = do
320
- withCustomConfig cmdLineArgs (Just configBootstrap) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
390
+ bootstrapRestartMissingFlag = performBootstrapRestartMissingFlag False
391
+
392
+ bootstrapRestartMissingFlagWithAddress :: IOManager -> [(Text , Text )] -> Assertion
393
+ bootstrapRestartMissingFlagWithAddress = performBootstrapRestartMissingFlag True
394
+
395
+ performBootstrapRestartMissingFlag :: Bool -> IOManager -> [(Text , Text )] -> Assertion
396
+ performBootstrapRestartMissingFlag useTxOutAddress = do
397
+ withCustomConfigAndDropDB cmdLineArgs (Just $ configBootstrap useTxOutAddress) babbageConfigDir testLabel $ \ interpreter mockServer dbSyncEnv -> do
321
398
startDBSync dbSyncEnv
322
399
void $ forgeAndSubmitBlocks interpreter mockServer 50
323
400
assertBlockNoBackoff dbSyncEnv 50
0 commit comments