Skip to content

1938 - 1 - Variant Name Change #1989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check-fourmolu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Run fourmolu
uses: haskell-actions/run-fourmolu@v9
uses: haskell-actions/run-fourmolu@v11
with:
version: "0.10.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

version: "0.17.0.0"
42 changes: 21 additions & 21 deletions cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ module Test.Cardano.Db.Mock.Config (
startDBSync,
withDBSyncEnv,
withFullConfig,
withFullConfigAndDropDB,
withFullConfigAndLogs,
withCustomConfigAndLogsAndDropDB,
withFullConfigDropDB,
withFullConfigLog,
withCustomConfigDropDBLog,
withCustomConfig,
withCustomConfigAndDropDB,
withCustomConfigAndLogs,
withCustomConfigDropDB,
withCustomConfigLog,
withFullConfig',
replaceConfigFile,
txOutTableTypeFromConfig,
txOutVariantTypeFromConfig,
) where

import Cardano.Api (NetworkMagic (..))
Expand Down Expand Up @@ -401,7 +401,7 @@ withFullConfig =
Nothing

-- this function needs to be used where the schema needs to be rebuilt
withFullConfigAndDropDB ::
withFullConfigDropDB ::
-- | config filepath
FilePath ->
-- | test label
Expand All @@ -410,7 +410,7 @@ withFullConfigAndDropDB ::
IOManager ->
[(Text, Text)] ->
IO a
withFullConfigAndDropDB =
withFullConfigDropDB =
withFullConfig'
( WithConfigArgs
{ hasFingerprint = True
Expand All @@ -421,7 +421,7 @@ withFullConfigAndDropDB =
initCommandLineArgs
Nothing

withFullConfigAndLogs ::
withFullConfigLog ::
-- | config filepath
FilePath ->
-- | test label
Expand All @@ -430,7 +430,7 @@ withFullConfigAndLogs ::
IOManager ->
[(Text, Text)] ->
IO a
withFullConfigAndLogs =
withFullConfigLog =
withFullConfig'
( WithConfigArgs
{ hasFingerprint = True
Expand Down Expand Up @@ -462,7 +462,7 @@ withCustomConfig =
}
)

withCustomConfigAndDropDB ::
withCustomConfigDropDB ::
CommandLineArgs ->
-- | custom SyncNodeConfig
Maybe (SyncNodeConfig -> SyncNodeConfig) ->
Expand All @@ -474,7 +474,7 @@ withCustomConfigAndDropDB ::
IOManager ->
[(Text, Text)] ->
IO a
withCustomConfigAndDropDB =
withCustomConfigDropDB =
withFullConfig'
( WithConfigArgs
{ hasFingerprint = True
Expand All @@ -484,7 +484,7 @@ withCustomConfigAndDropDB =
)

-- This is a usefull function to be able to see logs from DBSync when writing/debuging tests
withCustomConfigAndLogs ::
withCustomConfigLog ::
CommandLineArgs ->
-- | custom SyncNodeConfig
Maybe (SyncNodeConfig -> SyncNodeConfig) ->
Expand All @@ -496,7 +496,7 @@ withCustomConfigAndLogs ::
IOManager ->
[(Text, Text)] ->
IO a
withCustomConfigAndLogs =
withCustomConfigLog =
withFullConfig'
( WithConfigArgs
{ hasFingerprint = True
Expand All @@ -505,7 +505,7 @@ withCustomConfigAndLogs =
}
)

withCustomConfigAndLogsAndDropDB ::
withCustomConfigDropDBLog ::
CommandLineArgs ->
-- | custom SyncNodeConfig
Maybe (SyncNodeConfig -> SyncNodeConfig) ->
Expand All @@ -517,7 +517,7 @@ withCustomConfigAndLogsAndDropDB ::
IOManager ->
[(Text, Text)] ->
IO a
withCustomConfigAndLogsAndDropDB =
withCustomConfigDropDBLog =
withFullConfig'
( WithConfigArgs
{ hasFingerprint = True
Expand Down Expand Up @@ -604,14 +604,14 @@ replaceConfigFile newFilename dbSync@DBSyncEnv {..} = do
newParams =
dbSyncParams {enpConfigFile = ConfigFile $ configDir </> newFilename}

txOutTableTypeFromConfig :: DBSyncEnv -> DB.TxOutTableType
txOutTableTypeFromConfig dbSyncEnv =
txOutVariantTypeFromConfig :: DBSyncEnv -> DB.TxOutVariantType
txOutVariantTypeFromConfig dbSyncEnv =
case sioTxOut $ dncInsertOptions $ dbSyncConfig dbSyncEnv of
TxOutDisable -> DB.TxOutCore
TxOutDisable -> DB.TxOutVariantCore
TxOutEnable useTxOutAddress -> getTxOutTT useTxOutAddress
TxOutConsumed _ useTxOutAddress -> getTxOutTT useTxOutAddress
TxOutConsumedPrune _ useTxOutAddress -> getTxOutTT useTxOutAddress
TxOutConsumedBootstrap _ useTxOutAddress -> getTxOutTT useTxOutAddress
where
getTxOutTT :: UseTxOutAddress -> DB.TxOutTableType
getTxOutTT value = if unUseTxOutAddress value then DB.TxOutVariantAddress else DB.TxOutCore
getTxOutTT :: UseTxOutAddress -> DB.TxOutVariantType
getTxOutTT value = if unUseTxOutAddress value then DB.TxOutVariantAddress else DB.TxOutVariantCore
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import Control.Concurrent.Class.MonadSTM.Strict (MonadSTM (atomically))
import Control.Monad (void)
import Data.Text (Text)
import Ouroboros.Network.Block (blockNo)
import Test.Cardano.Db.Mock.Config (alonzoConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigAndDropDB)
import Test.Cardano.Db.Mock.Config (alonzoConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigDropDB)
import Test.Cardano.Db.Mock.Examples (mockBlock0, mockBlock1, mockBlock2)
import Test.Cardano.Db.Mock.UnifiedApi (forgeNextAndSubmit)
import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff)
import Test.Tasty.HUnit (Assertion, assertBool)

forgeBlocks :: IOManager -> [(Text, Text)] -> Assertion
forgeBlocks = do
withFullConfigAndDropDB alonzoConfigDir testLabel $ \interpreter _mockServer _dbSync -> do
withFullConfigDropDB alonzoConfigDir testLabel $ \interpreter _mockServer _dbSync -> do
_block0 <- forgeNext interpreter mockBlock0
_block1 <- forgeNext interpreter mockBlock1
block2 <- forgeNext interpreter mockBlock2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Test.Cardano.Db.Mock.Config (
alonzoConfigDir,
startDBSync,
withFullConfig,
withFullConfigAndDropDB,
withFullConfigDropDB,
)
import Test.Cardano.Db.Mock.UnifiedApi (
withAlonzoFindLeaderAndSubmit,
Expand All @@ -29,7 +29,7 @@ import Test.Tasty.HUnit (Assertion)

addSimpleTx :: IOManager -> [(Text, Text)] -> Assertion
addSimpleTx =
withFullConfigAndDropDB alonzoConfigDir testLabel $ \interpreter mockServer dbSync -> do
withFullConfigDropDB alonzoConfigDir testLabel $ \interpreter mockServer dbSync -> do
-- translate the block to a real Cardano block.
void $
withAlonzoFindLeaderAndSubmitTx interpreter mockServer $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Control.Monad (forM_, void)
import qualified Data.Map as Map
import Data.Text (Text)
import Ouroboros.Network.Block (blockPoint)
import Test.Cardano.Db.Mock.Config (babbageConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigAndDropDB)
import Test.Cardano.Db.Mock.Config (babbageConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigDropDB)
import Test.Cardano.Db.Mock.UnifiedApi (
fillEpochPercentage,
fillEpochs,
Expand All @@ -59,7 +59,7 @@ import Test.Tasty.HUnit (Assertion)

simpleRewards :: IOManager -> [(Text, Text)] -> Assertion
simpleRewards =
withFullConfigAndDropDB babbageConfigDir testLabel $ \interpreter mockServer dbSync -> do
withFullConfigDropDB babbageConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync
void $ registerAllStakeCreds interpreter mockServer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import Control.Concurrent.Class.MonadSTM.Strict (atomically)
import Control.Monad (void)
import Data.Text (Text)
import Ouroboros.Network.Block (blockNo)
import Test.Cardano.Db.Mock.Config (babbageConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigAndDropDB)
import Test.Cardano.Db.Mock.Config (babbageConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigDropDB)
import Test.Cardano.Db.Mock.Examples (mockBlock0, mockBlock1, mockBlock2)
import Test.Cardano.Db.Mock.UnifiedApi (fillUntilNextEpoch, forgeAndSubmitBlocks, forgeNextAndSubmit)
import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff)
import Test.Tasty.HUnit (Assertion, assertBool)

forgeBlocks :: IOManager -> [(Text, Text)] -> Assertion
forgeBlocks = do
withFullConfigAndDropDB babbageConfigDir testLabel $ \interpreter _mockServer _dbSync -> do
withFullConfigDropDB babbageConfigDir testLabel $ \interpreter _mockServer _dbSync -> do
_block0 <- forgeNext interpreter mockBlock0
_block1 <- forgeNext interpreter mockBlock1
block2 <- forgeNext interpreter mockBlock2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Prelude ()

checkEpochDisabledArg :: IOManager -> [(Text, Text)] -> Assertion
checkEpochDisabledArg =
withCustomConfigAndDropDB cliArgs Nothing conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cliArgs Nothing conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Test.Tasty.HUnit (Assertion ())

configRemoveJsonbFromSchemaEnabled :: IOManager -> [(Text, Text)] -> Assertion
configRemoveJsonbFromSchemaEnabled = do
withCustomConfigAndDropDB args (Just configRemoveJsonFromSchema) cfgDir testLabel $ \_interpreter _mockServer dbSync -> do
withCustomConfigDropDB args (Just configRemoveJsonFromSchema) cfgDir testLabel $ \_interpreter _mockServer dbSync -> do
startDBSync dbSync
threadDelay 7_000_000
assertEqQuery
Expand All @@ -35,7 +35,7 @@ configRemoveJsonbFromSchemaEnabled = do

configRemoveJsonbFromSchemaDisabled :: IOManager -> [(Text, Text)] -> Assertion
configRemoveJsonbFromSchemaDisabled = do
withCustomConfigAndDropDB args (Just configRemoveJsonFromSchemaFalse) cfgDir testLabel $
withCustomConfigDropDB args (Just configRemoveJsonFromSchemaFalse) cfgDir testLabel $
\_interpreter _mockServer dbSync -> do
startDBSync dbSync
threadDelay 7_000_000
Expand All @@ -52,7 +52,7 @@ configRemoveJsonbFromSchemaDisabled = do

configJsonbInSchemaShouldRemoveThenAdd :: IOManager -> [(Text, Text)] -> Assertion
configJsonbInSchemaShouldRemoveThenAdd =
withCustomConfigAndDropDB args (Just configRemoveJsonFromSchema) cfgDir testLabel $ \_interpreter _mockServer dbSyncEnv -> do
withCustomConfigDropDB args (Just configRemoveJsonFromSchema) cfgDir testLabel $ \_interpreter _mockServer dbSyncEnv -> do
startDBSync dbSyncEnv
threadDelay 7_000_000
assertEqQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ basicPruneWithAddress = performBasicPrune True

performBasicPrune :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performBasicPrune useTxOutAddress = do
withCustomConfigAndDropDB args (Just $ configPruneForceTxIn useTxOutAddress) cfgDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB args (Just $ configPruneForceTxIn useTxOutAddress) cfgDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync
let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync

-- Add some blocks
blks <- forgeAndSubmitBlocks interpreter mockServer 50
Expand Down Expand Up @@ -98,8 +98,8 @@ pruneWithSimpleRollbackWithAddress = performPruneWithSimpleRollback True

performPruneWithSimpleRollback :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruneWithSimpleRollback useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
let txOutTableType = txOutTableTypeFromConfig dbSync
withCustomConfigDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge some blocks
blk0 <- forgeNext interpreter mockBlock0
blk1 <- forgeNext interpreter mockBlock1
Expand Down Expand Up @@ -141,9 +141,9 @@ pruneWithFullTxRollbackWithAddress = performPruneWithFullTxRollback True

performPruneWithFullTxRollback :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruneWithFullTxRollback useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync
let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge a block
blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer []
-- Add some transactions
Expand Down Expand Up @@ -186,9 +186,9 @@ pruningShouldKeepSomeTxWithAddress = performPruningShouldKeepSomeTx True

performPruningShouldKeepSomeTx :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruningShouldKeepSomeTx useTxOutAddress = do
withCustomConfigAndDropDB cmdLineArgs (Just $ configPrune useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configPrune useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync
let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge some blocks
blk1 <- forgeAndSubmitBlocks interpreter mockServer 80
-- These two blocks/transactions will fall within the last (2 * securityParam) 20
Expand Down Expand Up @@ -222,10 +222,10 @@ pruneAndRollBackOneBlockWithAddress = performPruneAndRollBackOneBlock True

performPruneAndRollBackOneBlock :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruneAndRollBackOneBlock useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge some blocks
void $ forgeAndSubmitBlocks interpreter mockServer 98
-- These transactions will fall within the last (2 * securityParam) 20
Expand Down Expand Up @@ -268,10 +268,10 @@ noPruneAndRollBackWithAddress = performNoPruneAndRollBack True

performNoPruneAndRollBack :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performNoPruneAndRollBack useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge some blocks
void $ forgeAndSubmitBlocks interpreter mockServer 98
-- Add a block with transactions
Expand Down Expand Up @@ -314,10 +314,10 @@ pruneSameBlockWithAddress = performPruneSameBlock True

performPruneSameBlock :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruneSameBlock useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

let txOutTableType = txOutTableTypeFromConfig dbSync
let txOutTableType = txOutVariantTypeFromConfig dbSync
-- Forge some blocks
void $ forgeAndSubmitBlocks interpreter mockServer 76
blk77 <- forgeNextFindLeaderAndSubmit interpreter mockServer []
Expand Down Expand Up @@ -357,7 +357,7 @@ noPruneSameBlockWithAddress = performNoPruneSameBlock True

performNoPruneSameBlock :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performNoPruneSameBlock useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand All @@ -382,7 +382,7 @@ performNoPruneSameBlock useTxOutAddress =
void $ forgeNextFindLeaderAndSubmit interpreter mockServer []
-- Verify everything was pruned
assertBlockNoBackoff dbSync 98
assertEqQuery dbSync (DB.queryTxOutConsumedCount $ txOutTableTypeFromConfig dbSync) 0 "Unexpected TxOutConsumedByTxId after rollback"
assertEqQuery dbSync (DB.queryTxOutConsumedCount $ txOutVariantTypeFromConfig dbSync) 0 "Unexpected TxOutConsumedByTxId after rollback"
where
cmdLineArgs = initCommandLineArgs
testLabel = "conwayConfigNoPruneSameBlock"
Expand All @@ -395,7 +395,7 @@ migrateAndPruneRestartWithAddress = performMigrateAndPruneRestart True

performMigrateAndPruneRestart :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performMigrateAndPruneRestart useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configConsume useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand Down Expand Up @@ -424,7 +424,7 @@ pruneRestartMissingFlagWithAddress = performPruneRestartMissingFlag True

performPruneRestartMissingFlag :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performPruneRestartMissingFlag useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configPruneForceTxIn useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand Down Expand Up @@ -453,7 +453,7 @@ bootstrapRestartMissingFlagWithAddress = performBootstrapRestartMissingFlag True

performBootstrapRestartMissingFlag :: Bool -> IOManager -> [(Text, Text)] -> Assertion
performBootstrapRestartMissingFlag useTxOutAddress =
withCustomConfigAndDropDB cmdLineArgs (Just $ configBootstrap useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configBootstrap useTxOutAddress) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand All @@ -476,7 +476,7 @@ performBootstrapRestartMissingFlag useTxOutAddress =

populateDbRestartWithAddressConfig :: IOManager -> [(Text, Text)] -> Assertion
populateDbRestartWithAddressConfig =
withCustomConfigAndDropDB cmdLineArgs (Just $ configConsume False) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
withCustomConfigDropDB cmdLineArgs (Just $ configConsume False) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do
startDBSync dbSync

-- Forge some blocks
Expand Down
Loading
Loading