Skip to content

Commit 4a913e0

Browse files
committed
rename Extended to EpochDisabled & EpochAndCacheEnabled
1 parent e277843 commit 4a913e0

File tree

15 files changed

+102
-20
lines changed

15 files changed

+102
-20
lines changed

cardano-chain-gen/cardano-chain-gen.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ test-suite cardano-chain-gen
165165
Test.Cardano.Db.Mock.Unit.Alonzo.Stake
166166
Test.Cardano.Db.Mock.Unit.Alonzo.Tx
167167
Test.Cardano.Db.Mock.Unit.Babbage
168-
Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.MigrateConsumedPruneTxOut
169168
Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.ConfigFile
169+
Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.EpochDisabled
170+
Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.MigrateConsumedPruneTxOut
170171
Test.Cardano.Db.Mock.Unit.Babbage.InlineAndReference
171172
Test.Cardano.Db.Mock.Unit.Babbage.Other
172173
Test.Cardano.Db.Mock.Unit.Babbage.Plutus

cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ data TxOutParam = TxOutParam
103103

104104
data CommandLineArgs = CommandLineArgs
105105
{ claHasConfigFile :: Bool
106-
, claExtended :: Bool
106+
, claEpochDisabled :: Bool
107107
, claHasCache :: Bool
108108
, claShouldUseLedger :: Bool
109109
, claSkipFix :: Bool
@@ -260,7 +260,7 @@ mkSyncNodeParams staticDir mutableDir CommandLineArgs{..} = do
260260
, enpMaybeLedgerStateDir = Just $ LedgerStateDir $ mutableDir </> "ledger-states"
261261
, enpMigrationDir = MigrationDir "../schema"
262262
, enpPGPassSource = Db.PGPassCached pgconfig
263-
, enpExtended = claExtended
263+
, enpEpochDisabled = claEpochDisabled
264264
, enpHasCache = claHasCache
265265
, enpShouldUseLedger = claShouldUseLedger
266266
, enpSkipFix = claSkipFix
@@ -283,7 +283,7 @@ initCommandLineArgs :: CommandLineArgs
283283
initCommandLineArgs =
284284
CommandLineArgs
285285
{ claHasConfigFile = True
286-
, claExtended = True
286+
, claEpochDisabled = True
287287
, claHasCache = True
288288
, claShouldUseLedger = True
289289
, claSkipFix = True
@@ -327,6 +327,7 @@ withCustomConfig ::
327327
IO a
328328
withCustomConfig = withFullConfig' True False
329329

330+
-- when wanting to check for a failure in a test for some reason logging has to be enabled
330331
withCustomConfigAndLogs ::
331332
CommandLineArgs ->
332333
FilePath ->

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Test.Tasty.HUnit (Assertion, testCase)
1313
import Test.Tasty.ExpectedFailure (expectFail)
1414

1515
import qualified Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.MigrateConsumedPruneTxOut as MigrateConsumedPruneTxOut
16+
import qualified Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.EpochDisabled as EpochDisabled
1617
import qualified Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.ConfigFile as ConfigFile
1718
import qualified Test.Cardano.Db.Mock.Unit.Babbage.InlineAndReference as BabInlineRef
1819
import qualified Test.Cardano.Db.Mock.Unit.Babbage.Other as BabOther
@@ -52,7 +53,11 @@ unitTests iom knownMigrations =
5253
]
5354
, testGroup
5455
"ConfigFile"
55-
[ expectFail $ test "fails if incorrect config file" ConfigFile.checkConfigFileArg
56+
[ expectFail $ test "fails if incorrect or no config file given" ConfigFile.checkConfigFileArg ]
57+
, testGroup
58+
"EpochDisabled"
59+
[ test "Epoch doesn't update when disabled" EpochDisabled.checkEpochDisabledArg
60+
, test "Epoch updates when enabled" EpochDisabled.checkEpochEnabled
5661
]
5762
]
5863
, testGroup

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/CommandLineArg/ConfigFile.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mkCommandLineArgs :: Bool -> CommandLineArgs
1212
mkCommandLineArgs hasConfigFile =
1313
CommandLineArgs
1414
{ claHasConfigFile = hasConfigFile
15-
, claExtended = True
15+
, claEpochDisabled = True
1616
, claHasCache = True
1717
, claShouldUseLedger = True
1818
, claSkipFix = True
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module Test.Cardano.Db.Mock.Unit.Babbage.CommandLineArg.EpochDisabled (
2+
checkEpochDisabledArg,
3+
checkEpochEnabled,
4+
)
5+
where
6+
7+
import qualified Cardano.Db as DB
8+
import Cardano.Mock.ChainSync.Server (IOManager)
9+
import qualified Cardano.Mock.Forging.Tx.Babbage as Babbage
10+
import Cardano.Mock.Forging.Types (UTxOIndex (..))
11+
import Control.Monad (void)
12+
import Data.Text (Text)
13+
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), babbageConfigDir, startDBSync, withCustomConfig)
14+
import Test.Cardano.Db.Mock.UnifiedApi (forgeAndSubmitBlocks, withBabbageFindLeaderAndSubmitTx)
15+
import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff, assertEqQuery)
16+
import Test.Tasty.HUnit (Assertion)
17+
18+
mkCommandLineArgs :: Bool -> CommandLineArgs
19+
mkCommandLineArgs epochDisabled =
20+
CommandLineArgs
21+
{ claHasConfigFile = True
22+
, claEpochDisabled = epochDisabled
23+
, claHasCache = True
24+
, claShouldUseLedger = True
25+
, claSkipFix = True
26+
, claOnlyFix = False
27+
, claForceIndexes = False
28+
, claHasMultiAssets = True
29+
, claHasMetadata = True
30+
, claHasPlutusExtra = True
31+
, claHasOfflineData = True
32+
, claTurboMode = False
33+
, claFullMode = True
34+
, claMigrateConsumed = True
35+
, claPruneTxOut = True
36+
}
37+
38+
-- this test fails as incorrect configuration file given
39+
checkEpochDisabledArg :: IOManager -> [(Text, Text)] -> Assertion
40+
checkEpochDisabledArg =
41+
withCustomConfig (mkCommandLineArgs True) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do
42+
startDBSync dbSyncEnv
43+
b1 <- forgeAndSubmitBlocks interpreter mockServer 50
44+
-- add 2 blocks with tx
45+
void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000
46+
void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000
47+
b2 <- forgeAndSubmitBlocks interpreter mockServer 60
48+
49+
assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2)
50+
assertEqQuery dbSyncEnv DB.queryEpochCount 0 "new epoch didn't prune tx_out column that are null"
51+
where
52+
testLabel = "CLAcheckEpochDisabledArg "
53+
54+
checkEpochEnabled :: IOManager -> [(Text, Text)] -> Assertion
55+
checkEpochEnabled =
56+
withCustomConfig (mkCommandLineArgs False) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do
57+
startDBSync dbSyncEnv
58+
b1 <- forgeAndSubmitBlocks interpreter mockServer 50
59+
-- add 2 blocks with tx
60+
void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000
61+
void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000
62+
b2 <- forgeAndSubmitBlocks interpreter mockServer 60
63+
64+
assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2)
65+
assertEqQuery dbSyncEnv DB.queryEpochCount 1 "new epoch didn't prune tx_out column that are null"
66+
where
67+
testLabel = "CLAcheckEpochDisabledArg "

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/CommandLineArg/MigrateConsumedPruneTxOut.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mkCommandLineArgs :: TxOutParam -> CommandLineArgs
4040
mkCommandLineArgs TxOutParam {..} =
4141
CommandLineArgs
4242
{ claHasConfigFile = True
43-
, claExtended = True
43+
, claEpochDisabled = True
4444
, claHasCache = True
4545
, claShouldUseLedger = True
4646
, claSkipFix = True
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[1,3,4,7,8,9,10,11,14,30,31,33,34,35,40,42,44,61,62,74,76,82,85,88,89,93,95,102,104,106,111,114,120,123,141,143,146,149,158,170,171,178,186,190,198,201,207,209,210,221,223,227,245,249,250,259,260,265,272,276,283,284,294,296,301,305,306,311,312,317,318,321,322,325,331,333,337,339,345,347,348,350,365,375,377,379,382,391,394,401,407,411,413,415,424,428,445,453,467,469,471,474,487,489,490,492,497,498,515,519,520,524]

cardano-db-sync/app/cardano-db-sync.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pRunDbSyncNode =
6969
<*> optional pLedgerStateDir
7070
<*> pMigrationDir
7171
<*> pPGPassSource
72-
<*> pExtended
72+
<*> pEpochDisabled
7373
<*> pHasCache
7474
<*> pUseLedger
7575
<*> pSkipFix
@@ -127,11 +127,11 @@ pPGPassSource =
127127
<> Opt.metavar "ENV"
128128
)
129129

