Skip to content

Commit 1a192a3

Browse files
committed
use defaultCommandLineArgs make code less verbose
1 parent 4a913e0 commit 1a192a3

File tree

5 files changed

+11
-58
lines changed

5 files changed

+11
-58
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import Cardano.Mock.ChainSync.Server
5252
import Cardano.Mock.Forging.Interpreter
5353
import Cardano.Node.Protocol.Shelley (readLeaderCredentials)
5454
import Cardano.Node.Types (ProtocolFilepaths (..))
55-
import Cardano.Prelude (ReaderT, panic, stderr, fromMaybe)
55+
import Cardano.Prelude (ReaderT, panic, stderr)
5656
import Cardano.SMASH.Server.PoolDataLayer
5757
import Control.Concurrent.Async (Async, async, cancel, poll)
5858
import Control.Concurrent.STM (atomically)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ unitTests iom knownMigrations =
3838
, test "node restart boundary" BabSimple.nodeRestartBoundary
3939
]
4040
, testGroup
41-
"Command Line Arguements"
41+
"Command Line Arguments"
4242
[ testGroup
4343
"MigrateConsumed - PruneTxOut"
4444
[ test "flag check" MigrateConsumedPruneTxOut.commandLineArgCheck

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,16 @@ where
55

66
import Cardano.Mock.ChainSync.Server (IOManager)
77
import Data.Text (Text)
8-
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), babbageConfigDir, withCustomConfigAndLogs)
8+
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), babbageConfigDir, initCommandLineArgs, withCustomConfigAndLogs)
99
import Test.Tasty.HUnit (Assertion)
1010

11-
mkCommandLineArgs :: Bool -> CommandLineArgs
12-
mkCommandLineArgs hasConfigFile =
13-
CommandLineArgs
14-
{ claHasConfigFile = hasConfigFile
15-
, claEpochDisabled = True
16-
, claHasCache = True
17-
, claShouldUseLedger = True
18-
, claSkipFix = True
19-
, claOnlyFix = False
20-
, claForceIndexes = False
21-
, claHasMultiAssets = True
22-
, claHasMetadata = True
23-
, claHasPlutusExtra = True
24-
, claHasOfflineData = True
25-
, claTurboMode = False
26-
, claFullMode = True
27-
, claMigrateConsumed = True
28-
, claPruneTxOut = True
29-
}
11+
commandLineArgs :: CommandLineArgs
12+
commandLineArgs = initCommandLineArgs {claHasConfigFile = False}
3013

3114
-- this test fails as incorrect configuration file given
3215
checkConfigFileArg :: IOManager -> [(Text, Text)] -> Assertion
3316
checkConfigFileArg =
34-
withCustomConfigAndLogs (mkCommandLineArgs False) babbageConfigDir testLabel $ \_ _ _ -> do
17+
withCustomConfigAndLogs commandLineArgs babbageConfigDir testLabel $ \_ _ _ -> do
3518
pure ()
3619
where
3720
testLabel = "CLAcheckConfigFileArg"

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,13 @@ import qualified Cardano.Mock.Forging.Tx.Babbage as Babbage
1010
import Cardano.Mock.Forging.Types (UTxOIndex (..))
1111
import Control.Monad (void)
1212
import Data.Text (Text)
13-
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), babbageConfigDir, startDBSync, withCustomConfig)
13+
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), babbageConfigDir, startDBSync, withCustomConfig, initCommandLineArgs)
1414
import Test.Cardano.Db.Mock.UnifiedApi (forgeAndSubmitBlocks, withBabbageFindLeaderAndSubmitTx)
1515
import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff, assertEqQuery)
1616
import Test.Tasty.HUnit (Assertion)
1717

1818
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-
}
19+
mkCommandLineArgs epochDisabled = initCommandLineArgs {claEpochDisabled = epochDisabled}
3720

3821
-- this test fails as incorrect configuration file given
3922
checkEpochDisabledArg :: IOManager -> [(Text, Text)] -> Assertion

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Control.Concurrent.Class.MonadSTM.Strict (atomically)
2222
import Control.Monad (void)
2323
import Data.Text (Text)
2424
import Ouroboros.Consensus.Block (blockPoint)
25-
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), TxOutParam (..), babbageConfigDir, startDBSync, withCustomConfig)
25+
import Test.Cardano.Db.Mock.Config (CommandLineArgs (..), TxOutParam (..), babbageConfigDir, startDBSync, withCustomConfig, initCommandLineArgs)
2626
import Test.Cardano.Db.Mock.Examples (mockBlock0, mockBlock1)
2727
import Test.Cardano.Db.Mock.UnifiedApi (
2828
forgeAndSubmitBlocks,
@@ -38,21 +38,8 @@ import Test.Tasty.HUnit (Assertion)
3838
-- defaults for
3939
mkCommandLineArgs :: TxOutParam -> CommandLineArgs
4040
mkCommandLineArgs TxOutParam {..} =
41-
CommandLineArgs
42-
{ claHasConfigFile = True
43-
, claEpochDisabled = True
44-
, claHasCache = True
45-
, claShouldUseLedger = True
46-
, claSkipFix = True
47-
, claOnlyFix = False
48-
, claForceIndexes = False
49-
, claHasMultiAssets = True
50-
, claHasMetadata = True
51-
, claHasPlutusExtra = True
52-
, claHasOfflineData = True
53-
, claTurboMode = False
54-
, claFullMode = True
55-
, claMigrateConsumed = paramMigrateConsumed
41+
initCommandLineArgs
42+
{ claMigrateConsumed = paramMigrateConsumed
5643
, claPruneTxOut = paramPruneTxOut
5744
}
5845

0 commit comments

Comments
 (0)