From 6010aff972afdea8642cfd8667973109aab252ae Mon Sep 17 00:00:00 2001 From: Cmdv Date: Tue, 17 Sep 2024 14:20:24 +0100 Subject: [PATCH] remove config files and hardcode the content --- .../test/Test/Cardano/Db/Mock/Config.hs | 20 +- .../Config/MigrateConsumedPruneTxOut.hs | 523 +++++++------- .../Mock/Unit/Conway/Config/JsonbInSchema.hs | 95 ++- .../Config/MigrateConsumedPruneTxOut.hs | 674 +++++++++--------- .../Cardano/Db/Mock/Unit/Conway/Plutus.hs | 35 +- .../Test/Cardano/Db/Mock/Unit/Conway/Stake.hs | 10 +- .../Test/Cardano/Db/Mock/Unit/Conway/Tx.hs | 62 +- .../test-db-sync-config-keep-metadata.json | 120 ---- .../test-db-sync-config-no-ledger.json | 117 --- .../test-db-sync-config-no-metadata.json | 119 ---- .../test-db-sync-config-no-multi-assets.json | 119 ---- .../test-db-sync-config-no-plutus.json | 119 ---- .../test-db-sync-config-no-shelley.json | 119 ---- 13 files changed, 690 insertions(+), 1442 deletions(-) delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-keep-metadata.json delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-ledger.json delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-metadata.json delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-multi-assets.json delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-plutus.json delete mode 100644 cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-shelley.json diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs index f7e575aac..af9cfb4ae 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs @@ -19,7 +19,6 @@ module Test.Cardano.Db.Mock.Config ( getPoolLayer, mkConfig, mkSyncNodeConfig, - mkCustomSyncNodeConfig, mkConfigDir, mkFingerPrint, mkMutableDir, @@ -243,11 +242,6 @@ mkSyncNodeConfig configFilePath cmdLineArgs = configFilename = claConfigFilename cmdLineArgs configDir = mkConfigDir configFilePath -mkCustomSyncNodeConfig :: FilePath -> CommandLineArgs -> (SyncNodeConfig -> SyncNodeConfig) -> IO SyncNodeConfig -mkCustomSyncNodeConfig cfgDir args updateFn = do - initConfigFile <- mkSyncNodeConfig cfgDir args - pure $ updateFn initConfigFile - mkShelleyCredentials :: FilePath -> IO [ShelleyLeaderCredentials StandardCrypto] mkShelleyCredentials bulkFile = do eitherM (panic . textShow) pure $ runExceptT $ readLeaderCredentials (Just protFiles) @@ -383,7 +377,7 @@ withFullConfigAndLogs = withCustomConfig :: CommandLineArgs -> -- | custom SyncNodeConfig - Maybe SyncNodeConfig -> + Maybe (SyncNodeConfig -> SyncNodeConfig) -> -- | config filepath FilePath -> -- | test label @@ -404,7 +398,7 @@ withCustomConfig = withCustomConfigAndDropDB :: CommandLineArgs -> -- | custom SyncNodeConfig - Maybe SyncNodeConfig -> + Maybe (SyncNodeConfig -> SyncNodeConfig) -> -- | config filepath FilePath -> -- | test label @@ -426,7 +420,7 @@ withCustomConfigAndDropDB = withCustomConfigAndLogs :: CommandLineArgs -> -- | custom SyncNodeConfig - Maybe SyncNodeConfig -> + Maybe (SyncNodeConfig -> SyncNodeConfig) -> -- | config filepath FilePath -> -- | test label @@ -447,7 +441,7 @@ withCustomConfigAndLogs = withCustomConfigAndLogsAndDropDB :: CommandLineArgs -> -- | custom SyncNodeConfig - Maybe SyncNodeConfig -> + Maybe (SyncNodeConfig -> SyncNodeConfig) -> -- | config filepath FilePath -> -- | test label @@ -469,7 +463,7 @@ withFullConfig' :: WithConfigArgs -> CommandLineArgs -> -- | custom SyncNodeConfig - Maybe SyncNodeConfig -> + Maybe (SyncNodeConfig -> SyncNodeConfig) -> -- | config filepath FilePath -> -- | test label @@ -483,7 +477,9 @@ withFullConfig' WithConfigArgs {..} cmdLineArgs mSyncNodeConfig configFilePath t -- check if custom syncNodeConfigs have been passed or not syncNodeConfig <- case mSyncNodeConfig of - Just snc -> pure snc + Just updateFn -> do + initConfigFile <- mkSyncNodeConfig configFilePath cmdLineArgs + pure $ updateFn initConfigFile Nothing -> mkSyncNodeConfig configFilePath cmdLineArgs cfg <- mkConfig configFilePath mutableDir cmdLineArgs syncNodeConfig diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/MigrateConsumedPruneTxOut.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/MigrateConsumedPruneTxOut.hs index 5e82591b1..7963a6392 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/MigrateConsumedPruneTxOut.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/MigrateConsumedPruneTxOut.hs @@ -35,11 +35,11 @@ import Test.Cardano.Db.Mock.Config ( CommandLineArgs (..), babbageConfigDir, initCommandLineArgs, - mkCustomSyncNodeConfig, replaceConfigFile, startDBSync, stopDBSync, withCustomConfig, + withCustomConfigAndDropDB, ) import Test.Cardano.Db.Mock.Examples (mockBlock0, mockBlock1) import Test.Cardano.Db.Mock.UnifiedApi ( @@ -53,333 +53,310 @@ import Test.Cardano.Db.Mock.UnifiedApi ( import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff, assertEqQuery, assertTxCount, assertTxInCount, assertTxOutCount, assertUnspentTx, checkStillRuns) import Test.Tasty.HUnit (Assertion) -migrateTxOutPruneForceTxIn :: SyncNodeConfig -> SyncNodeConfig -migrateTxOutPruneForceTxIn cfg = do +------------------------------------------------------------------------------ +-- Custom Configs +------------------------------------------------------------------------------ +configTxOutPruneForceTxIn :: SyncNodeConfig -> SyncNodeConfig +configTxOutPruneForceTxIn cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn True)}} -migrateTxOutPruneConfig :: SyncNodeConfig -> SyncNodeConfig -migrateTxOutPruneConfig cfg = do +configTxOutPrune :: SyncNodeConfig -> SyncNodeConfig +configTxOutPrune cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn False)}} -migrateTxOutConsumeConfig :: SyncNodeConfig -> SyncNodeConfig -migrateTxOutConsumeConfig cfg = do +configConsume :: SyncNodeConfig -> SyncNodeConfig +configConsume cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutConsumed (ForceTxIn False)}} +configBootstrap :: SyncNodeConfig -> SyncNodeConfig +configBootstrap cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutBootstrap (ForceTxIn False)}} + +------------------------------------------------------------------------------ +-- Tests +------------------------------------------------------------------------------ txConsumedColumnCheck :: IOManager -> [(Text, Text)] -> Assertion -txConsumedColumnCheck ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +txConsumedColumnCheck = do + withCustomConfigAndDropDB cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + void $ + withBabbageFindLeaderAndSubmitTx interpreter mockServer $ + Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 500 + + startDBSync dbSyncEnv + assertBlockNoBackoff dbSyncEnv 1 + assertEqQuery dbSyncEnv DB.queryTxConsumedColumnExists True "missing consumed_by_tx_id column when flag --consumed-tx-out active" where - action interpreter mockServer dbSyncEnv = do - void $ - withBabbageFindLeaderAndSubmitTx interpreter mockServer $ - Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 500 - - startDBSync dbSyncEnv - assertBlockNoBackoff dbSyncEnv 1 - assertEqQuery dbSyncEnv DB.queryTxConsumedColumnExists True "missing consumed_by_tx_id column when flag --consumed-tx-out active" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configTxConsumedColumnCheck" basicPrune :: IOManager -> [(Text, Text)] -> Assertion -basicPrune ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +basicPrune = do + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + -- add 50 block + b1 <- forgeAndSubmitBlocks interpreter mockServer 50 + -- add 2 blocks with tx + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000 + assertBlockNoBackoff dbSyncEnv (fromIntegral $ length b1 + 2) + -- check tx-out count before any pruning has happened + assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" + -- add other blocks to instantiate the pruning + b2 <- forgeAndSubmitBlocks interpreter mockServer 48 + assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2) + + -- check that the tx_out has been pruned + assertEqQuery dbSyncEnv DB.queryTxOutCount 12 "the pruning didn't work correctly as the tx-out count is incorrect" + -- check Unspent tx match after pruning + assertUnspentTx dbSyncEnv where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - -- add 50 block - b1 <- forgeAndSubmitBlocks interpreter mockServer 50 - -- add 2 blocks with tx - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000 - assertBlockNoBackoff dbSyncEnv (fromIntegral $ length b1 + 2) - -- check tx-out count before any pruning has happened - assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" - -- add other blocks to instantiate the pruning - b2 <- forgeAndSubmitBlocks interpreter mockServer 48 - assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2) - - -- check that the tx_out has been pruned - assertEqQuery dbSyncEnv DB.queryTxOutCount 12 "the pruning didn't work correctly as the tx-out count is incorrect" - -- check Unspent tx match after pruning - assertUnspentTx dbSyncEnv - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPrune" pruneWithSimpleRollback :: IOManager -> [(Text, Text)] -> Assertion -pruneWithSimpleRollback ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruneWithSimpleRollback = do + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + blk0 <- forgeNext interpreter mockBlock0 + blk1 <- forgeNext interpreter mockBlock1 + atomically $ addBlock mockServer blk0 + startDBSync dbSyncEnv + atomically $ addBlock mockServer blk1 + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000 + assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "" + b1 <- forgeAndSubmitBlocks interpreter mockServer 96 + assertBlockNoBackoff dbSyncEnv (fullBlockSize b1) + assertEqQuery dbSyncEnv DB.queryTxOutCount 12 "the txOut count is incorrect" + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" + assertUnspentTx dbSyncEnv + + rollbackTo interpreter mockServer (blockPoint blk1) + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId cout after rollback" + assertBlockNoBackoff dbSyncEnv $ fullBlockSize b1 where - action interpreter mockServer dbSyncEnv = do - blk0 <- forgeNext interpreter mockBlock0 - blk1 <- forgeNext interpreter mockBlock1 - atomically $ addBlock mockServer blk0 - startDBSync dbSyncEnv - atomically $ addBlock mockServer blk1 - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10000 10000 - assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "" - b1 <- forgeAndSubmitBlocks interpreter mockServer 96 - assertBlockNoBackoff dbSyncEnv (fullBlockSize b1) - assertEqQuery dbSyncEnv DB.queryTxOutCount 12 "the txOut count is incorrect" - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" - assertUnspentTx dbSyncEnv - - rollbackTo interpreter mockServer (blockPoint blk1) - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId cout after rollback" - assertBlockNoBackoff dbSyncEnv $ fullBlockSize b1 - - args = initCommandLineArgs fullBlockSize b = fromIntegral $ length b + 4 + cmdLineArgs = initCommandLineArgs testLabel = "configPruneSimpleRollback" pruneWithFullTxRollback :: IOManager -> [(Text, Text)] -> Assertion -pruneWithFullTxRollback ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruneWithFullTxRollback = do + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Babbage.mkFullTx 0 100 st + tx1 <- Babbage.mkFullTx 1 200 st + pure [tx0, tx1] + assertBlockNoBackoff dbSyncEnv 2 + assertTxCount dbSyncEnv 13 + assertUnspentTx dbSyncEnv + assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" + rollbackTo interpreter mockServer $ blockPoint blk0 + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Babbage.mkFullTx 0 100 st + tx1 <- Babbage.mkFullTx 1 200 st + tx2 <- Babbage.mkFullTx 2 200 st + pure [tx1, tx2, tx0] + assertBlockNoBackoff dbSyncEnv 2 + assertTxCount dbSyncEnv 14 + assertEqQuery dbSyncEnv DB.queryTxOutCount 16 "new epoch didn't prune tx_out column that are null" + assertUnspentTx dbSyncEnv where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Babbage.mkFullTx 0 100 st - tx1 <- Babbage.mkFullTx 1 200 st - pure [tx0, tx1] - assertBlockNoBackoff dbSyncEnv 2 - assertTxCount dbSyncEnv 13 - assertUnspentTx dbSyncEnv - assertEqQuery dbSyncEnv DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" - rollbackTo interpreter mockServer $ blockPoint blk0 - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Babbage.mkFullTx 0 100 st - tx1 <- Babbage.mkFullTx 1 200 st - tx2 <- Babbage.mkFullTx 2 200 st - pure [tx1, tx2, tx0] - assertBlockNoBackoff dbSyncEnv 2 - assertTxCount dbSyncEnv 14 - assertEqQuery dbSyncEnv DB.queryTxOutCount 16 "new epoch didn't prune tx_out column that are null" - assertUnspentTx dbSyncEnv - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneOnFullRollback" -- The tx in the last, 2 x securityParam worth of blocks should not be pruned. -- In these tests, 2 x securityParam = 20 blocks. pruningShouldKeepSomeTx :: IOManager -> [(Text, Text)] -> Assertion -pruningShouldKeepSomeTx ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneConfig - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruningShouldKeepSomeTx = do + withCustomConfig cmdLineArgs (Just configTxOutPrune) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + b1 <- forgeAndSubmitBlocks interpreter mockServer 80 + -- these two blocs + tx will fall withing the last 20 blocks so should not be pruned + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 10000 + b2 <- forgeAndSubmitBlocks interpreter mockServer 18 + assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2) + -- the two marked TxOutConsumedByTxId should not be pruned + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count after prune" + -- add more blocks to instantiate another prune + b3 <- forgeAndSubmitBlocks interpreter mockServer 110 + assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2 <> b3) + 2) + -- the prune should have removed all + assertTxInCount dbSyncEnv 0 + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - b1 <- forgeAndSubmitBlocks interpreter mockServer 80 - -- these two blocs + tx will fall withing the last 20 blocks so should not be pruned - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 10000 - b2 <- forgeAndSubmitBlocks interpreter mockServer 18 - assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2) + 2) - -- the two marked TxOutConsumedByTxId should not be pruned - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count after prune" - -- add more blocks to instantiate another prune - b3 <- forgeAndSubmitBlocks interpreter mockServer 110 - assertBlockNoBackoff dbSyncEnv (fromIntegral $ length (b1 <> b2 <> b3) + 2) - -- the prune should have removed all - assertTxInCount dbSyncEnv 0 - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneCorrectAmount" -- prune with rollback pruneAndRollBackOneBlock :: IOManager -> [(Text, Text)] -> Assertion -pruneAndRollBackOneBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruneAndRollBackOneBlock = do + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 98 + -- add 2 blocks with tx + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 + -- add an empty block then fill it with a tx so we can use blk100 as point to rollback + blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + st <- getBabbageLedgerState interpreter + let Right tx1 = Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 500 st + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \_st -> + Right [tx1] + assertBlockNoBackoff dbSyncEnv 101 + -- the 2 tx have been marked but not pruned as they are withing the last 20 blocks + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" + rollbackTo interpreter mockServer $ blockPoint blk100 + -- add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + assertBlockNoBackoff dbSyncEnv 101 + -- there should only be 1 tx marked now as the other was deleted in rollback + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" + -- cause another prune + void $ forgeAndSubmitBlocks interpreter mockServer 102 + assertBlockNoBackoff dbSyncEnv 203 + -- everything should be pruned + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 98 - -- add 2 blocks with tx - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 - -- add an empty block then fill it with a tx so we can use blk100 as point to rollback - blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - st <- getBabbageLedgerState interpreter - let Right tx1 = Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 500 st - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \_st -> - Right [tx1] - assertBlockNoBackoff dbSyncEnv 101 - -- the 2 tx have been marked but not pruned as they are withing the last 20 blocks - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" - rollbackTo interpreter mockServer $ blockPoint blk100 - -- add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - assertBlockNoBackoff dbSyncEnv 101 - -- there should only be 1 tx marked now as the other was deleted in rollback - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - -- cause another prune - void $ forgeAndSubmitBlocks interpreter mockServer 102 - assertBlockNoBackoff dbSyncEnv 203 - -- everything should be pruned - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneAndRollBack" -- consume with rollback noPruneAndRollBack :: IOManager -> [(Text, Text)] -> Assertion -noPruneAndRollBack ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutConsumeConfig - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +noPruneAndRollBack = do + withCustomConfig cmdLineArgs (Just configConsume) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 98 + -- add 2 blocks with tx + void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 + -- add an empty block then fill it with a tx so we can use blk100 as point to rollback + blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + st <- getBabbageLedgerState interpreter + let Right tx1 = Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 500 st + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \_st -> + Right [tx1] + assertBlockNoBackoff dbSyncEnv 101 + -- the 2 tx have been marked but not pruned as they are withing the last 20 blocks + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" + rollbackTo interpreter mockServer $ blockPoint blk100 + -- add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + assertBlockNoBackoff dbSyncEnv 101 + -- there should only be 1 tx marked now as the other was deleted in rollback + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" + -- cause another prune + void $ forgeAndSubmitBlocks interpreter mockServer 102 + assertBlockNoBackoff dbSyncEnv 203 + -- everything should be pruned + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 98 - -- add 2 blocks with tx - void $ withBabbageFindLeaderAndSubmitTx interpreter mockServer $ Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10000 10000 - -- add an empty block then fill it with a tx so we can use blk100 as point to rollback - blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - st <- getBabbageLedgerState interpreter - let Right tx1 = Babbage.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10000 500 st - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \_st -> - Right [tx1] - assertBlockNoBackoff dbSyncEnv 101 - -- the 2 tx have been marked but not pruned as they are withing the last 20 blocks - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" - rollbackTo interpreter mockServer $ blockPoint blk100 - -- add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - assertBlockNoBackoff dbSyncEnv 101 - -- there should only be 1 tx marked now as the other was deleted in rollback - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - -- cause another prune - void $ forgeAndSubmitBlocks interpreter mockServer 102 - assertBlockNoBackoff dbSyncEnv 203 - -- everything should be pruned - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneAndRollBack" pruneSameBlock :: IOManager -> [(Text, Text)] -> Assertion -pruneSameBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruneSameBlock = + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 76 + blk77 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20000 20000 st + let utxo0 = head (Babbage.mkUTxOBabbage tx0) + tx1 <- Babbage.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10000 500 st + pure [tx0, tx1] + assertBlockNoBackoff dbSyncEnv 78 + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId before rollback" + void $ forgeAndSubmitBlocks interpreter mockServer 22 + assertBlockNoBackoff dbSyncEnv 100 + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after prune" + rollbackTo interpreter mockServer (blockPoint blk77) + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + assertBlockNoBackoff dbSyncEnv 78 + assertTxInCount dbSyncEnv 0 + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 76 - blk77 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20000 20000 st - let utxo0 = head (Babbage.mkUTxOBabbage tx0) - tx1 <- Babbage.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10000 500 st - pure [tx0, tx1] - assertBlockNoBackoff dbSyncEnv 78 - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId before rollback" - void $ forgeAndSubmitBlocks interpreter mockServer 22 - assertBlockNoBackoff dbSyncEnv 100 - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after prune" - rollbackTo interpreter mockServer (blockPoint blk77) - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - assertBlockNoBackoff dbSyncEnv 78 - assertTxInCount dbSyncEnv 0 - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneSameBlock" noPruneSameBlock :: IOManager -> [(Text, Text)] -> Assertion -noPruneSameBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +noPruneSameBlock = + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 96 + blk97 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20000 20000 st + let utxo0 = head (Babbage.mkUTxOBabbage tx0) + tx1 <- Babbage.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10000 500 st + pure [tx0, tx1] + void $ forgeAndSubmitBlocks interpreter mockServer 2 + assertBlockNoBackoff dbSyncEnv 100 + rollbackTo interpreter mockServer (blockPoint blk97) + assertBlockNoBackoff dbSyncEnv 100 + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + assertBlockNoBackoff dbSyncEnv 98 + assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 96 - blk97 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - void $ withBabbageFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Babbage.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20000 20000 st - let utxo0 = head (Babbage.mkUTxOBabbage tx0) - tx1 <- Babbage.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10000 500 st - pure [tx0, tx1] - void $ forgeAndSubmitBlocks interpreter mockServer 2 - assertBlockNoBackoff dbSyncEnv 100 - rollbackTo interpreter mockServer (blockPoint blk97) - assertBlockNoBackoff dbSyncEnv 100 - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - assertBlockNoBackoff dbSyncEnv 98 - assertEqQuery dbSyncEnv DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configNoPruneSameBlock" migrateAndPruneRestart :: IOManager -> [(Text, Text)] -> Assertion -migrateAndPruneRestart ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +migrateAndPruneRestart = do + withCustomConfig cmdLineArgs (Just configConsume) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 50 + assertBlockNoBackoff dbSyncEnv 50 + -- stop + stopDBSync dbSyncEnv + -- update the syncParams to include new params + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv + startDBSync newEnv + -- there is a slight delay before flag is checked + threadDelay 6000000 + -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception + checkStillRuns dbSyncEnv where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 50 - assertBlockNoBackoff dbSyncEnv 50 - -- stop - stopDBSync dbSyncEnv - -- update the syncParams to include new params - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv - startDBSync newEnv - -- there is a slight delay before flag is checked - threadDelay 6000000 - -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception - checkStillRuns dbSyncEnv - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configMigrateAndPruneRestart" pruneRestartMissingFlag :: IOManager -> [(Text, Text)] -> Assertion -pruneRestartMissingFlag ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +pruneRestartMissingFlag = do + withCustomConfig cmdLineArgs (Just configTxOutPruneForceTxIn) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 50 + assertBlockNoBackoff dbSyncEnv 50 + -- stop + stopDBSync dbSyncEnv + -- update the syncParams to include new params + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv + startDBSync newEnv + -- there is a slight delay before flag is checked + threadDelay 6000000 + -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception + checkStillRuns dbSyncEnv where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 50 - assertBlockNoBackoff dbSyncEnv 50 - -- stop - stopDBSync dbSyncEnv - -- update the syncParams to include new params - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv - startDBSync newEnv - -- there is a slight delay before flag is checked - threadDelay 6000000 - -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception - checkStillRuns dbSyncEnv - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "configPruneRestartMissingFlag" bootstrapRestartMissingFlag :: IOManager -> [(Text, Text)] -> Assertion -bootstrapRestartMissingFlag ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig babbageConfigDir args migrateTxOutPruneForceTxIn - withCustomConfig args (Just syncNodeConfig) babbageConfigDir testLabel action ioManager metadata +bootstrapRestartMissingFlag = do + withCustomConfig cmdLineArgs (Just configBootstrap) babbageConfigDir testLabel $ \interpreter mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + void $ forgeAndSubmitBlocks interpreter mockServer 50 + assertBlockNoBackoff dbSyncEnv 50 + assertTxOutCount dbSyncEnv 0 + -- stop + stopDBSync dbSyncEnv + -- update the syncParams to include new params + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv + startDBSync newEnv + -- there is a slight delay before flag is checked + threadDelay 6000000 + -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception + checkStillRuns dbSyncEnv where - action interpreter mockServer dbSyncEnv = do - startDBSync dbSyncEnv - void $ forgeAndSubmitBlocks interpreter mockServer 50 - assertBlockNoBackoff dbSyncEnv 50 - assertTxOutCount dbSyncEnv 0 - -- stop - stopDBSync dbSyncEnv - -- update the syncParams to include new params - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSyncEnv - startDBSync newEnv - -- there is a slight delay before flag is checked - threadDelay 6000000 - -- checkStillRuns uses `poll` due to this being inside Async and passes along our thrown exception - checkStillRuns dbSyncEnv - - args = initCommandLineArgs {claBootstrap = True} + cmdLineArgs = + initCommandLineArgs + { claBootstrap = True + } testLabel = "configBootstrapRestartMissingFlag" diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/JsonbInSchema.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/JsonbInSchema.hs index ab059defa..cbfb7ef18 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/JsonbInSchema.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/JsonbInSchema.hs @@ -17,20 +17,17 @@ import Test.Cardano.Db.Mock.Validate import Test.Tasty.HUnit (Assertion ()) configRemoveJsonbFromSchemaEnabled :: IOManager -> [(Text, Text)] -> Assertion -configRemoveJsonbFromSchemaEnabled ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig cfgDir args config - withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata +configRemoveJsonbFromSchemaEnabled = do + withCustomConfigAndDropDB args (Just config) cfgDir testLabel $ \_interpreter _mockServer dbSync -> do + startDBSync dbSync + threadDelay 7_000_000 + assertEqQuery + dbSync + DB.queryJsonbInSchemaExists + False + "There should be no jsonb data types in database if option is enabled" + checkStillRuns dbSync where - action _interpreter _mockServer dbSync = do - startDBSync dbSync - threadDelay 7_000_000 - assertEqQuery - dbSync - DB.queryJsonbInSchemaExists - False - "There should be no jsonb data types in database if option is enabled" - checkStillRuns dbSync - args = initCommandLineArgs {claFullMode = False} testLabel = "conwayConfigRemoveJsonbFromSchemaEnabled" @@ -41,11 +38,9 @@ configRemoveJsonbFromSchemaEnabled ioManager metadata = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig True}} configRemoveJsonbFromSchemaDisabled :: IOManager -> [(Text, Text)] -> Assertion -configRemoveJsonbFromSchemaDisabled ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig cfgDir args config - withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata - where - action _interpreter _mockServer dbSync = do +configRemoveJsonbFromSchemaDisabled = do + withCustomConfigAndDropDB args (Just config) cfgDir testLabel $ + \_interpreter _mockServer dbSync -> do startDBSync dbSync threadDelay 7_000_000 assertEqQuery @@ -54,48 +49,46 @@ configRemoveJsonbFromSchemaDisabled ioManager metadata = do True "There should be jsonb types in database if option is disabled" checkStillRuns dbSync - + where args = initCommandLineArgs {claFullMode = False} testLabel = "conwayConfigRemoveJsonbFromSchemaDisabled" cfgDir = conwayConfigDir + config :: SyncNodeConfig -> SyncNodeConfig config cfg = cfg {dncInsertOptions = (dncInsertOptions cfg) {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False}} configJsonbInSchemaShouldRemoveThenAdd :: IOManager -> [(Text, Text)] -> Assertion -configJsonbInSchemaShouldRemoveThenAdd ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig cfgDir args config - withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata +configJsonbInSchemaShouldRemoveThenAdd = + withCustomConfigAndDropDB args (Just config) cfgDir testLabel $ \_interpreter _mockServer dbSyncEnv -> do + startDBSync dbSyncEnv + threadDelay 7_000_000 + assertEqQuery + dbSyncEnv + DB.queryJsonbInSchemaExists + False + "There should be no jsonb types in database if option has been enabled" + stopDBSync dbSyncEnv + let newDbSyncEnv = + dbSyncEnv + { dbSyncConfig = + (dbSyncConfig dbSyncEnv) + { dncInsertOptions = + (dncInsertOptions $ dbSyncConfig dbSyncEnv) + { sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False + } + } + } + startDBSync newDbSyncEnv + threadDelay 7_000_000 + assertEqQuery + dbSyncEnv + DB.queryJsonbInSchemaExists + True + "There should be jsonb types in database if option has been disabled" + -- Expected to fail + checkStillRuns dbSyncEnv where - action _interpreter _mockServer dbSyncEnv = do - startDBSync dbSyncEnv - threadDelay 7_000_000 - assertEqQuery - dbSyncEnv - DB.queryJsonbInSchemaExists - False - "There should be no jsonb types in database if option has been enabled" - stopDBSync dbSyncEnv - let newDbSyncEnv = - dbSyncEnv - { dbSyncConfig = - (dbSyncConfig dbSyncEnv) - { dncInsertOptions = - (dncInsertOptions $ dbSyncConfig dbSyncEnv) - { sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False - } - } - } - startDBSync newDbSyncEnv - threadDelay 7_000_000 - assertEqQuery - dbSyncEnv - DB.queryJsonbInSchemaExists - True - "There should be jsonb types in database if option has been disabled" - -- Expected to fail - checkStillRuns dbSyncEnv - args = initCommandLineArgs {claFullMode = False} testLabel = "configJsonbInSchemaShouldRemoveThenAdd" cfgDir = conwayConfigDir diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/MigrateConsumedPruneTxOut.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/MigrateConsumedPruneTxOut.hs index e51ffeb67..e672c0417 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/MigrateConsumedPruneTxOut.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/MigrateConsumedPruneTxOut.hs @@ -36,29 +36,33 @@ import Test.Tasty.HUnit (Assertion ()) import Prelude () import qualified Prelude -migrateConsumeConfig :: SyncNodeConfig -> SyncNodeConfig -migrateConsumeConfig cfg = do +------------------------------------------------------------------------------ +-- Configs +------------------------------------------------------------------------------ +configConsumed :: SyncNodeConfig -> SyncNodeConfig +configConsumed cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutConsumed (ForceTxIn False)}} -migratePruneConfigForceTxIn :: SyncNodeConfig -> SyncNodeConfig -migratePruneConfigForceTxIn cfg = do +configPruneForceTxIn :: SyncNodeConfig -> SyncNodeConfig +configPruneForceTxIn cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn True)}} -migratePruneConfig :: SyncNodeConfig -> SyncNodeConfig -migratePruneConfig cfg = do +configPrune :: SyncNodeConfig -> SyncNodeConfig +configPrune cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutPrune (ForceTxIn False)}} -migrateBootstrapConfig :: SyncNodeConfig -> SyncNodeConfig -migrateBootstrapConfig cfg = do +configBootstrap :: SyncNodeConfig -> SyncNodeConfig +configBootstrap cfg = do cfg {dncInsertOptions = (dncInsertOptions cfg) {sioTxOut = TxOutBootstrap (ForceTxIn False)}} +------------------------------------------------------------------------------ +-- Tests +----------------------------------------------------------------------------- txConsumedColumnCheck :: IOManager -> [(Text, Text)] -> Assertion -txConsumedColumnCheck ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migrateConsumeConfig - let syncNodeConfig' = syncNodeConfig {dncEnableLogging = True} - withCustomConfig args (Just syncNodeConfig') conwayConfigDir testLabel action ioManager metadata - where - action interpreter mockServer dbSync = do +txConsumedColumnCheck = do + -- be mindful that you have to manually pass the ioManager + names + withCustomConfigAndDropDB cmdLineArgs (Just configConsumed) conwayConfigDir testLabel $ + \interpreter mockServer dbSync -> do startDBSync dbSync void $ @@ -71,386 +75,360 @@ txConsumedColumnCheck ioManager metadata = do DB.queryTxConsumedColumnExists True "missing consumed_by_tx_id column when tx-out = consumed" - - args = initCommandLineArgs + where + cmdLineArgs = initCommandLineArgs testLabel = "conwayTxConsumedColumnCheck" basicPrune :: IOManager -> [(Text, Text)] -> Assertion -basicPrune ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +basicPrune = do + withCustomConfig args (Just configPruneForceTxIn) cfgDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Add some blocks + blks <- forgeAndSubmitBlocks interpreter mockServer 50 + + -- Add blocks with transactions + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0 + + -- Check tx-out count before pruning + assertBlockNoBackoff dbSync (fullBlockSize blks) + assertEqQuery dbSync DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" + + blks' <- forgeAndSubmitBlocks interpreter mockServer 48 + assertBlockNoBackoff dbSync (fullBlockSize $ blks <> blks') + + -- Check that tx_out was pruned + assertEqQuery dbSync DB.queryTxOutCount 12 "the pruning didn't work correctly as the tx-out count is incorrect" + -- Check unspent tx + assertUnspentTx dbSync where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Add some blocks - blks <- forgeAndSubmitBlocks interpreter mockServer 50 - - -- Add blocks with transactions - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0 - - -- Check tx-out count before pruning - assertBlockNoBackoff dbSync (fullBlockSize blks) - assertEqQuery dbSync DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" - - blks' <- forgeAndSubmitBlocks interpreter mockServer 48 - assertBlockNoBackoff dbSync (fullBlockSize $ blks <> blks') - - -- Check that tx_out was pruned - assertEqQuery dbSync DB.queryTxOutCount 12 "the pruning didn't work correctly as the tx-out count is incorrect" - -- Check unspent tx - assertUnspentTx dbSync - args = initCommandLineArgs testLabel = "conwayConfigPrune" fullBlockSize b = fromIntegral $ length b + 2 + cfgDir = conwayConfigDir pruneWithSimpleRollback :: IOManager -> [(Text, Text)] -> Assertion -pruneWithSimpleRollback ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruneWithSimpleRollback = + withCustomConfig cmdLineArgs (Just configPruneForceTxIn) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + -- Forge some blocks + blk0 <- forgeNext interpreter mockBlock0 + blk1 <- forgeNext interpreter mockBlock1 + atomically $ addBlock mockServer blk0 + + startDBSync dbSync + atomically $ addBlock mockServer blk1 + + -- Create some payment transactions + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0 + assertEqQuery dbSync DB.queryTxOutCount 14 "" + + -- Submit some blocks + blks <- forgeAndSubmitBlocks interpreter mockServer 96 + assertBlockNoBackoff dbSync (fullBlockSize blks) + assertEqQuery dbSync DB.queryTxOutCount 12 "the txOut count is incorrect" + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" + assertUnspentTx dbSync + + -- Rollback + rollbackTo interpreter mockServer (blockPoint blk1) + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" + assertBlockNoBackoff dbSync (fullBlockSize blks) where - action interpreter mockServer dbSync = do - -- Forge some blocks - blk0 <- forgeNext interpreter mockBlock0 - blk1 <- forgeNext interpreter mockBlock1 - atomically $ addBlock mockServer blk0 - - startDBSync dbSync - atomically $ addBlock mockServer blk1 - - -- Create some payment transactions - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0 - assertEqQuery dbSync DB.queryTxOutCount 14 "" - - -- Submit some blocks - blks <- forgeAndSubmitBlocks interpreter mockServer 96 - assertBlockNoBackoff dbSync (fullBlockSize blks) - assertEqQuery dbSync DB.queryTxOutCount 12 "the txOut count is incorrect" - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" - assertUnspentTx dbSync - - -- Rollback - rollbackTo interpreter mockServer (blockPoint blk1) - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" - assertBlockNoBackoff dbSync (fullBlockSize blks) - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneSimpleRollback" fullBlockSize b = fromIntegral $ length b + 4 pruneWithFullTxRollback :: IOManager -> [(Text, Text)] -> Assertion -pruneWithFullTxRollback ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruneWithFullTxRollback = + withCustomConfig cmdLineArgs (Just configPruneForceTxIn) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + -- Forge a block + blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Add some transactions + void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Conway.mkFullTx 0 100 st + tx1 <- Conway.mkFullTx 1 200 st + pure [tx0, tx1] + + -- Verify tx_out was pruned + assertBlockNoBackoff dbSync 2 + assertTxCount dbSync 13 + assertUnspentTx dbSync + assertEqQuery dbSync DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" + + -- Rollback + rollbackTo interpreter mockServer $ blockPoint blk0 + -- Add more transactions + void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \st -> do + tx0 <- Conway.mkFullTx 0 100 st + tx1 <- Conway.mkFullTx 1 200 st + tx2 <- Conway.mkFullTx 2 200 st + pure [tx1, tx2, tx0] + + -- Verify tx_out was pruned again + assertBlockNoBackoff dbSync 2 + assertTxCount dbSync 14 + assertEqQuery dbSync DB.queryTxOutCount 16 "new epoch didn't prune tx_out column that are null" + assertUnspentTx dbSync where - action interpreter mockServer dbSync = do - startDBSync dbSync - -- Forge a block - blk0 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Add some transactions - void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Conway.mkFullTx 0 100 st - tx1 <- Conway.mkFullTx 1 200 st - pure [tx0, tx1] - - -- Verify tx_out was pruned - assertBlockNoBackoff dbSync 2 - assertTxCount dbSync 13 - assertUnspentTx dbSync - assertEqQuery dbSync DB.queryTxOutCount 14 "new epoch didn't prune tx_out column that are null" - - -- Rollback - rollbackTo interpreter mockServer $ blockPoint blk0 - -- Add more transactions - void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \st -> do - tx0 <- Conway.mkFullTx 0 100 st - tx1 <- Conway.mkFullTx 1 200 st - tx2 <- Conway.mkFullTx 2 200 st - pure [tx1, tx2, tx0] - - -- Verify tx_out was pruned again - assertBlockNoBackoff dbSync 2 - assertTxCount dbSync 14 - assertEqQuery dbSync DB.queryTxOutCount 16 "new epoch didn't prune tx_out column that are null" - assertUnspentTx dbSync - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneOnFullRollback" -- The transactions in the last `2 * securityParam` blocks should not be pruned pruningShouldKeepSomeTx :: IOManager -> [(Text, Text)] -> Assertion -pruningShouldKeepSomeTx ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfig - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruningShouldKeepSomeTx = do + withCustomConfig cmdLineArgs (Just configPrune) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + blk1 <- forgeAndSubmitBlocks interpreter mockServer 80 + -- These two blocks/transactions will fall within the last (2 * securityParam) 20 + -- blocks so should not be pruned + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 10_000 0 + blk2 <- forgeAndSubmitBlocks interpreter mockServer 18 + -- Verify the two transactions above weren't pruned + assertBlockNoBackoff dbSync (fromIntegral $ length (blk1 <> blk2) + 2) + assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count after prune" + + -- Add more blocks + blk3 <- forgeAndSubmitBlocks interpreter mockServer 110 + -- Verify everything has been pruned + assertBlockNoBackoff dbSync (fromIntegral $ length (blk1 <> blk2 <> blk3) + 2) + assertTxInCount dbSync 0 + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Forge some blocks - blk1 <- forgeAndSubmitBlocks interpreter mockServer 80 - -- These two blocks/transactions will fall within the last (2 * securityParam) 20 - -- blocks so should not be pruned - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 10_000 0 - blk2 <- forgeAndSubmitBlocks interpreter mockServer 18 - -- Verify the two transactions above weren't pruned - assertBlockNoBackoff dbSync (fromIntegral $ length (blk1 <> blk2) + 2) - assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count after prune" - - -- Add more blocks - blk3 <- forgeAndSubmitBlocks interpreter mockServer 110 - -- Verify everything has been pruned - assertBlockNoBackoff dbSync (fromIntegral $ length (blk1 <> blk2 <> blk3) + 2) - assertTxInCount dbSync 0 - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after prune" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneCorrectAmount" pruneAndRollBackOneBlock :: IOManager -> [(Text, Text)] -> Assertion -pruneAndRollBackOneBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruneAndRollBackOneBlock = + withCustomConfig cmdLineArgs (Just configPruneForceTxIn) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 98 + -- These transactions will fall within the last (2 * securityParam) 20 + -- blocks so should not be pruned + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 + -- Create a block to rollback to + blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + state' <- getConwayLedgerState interpreter + -- Add some more blocks + let tx1 = Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 500 0 state' + void $ withConwayFindLeaderAndSubmit interpreter mockServer (\_ -> sequence [tx1]) + -- Verify the last 2 transactions weren't pruned + assertBlockNoBackoff dbSync 101 + assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" + + rollbackTo interpreter mockServer (blockPoint blk100) + + -- Add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Verify the transactions were removed in the rollback + assertBlockNoBackoff dbSync 101 + assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" + + -- Trigger a prune + void $ forgeAndSubmitBlocks interpreter mockServer 102 + -- Verify everything was pruned + assertBlockNoBackoff dbSync 203 + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" where - action interpreter mockServer dbSync = do - startDBSync dbSync - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 98 - -- These transactions will fall within the last (2 * securityParam) 20 - -- blocks so should not be pruned - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 - -- Create a block to rollback to - blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - state' <- getConwayLedgerState interpreter - -- Add some more blocks - let tx1 = Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 500 0 state' - void $ withConwayFindLeaderAndSubmit interpreter mockServer (\_ -> sequence [tx1]) - -- Verify the last 2 transactions weren't pruned - assertBlockNoBackoff dbSync 101 - assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" - - rollbackTo interpreter mockServer (blockPoint blk100) - - -- Add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Verify the transactions were removed in the rollback - assertBlockNoBackoff dbSync 101 - assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - - -- Trigger a prune - void $ forgeAndSubmitBlocks interpreter mockServer 102 - -- Verify everything was pruned - assertBlockNoBackoff dbSync 203 - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId count after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneAndRollBack" noPruneAndRollBack :: IOManager -> [(Text, Text)] -> Assertion -noPruneAndRollBack ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migrateConsumeConfig - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +noPruneAndRollBack = + withCustomConfig cmdLineArgs (Just configConsumed) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 98 + -- Add a block with transactions + void $ + withConwayFindLeaderAndSubmitTx interpreter mockServer $ + Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 + -- Create a block to rollback to + blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Add some more blocks + state' <- getConwayLedgerState interpreter + let tx1 = Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 500 0 state' + void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \_ -> sequence [tx1] + + -- Verify the transactions weren't pruned + assertBlockNoBackoff dbSync 101 + assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" + + rollbackTo interpreter mockServer (blockPoint blk100) + + -- Add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Verify transactions were removed + assertBlockNoBackoff dbSync 101 + assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" + + -- Add some more blocks + void $ forgeAndSubmitBlocks interpreter mockServer 102 + -- Verify nothing has been pruned + assertBlockNoBackoff dbSync 203 + assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" where - action interpreter mockServer dbSync = do - startDBSync dbSync - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 98 - -- Add a block with transactions - void $ - withConwayFindLeaderAndSubmitTx interpreter mockServer $ - Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0 - -- Create a block to rollback to - blk100 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Add some more blocks - state' <- getConwayLedgerState interpreter - let tx1 = Conway.mkPaymentTx (UTxOIndex 2) (UTxOIndex 3) 10_000 500 0 state' - void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \_ -> sequence [tx1] - - -- Verify the transactions weren't pruned - assertBlockNoBackoff dbSync 101 - assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId count before rollback" - - rollbackTo interpreter mockServer (blockPoint blk100) - - -- Add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Verify transactions were removed - assertBlockNoBackoff dbSync 101 - assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - - -- Add some more blocks - void $ forgeAndSubmitBlocks interpreter mockServer 102 - -- Verify nothing has been pruned - assertBlockNoBackoff dbSync 203 - assertEqQuery dbSync DB.queryTxOutConsumedCount 1 "Unexpected TxOutConsumedByTxId count after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigNoPruneAndRollBack" pruneSameBlock :: IOManager -> [(Text, Text)] -> Assertion -pruneSameBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruneSameBlock = + withCustomConfig cmdLineArgs (Just configPruneForceTxIn) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 76 + blk77 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Add a block with transactions + void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \state' -> do + tx0 <- Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20_000 20_000 0 state' + let utxo0 = Prelude.head (Conway.mkUTxOConway tx0) + tx1 <- Conway.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10_000 500 0 state' + pure [tx0, tx1] + -- Verify the transactions weren't pruned + assertBlockNoBackoff dbSync 78 + assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId before rollback" + + -- Trigger a prune + void $ forgeAndSubmitBlocks interpreter mockServer 22 + -- Verify the transactions were pruned + assertBlockNoBackoff dbSync 100 + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after prune" + + rollbackTo interpreter mockServer (blockPoint blk77) + + -- Add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Verify the transactions were pruned again + assertBlockNoBackoff dbSync 78 + assertTxInCount dbSync 0 + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" where - action interpreter mockServer dbSync = do - startDBSync dbSync - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 76 - blk77 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Add a block with transactions - void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \state' -> do - tx0 <- Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20_000 20_000 0 state' - let utxo0 = Prelude.head (Conway.mkUTxOConway tx0) - tx1 <- Conway.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10_000 500 0 state' - pure [tx0, tx1] - -- Verify the transactions weren't pruned - assertBlockNoBackoff dbSync 78 - assertEqQuery dbSync DB.queryTxOutConsumedCount 2 "Unexpected TxOutConsumedByTxId before rollback" - - -- Trigger a prune - void $ forgeAndSubmitBlocks interpreter mockServer 22 - -- Verify the transactions were pruned - assertBlockNoBackoff dbSync 100 - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after prune" - - rollbackTo interpreter mockServer (blockPoint blk77) - - -- Add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Verify the transactions were pruned again - assertBlockNoBackoff dbSync 78 - assertTxInCount dbSync 0 - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneSameBlock" noPruneSameBlock :: IOManager -> [(Text, Text)] -> Assertion -noPruneSameBlock ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migrateConsumeConfig - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +noPruneSameBlock = + withCustomConfig cmdLineArgs (Just configConsumed) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 96 + blk97 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Add a block with transactions + void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \state' -> do + tx0 <- Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20_000 20_000 0 state' + let utxo0 = Prelude.head (Conway.mkUTxOConway tx0) + tx1 <- Conway.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10_000 500 0 state' + pure [tx0, tx1] + -- Add some more empty blocks + void $ forgeAndSubmitBlocks interpreter mockServer 2 + -- Verify the blocks exist + assertBlockNoBackoff dbSync 100 + + rollbackTo interpreter mockServer (blockPoint blk97) + + -- Verify we haven't pruned anything yet + assertBlockNoBackoff dbSync 100 + -- Add an empty block + void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] + -- Verify everything was pruned + assertBlockNoBackoff dbSync 98 + assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 96 - blk97 <- forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Add a block with transactions - void $ withConwayFindLeaderAndSubmit interpreter mockServer $ \state' -> do - tx0 <- Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 20_000 20_000 0 state' - let utxo0 = Prelude.head (Conway.mkUTxOConway tx0) - tx1 <- Conway.mkPaymentTx (UTxOPair utxo0) (UTxOIndex 2) 10_000 500 0 state' - pure [tx0, tx1] - -- Add some more empty blocks - void $ forgeAndSubmitBlocks interpreter mockServer 2 - -- Verify the blocks exist - assertBlockNoBackoff dbSync 100 - - rollbackTo interpreter mockServer (blockPoint blk97) - - -- Verify we haven't pruned anything yet - assertBlockNoBackoff dbSync 100 - -- Add an empty block - void $ forgeNextFindLeaderAndSubmit interpreter mockServer [] - -- Verify everything was pruned - assertBlockNoBackoff dbSync 98 - assertEqQuery dbSync DB.queryTxOutConsumedCount 0 "Unexpected TxOutConsumedByTxId after rollback" - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigNoPruneSameBlock" migrateAndPruneRestart :: IOManager -> [(Text, Text)] -> Assertion -migrateAndPruneRestart ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migrateConsumeConfig - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +migrateAndPruneRestart = + withCustomConfig cmdLineArgs (Just configConsumed) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 50 + -- Wait for them to sync + assertBlockNoBackoff dbSync 50 + + stopDBSync dbSync + + -- Start without tx-out=consumed + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync + startDBSync newEnv + -- There is a slight delay before the flag is checked + threadDelay 6_000_000 + -- Expected to fail + checkStillRuns dbSync where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 50 - -- Wait for them to sync - assertBlockNoBackoff dbSync 50 - - stopDBSync dbSync - - -- Start without tx-out=consumed - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync - startDBSync newEnv - -- There is a slight delay before the flag is checked - threadDelay 6_000_000 - -- Expected to fail - checkStillRuns dbSync - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigMigrateAndPruneRestart" pruneRestartMissingFlag :: IOManager -> [(Text, Text)] -> Assertion -pruneRestartMissingFlag ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migratePruneConfigForceTxIn - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +pruneRestartMissingFlag = + withCustomConfig cmdLineArgs (Just configPruneForceTxIn) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 50 + -- Wait for them to sync + assertBlockNoBackoff dbSync 50 + + stopDBSync dbSync + + -- Start without tx-out=prune + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync + startDBSync newEnv + -- There is a slight delay before the flag is checked + threadDelay 6_000_000 + -- Expected to fail + checkStillRuns dbSync where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 50 - -- Wait for them to sync - assertBlockNoBackoff dbSync 50 - - stopDBSync dbSync - - -- Start without tx-out=prune - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync - startDBSync newEnv - -- There is a slight delay before the flag is checked - threadDelay 6_000_000 - -- Expected to fail - checkStillRuns dbSync - - args = initCommandLineArgs + cmdLineArgs = initCommandLineArgs testLabel = "conwayConfigPruneRestartMissingFlag" bootstrapRestartMissingFlag :: IOManager -> [(Text, Text)] -> Assertion -bootstrapRestartMissingFlag ioManager metadata = do - syncNodeConfig <- mkCustomSyncNodeConfig conwayConfigDir args migrateBootstrapConfig - withCustomConfig args (Just syncNodeConfig) conwayConfigDir testLabel action ioManager metadata +bootstrapRestartMissingFlag = + withCustomConfig cmdLineArgs (Just configBootstrap) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + startDBSync dbSync + + -- Forge some blocks + void $ forgeAndSubmitBlocks interpreter mockServer 50 + -- Wait for it to sync + assertBlockNoBackoff dbSync 50 + assertTxOutCount dbSync 0 + + stopDBSync dbSync + -- Start without tx-out=bootstrap + newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync + startDBSync newEnv + -- There is a slight delay befor the flag is checked + threadDelay 6_000_000 + -- Expected to fail + checkStillRuns dbSync where - action interpreter mockServer dbSync = do - startDBSync dbSync - - -- Forge some blocks - void $ forgeAndSubmitBlocks interpreter mockServer 50 - -- Wait for it to sync - assertBlockNoBackoff dbSync 50 - assertTxOutCount dbSync 0 - - stopDBSync dbSync - -- Start without tx-out=bootstrap - newEnv <- replaceConfigFile "test-db-sync-config.json" dbSync - startDBSync newEnv - -- There is a slight delay before the flag is checked - threadDelay 6_000_000 - -- Expected to fail - checkStillRuns dbSync - - args = initCommandLineArgs {claBootstrap = True} + cmdLineArgs = + initCommandLineArgs + { claBootstrap = True + } testLabel = "conwayConfigBootstrapRestartMissingFlag" diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Plutus.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Plutus.hs index 8cd95e76c..ebd554a40 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Plutus.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Plutus.hs @@ -37,6 +37,7 @@ module Test.Cardano.Db.Mock.Unit.Conway.Plutus ( import Cardano.Crypto.Hash.Class (hashToBytes) import qualified Cardano.Db as DB +import Cardano.DbSync.Config.Types import Cardano.DbSync.Era.Shelley.Generic.Util (renderAddress) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..), PolicyID (..)) @@ -53,12 +54,34 @@ import qualified Data.Map as Map import Data.Maybe.Strict (StrictMaybe (..)) import Ouroboros.Consensus.Shelley.Eras (StandardConway ()) import Ouroboros.Network.Block (genesisPoint) -import Test.Cardano.Db.Mock.Config +import Test.Cardano.Db.Mock.Config ( + CommandLineArgs (..), + conwayConfigDir, + initCommandLineArgs, + startDBSync, + withCustomConfig, + withFullConfig, + withFullConfigAndDropDB, + ) import qualified Test.Cardano.Db.Mock.UnifiedApi as Api import Test.Cardano.Db.Mock.Validate import Test.Tasty.HUnit (Assertion ()) import Prelude (head, tail, (!!)) +------------------------------------------------------------------------------ +-- Custom Configs +------------------------------------------------------------------------------ +configPlutusDisable :: SyncNodeConfig -> SyncNodeConfig +configPlutusDisable cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioPlutus = PlutusDisable}} + +configMultiAssetsDisable :: SyncNodeConfig -> SyncNodeConfig +configMultiAssetsDisable cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMultiAsset = MultiAssetDisable}} + +------------------------------------------------------------------------------ +-- Tests +------------------------------------------------------------------------------ simpleScript :: IOManager -> [(Text, Text)] -> Assertion simpleScript = withFullConfigAndDropDB conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do @@ -133,7 +156,7 @@ unlockScriptSameBlock = unlockScriptNoPlutus :: IOManager -> [(Text, Text)] -> Assertion unlockScriptNoPlutus = - withCustomConfig args Nothing conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + withCustomConfig args (Just configPlutusDisable) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do startDBSync dbSync -- Forge a block with stake credentials @@ -163,8 +186,7 @@ unlockScriptNoPlutus = where args = initCommandLineArgs - { claConfigFilename = "test-db-sync-config-no-plutus.json" - , claFullMode = False + { claFullMode = False } testLabel = "conwayConfigPlutusDisbaled" @@ -769,7 +791,7 @@ swapMultiAssets = swapMultiAssetsDisabled :: IOManager -> [(Text, Text)] -> Assertion swapMultiAssetsDisabled = - withCustomConfig args Nothing cfgDir testLabel $ \interpreter mockServer dbSync -> do + withCustomConfig args (Just configMultiAssetsDisable) cfgDir testLabel $ \interpreter mockServer dbSync -> do startDBSync dbSync -- Forge a block with multiple multi-asset scripts @@ -800,8 +822,7 @@ swapMultiAssetsDisabled = where args = initCommandLineArgs - { claConfigFilename = "test-db-sync-config-no-multi-assets.json" - , claFullMode = False + { claFullMode = False } testLabel = "conwayConfigMultiAssetsDisabled" diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Stake.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Stake.hs index ab9dce6c7..4ee18e599 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Stake.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Stake.hs @@ -21,6 +21,7 @@ module Test.Cardano.Db.Mock.Unit.Conway.Stake ( ) where import qualified Cardano.Db as DB +import Cardano.DbSync.Config.Types import Cardano.Ledger.BaseTypes (CertIx (..), TxIx (..)) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Credential (Ptr (..)) @@ -416,7 +417,7 @@ registerStakeCreds = do registerStakeCredsNoShelley :: IOManager -> [(Text, Text)] -> Assertion registerStakeCredsNoShelley = do - withCustomConfig args Nothing cfgDir testLabel $ \interpreter mockServer dbSync -> do + withCustomConfig args (Just configMultiAssetsDisable) cfgDir testLabel $ \interpreter mockServer dbSync -> do startDBSync dbSync -- These should not be saved when shelley is disabled @@ -431,8 +432,11 @@ registerStakeCredsNoShelley = do where args = initCommandLineArgs - { claConfigFilename = "test-db-sync-config-no-shelley.json" - , claFullMode = False + { claFullMode = False } testLabel = "conwayConfigShelleyDisabled" cfgDir = conwayConfigDir + + configMultiAssetsDisable :: SyncNodeConfig -> SyncNodeConfig + configMultiAssetsDisable cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioShelley = ShelleyDisable}} diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Tx.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Tx.hs index 0079f1e8d..8b7f1f439 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Tx.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Tx.hs @@ -17,7 +17,7 @@ module Test.Cardano.Db.Mock.Unit.Conway.Tx ( ) where import Cardano.DbSync.Config (SyncNodeConfig (..)) -import Cardano.DbSync.Config.Types (MetadataConfig (..), SyncInsertOptions (..)) +import Cardano.DbSync.Config.Types (LedgerInsertConfig (..), MetadataConfig (..), SyncInsertOptions (..)) import Cardano.Ledger.Shelley.TxAuxData (Metadatum (..)) import Cardano.Mock.ChainSync.Server (IOManager ()) import qualified Cardano.Mock.Forging.Tx.Conway as Conway @@ -67,7 +67,7 @@ addSimpleTxShelley = addSimpleTxNoLedger :: IOManager -> [(Text, Text)] -> Assertion addSimpleTxNoLedger = do - withCustomConfig args Nothing conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do + withCustomConfig args (Just configLedgerIgnore) conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do -- Forge a block void $ UnifiedApi.withConwayFindLeaderAndSubmitTx interpreter mockServer $ @@ -82,11 +82,14 @@ addSimpleTxNoLedger = do where args = initCommandLineArgs - { claConfigFilename = "test-db-sync-config-no-ledger.json" - , claFullMode = False + { claFullMode = False } testLabel = "conwayConfigLedgerDisabled" + configLedgerIgnore :: SyncNodeConfig -> SyncNodeConfig + configLedgerIgnore cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioLedger = LedgerIgnore}} + addTxTreasuryDonation :: IOManager -> [(Text, Text)] -> Assertion addTxTreasuryDonation = withFullConfig conwayConfigDir testLabel $ \interpreter mockServer dbSync -> do @@ -126,11 +129,9 @@ consumeSameBlock = testLabel = "conwayConsumeSameBlock" addTxMetadata :: IOManager -> [(Text, Text)] -> Assertion -addTxMetadata ioManager metadata = do - syncNodeConfig <- mksNodeConfig - withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata - where - action = \interpreter mockServer dbSync -> do +addTxMetadata = do + withCustomConfigAndDropDB args (Just configMetadataEnable) cfgDir testLabel $ + \interpreter mockServer dbSync -> do startDBSync dbSync -- Add blocks with transactions void $ @@ -143,24 +144,19 @@ addTxMetadata ioManager metadata = do assertBlockNoBackoff dbSync 1 -- Should have tx metadata assertEqBackoff dbSync queryTxMetadataCount 2 [] "Expected tx metadata" - + where args = initCommandLineArgs {claFullMode = False} testLabel = "conwayConfigMetadataEnabled" cfgDir = conwayConfigDir - mksNodeConfig :: IO SyncNodeConfig - mksNodeConfig = do - initConfigFile <- mkSyncNodeConfig cfgDir args - let dncInsertOptions' = dncInsertOptions initConfigFile - pure $ - initConfigFile - { dncInsertOptions = dncInsertOptions' {sioMetadata = MetadataEnable} - } + configMetadataEnable :: SyncNodeConfig -> SyncNodeConfig + configMetadataEnable cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataEnable}} addTxMetadataWhitelist :: IOManager -> [(Text, Text)] -> Assertion addTxMetadataWhitelist = do - withCustomConfigAndDropDB args Nothing cfgDir testLabel $ \interpreter mockServer dbSync -> do + withCustomConfigAndDropDB args (Just configMetadataKeys) cfgDir testLabel $ \interpreter mockServer dbSync -> do startDBSync dbSync -- Add blocks with transactions @@ -177,18 +173,19 @@ addTxMetadataWhitelist = do where args = initCommandLineArgs - { claConfigFilename = "test-db-sync-config-keep-metadata.json" - , claFullMode = False + { claFullMode = False } testLabel = "conwayConfigMetadataKeep" cfgDir = conwayConfigDir + configMetadataKeys :: SyncNodeConfig -> SyncNodeConfig + configMetadataKeys cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataKeys $ 1 :| []}} + addTxMetadataDisabled :: IOManager -> [(Text, Text)] -> Assertion -addTxMetadataDisabled ioManager metadata = do - syncNodeConfig <- mksNodeConfig - withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata - where - action = \interpreter mockServer dbSync -> do +addTxMetadataDisabled = do + withCustomConfigAndDropDB args (Just configMetadataDisable) cfgDir testLabel $ + \interpreter mockServer dbSync -> do startDBSync dbSync -- Add blocks with transactions void $ @@ -201,17 +198,12 @@ addTxMetadataDisabled ioManager metadata = do assertBlockNoBackoff dbSync 1 -- Should have tx metadata assertEqBackoff dbSync queryTxMetadataCount 0 [] "Expected tx metadata" - + where args = initCommandLineArgs {claFullMode = False} testLabel = "conwayConfigMetadataDisabled" cfgDir = conwayConfigDir - mksNodeConfig :: IO SyncNodeConfig - mksNodeConfig = do - initConfigFile <- mkSyncNodeConfig cfgDir args - let dncInsertOptions' = dncInsertOptions initConfigFile - pure $ - initConfigFile - { dncInsertOptions = dncInsertOptions' {sioMetadata = MetadataDisable} - } + configMetadataDisable :: SyncNodeConfig -> SyncNodeConfig + configMetadataDisable cfg = do + cfg {dncInsertOptions = (dncInsertOptions cfg) {sioMetadata = MetadataDisable}} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-keep-metadata.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-keep-metadata.json deleted file mode 100644 index 670309b67..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-keep-metadata.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "metadata": { - "enable": true, - "keys": [1] - } - } -} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-ledger.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-ledger.json deleted file mode 100644 index 9a183b7df..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-ledger.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "ledger": "ignore" - } -} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-metadata.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-metadata.json deleted file mode 100644 index 730e364de..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-metadata.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "metadata": { - "enable": false - } - } -} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-multi-assets.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-multi-assets.json deleted file mode 100644 index ef96054a6..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-multi-assets.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "multi_asset": { - "enable": false - } - } -} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-plutus.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-plutus.json deleted file mode 100644 index f8fbe0c44..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-plutus.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "plutus": { - "enable": false - } - } -} diff --git a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-shelley.json b/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-shelley.json deleted file mode 100644 index 08b8a98e0..000000000 --- a/cardano-chain-gen/test/testfiles/config-conway/test-db-sync-config-no-shelley.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "EnableLogMetrics": false, - "EnableLogging": true, - "NetworkName": "testing", - "NodeConfigFile": "test-config.json", - "PrometheusPort": 8080, - "RequiresNetworkMagic": "RequiresMagic", - "defaultBackends": [ - "KatipBK" - ], - "defaultScribes": [ - [ - "StdoutSK", - "stdout" - ] - ], - "minSeverity": "Info", - "options": { - "cfokey": { - "value": "Release-1.0.0" - }, - "mapBackends": {}, - "mapSeverity": { - "db-sync-node": "Info", - "db-sync-node.Mux": "Error", - "db-sync-node.Subscription": "Error" - }, - "mapSubtrace": { - "#ekgview": { - "contents": [ - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": ".monoclock.basic.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "cardano.epoch-validation.benchmark", - "tag": "Contains" - }, - [ - { - "contents": "diff.RTS.cpuNs.timed.", - "tag": "Contains" - } - ] - ], - [ - { - "contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark", - "tag": "StartsWith" - }, - [ - { - "contents": "diff.RTS.gcNum.timed.", - "tag": "Contains" - } - ] - ] - ], - "subtrace": "FilterTrace" - }, - "#messagecounters.aggregation": { - "subtrace": "NoTrace" - }, - "#messagecounters.ekgview": { - "subtrace": "NoTrace" - }, - "#messagecounters.katip": { - "subtrace": "NoTrace" - }, - "#messagecounters.monitoring": { - "subtrace": "NoTrace" - }, - "#messagecounters.switchboard": { - "subtrace": "NoTrace" - }, - "benchmark": { - "contents": [ - "GhcRtsStats", - "MonotonicClock" - ], - "subtrace": "ObservableTrace" - }, - "cardano.epoch-validation.utxo-stats": { - "subtrace": "NoTrace" - } - } - }, - "rotation": { - "rpKeepFilesNum": 10, - "rpLogLimitBytes": 5000000, - "rpMaxAgeHours": 24 - }, - "setupBackends": [ - "AggregationBK", - "KatipBK" - ], - "setupScribes": [ - { - "scFormat": "ScText", - "scKind": "StdoutSK", - "scName": "stdout", - "scRotation": null - } - ], - "insert_options": { - "shelley": { - "enable": false - } - } -}