130-
pExtended :: Parser Bool
131-
pExtended =
130+
pEpochDisabled :: Parser Bool
131+
pEpochDisabled =
132132
Opt.flag
133-
True
134133
False
134+
True
135135
( Opt.long "disable-epoch"
136136
<> Opt.help "Makes epoch table remain empty"
137137
)

cardano-db-sync/src/Cardano/DbSync.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ logProtocolMagicId tracer pm =
228228
extractSyncOptions :: SyncNodeParams -> Bool -> SyncOptions
229229
extractSyncOptions snp aop =
230230
SyncOptions
231-
{ soptExtended = enpExtended snp && enpHasCache snp
231+
{ soptEpochAndCacheEnabled = not $ enpEpochDisabled snp && enpHasCache snp
232232
, soptAbortOnInvalid = aop
233233
, soptCache = enpHasCache snp
234234
, soptSkipFix = enpSkipFix snp
@@ -255,7 +255,7 @@ startupReport trce aop params = do
255255
logInfo trce $ mconcat ["Git hash: ", Db.gitRev]
256256
logInfo trce $ mconcat ["Option disable-ledger: ", textShow (not $ enpShouldUseLedger params)]
257257
logInfo trce $ mconcat ["Option disable-cache: ", textShow (not $ enpHasCache params)]
258-
logInfo trce $ mconcat ["Option disable-epoch: ", textShow (not $ enpExtended params)]
258+
logInfo trce $ mconcat ["Option disable-epoch: ", textShow (enpEpochDisabled params)]
259259
logInfo trce $ mconcat ["Option skip-fix: ", textShow (enpSkipFix params)]
260260
logInfo trce $ mconcat ["Option fix-only: ", textShow (enpOnlyFix params)]
261261
logInfo trce $ mconcat ["Option force-indexes: ", textShow (enpForceIndexes params)]

cardano-db-sync/src/Cardano/DbSync/Api/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ data SyncEnv = SyncEnv
5454
}
5555

5656
data SyncOptions = SyncOptions
57-
{ soptExtended :: !Bool
57+
{ soptEpochAndCacheEnabled :: !Bool
5858
, soptAbortOnInvalid :: !Bool
5959
, soptCache :: !Bool
6060
, soptSkipFix :: !Bool

0 commit comments

Comments
 (0)