@@ -34,8 +34,8 @@ import Cardano.Mock.Forging.Types (PoolIndex (..), StakeIndex (..), UTxOIndex (.
3434import Cardano.Prelude
3535import Data.Maybe.Strict (StrictMaybe (.. ))
3636import Ouroboros.Network.Block (blockPoint )
37- import Test.Cardano.Db.Mock.Config
38- import Test.Cardano.Db.Mock.Examples ( mockBlock0 , mockBlock1 , mockBlock2 )
37+ import Test.Cardano.Db.Mock.Config ( claFullMode , configPoolStats , conwayConfigDir , initCommandLineArgs , queryDBSync , startDBSync , stopDBSync , withCustomConfigDropDB , withFullConfigDropDB )
38+ import Test.Cardano.Db.Mock.Examples
3939import Test.Cardano.Db.Mock.UnifiedApi
4040import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff , assertEqQuery , assertTxCount )
4141import Test.Tasty.HUnit (Assertion (), assertBool , assertEqual )
@@ -134,9 +134,9 @@ lazyRollback =
134134 rollbackTo interpreter mockServer (blockPoint lastBlk)
135135
136136 -- Here we create the fork
137- void
138- $ withConwayFindLeaderAndSubmitTx interpreter mockServer
139- $ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
137+ void $
138+ withConwayFindLeaderAndSubmitTx interpreter mockServer $
139+ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
140140 -- Add some more blocks
141141 void $ forgeAndSubmitBlocks interpreter mockServer 40
142142 -- Verify the new block count
@@ -162,9 +162,9 @@ lazyRollbackRestart =
162162 startDBSync dbSync
163163
164164 -- Here we create the fork
165- void
166- $ withConwayFindLeaderAndSubmitTx interpreter mockServer
167- $ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
165+ void $
166+ withConwayFindLeaderAndSubmitTx interpreter mockServer $
167+ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
168168 -- Add some more blocks
169169 void $ forgeAndSubmitBlocks interpreter mockServer 30
170170 -- Verify the new block count
@@ -188,18 +188,18 @@ doubleRollback =
188188 -- Rollback to second block point
189189 rollbackTo interpreter mockServer (blockPoint lastBlk2)
190190 -- Here we create a fork
191- void
192- $ withConwayFindLeaderAndSubmitTx interpreter mockServer
193- $ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
191+ void $
192+ withConwayFindLeaderAndSubmitTx interpreter mockServer $
193+ Conway. mkSimpleDCertTx [(StakeIndexNew 1 , Conway. mkRegTxCert SNothing )]
194194 -- Add some more blocks
195195 void $ forgeAndSubmitBlocks interpreter mockServer 50
196196
197197 -- Rollback to first block point
198198 rollbackTo interpreter mockServer (blockPoint lastBlk1)
199199 -- Create another fork
200- void
201- $ withConwayFindLeaderAndSubmitTx interpreter mockServer
202- $ Conway. mkSimpleDCertTx [(StakeIndexNew 0 , Conway. mkRegTxCert $ SJust (Coin 100 ))]
200+ void $
201+ withConwayFindLeaderAndSubmitTx interpreter mockServer $
202+ Conway. mkSimpleDCertTx [(StakeIndexNew 0 , Conway. mkRegTxCert $ SJust (Coin 100 ))]
203203 -- Add some more blocks
204204 void $ forgeAndSubmitBlocks interpreter mockServer 50
205205 -- Wait for it to sync
@@ -379,8 +379,8 @@ drepDistrRollback =
379379
380380poolStatBasicTest :: IOManager -> [(Text , Text )] -> Assertion
381381poolStatBasicTest =
382- withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel
383- $ \ interpreter mockServer dbSync -> do
382+ withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel $
383+ \ interpreter mockServer dbSync -> do
384384 startDBSync dbSync
385385
386386 -- Test basic pool stats functionality
@@ -391,10 +391,10 @@ poolStatBasicTest =
391391 void $ forgeAndSubmitBlocks interpreter mockServer 200
392392 assertBlockNoBackoff dbSync 201
393393
394- poolStatCount <- queryDBSync dbSync Db . queryPoolStatCount
394+ poolStatCount <- queryDBSync dbSync DB . queryPoolStatCount
395395
396396 -- Verify pool stats are created and no duplicates exist
397- duplicateCount <- queryDBSync dbSync Db . queryPoolStatDuplicates
397+ duplicateCount <- queryDBSync dbSync DB . queryPoolStatDuplicates
398398 assertEqual " Should have no duplicate pool stats" 0 duplicateCount
399399 assertBool " Should have some pool stats" (poolStatCount > 0 )
400400 where
@@ -403,8 +403,8 @@ poolStatBasicTest =
403403
404404poolStatRollbackNoDuplicates :: IOManager -> [(Text , Text )] -> Assertion
405405poolStatRollbackNoDuplicates =
406- withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel
407- $ \ interpreter mockServer dbSync -> do
406+ withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel $
407+ \ interpreter mockServer dbSync -> do
408408 startDBSync dbSync
409409
410410 -- Simple setup: create some blocks with pool stats
@@ -429,16 +429,16 @@ poolStatRollbackNoDuplicates =
429429 assertBlockNoBackoff dbSync 351 -- Should stay same due to rollbackExpand commentComment on line R349ResolvedCode has comments. Press enter to view.
430430
431431 -- The main test: no duplicates after rollback + re-sync
432- duplicateCount <- queryDBSync dbSync Db . queryPoolStatDuplicates
432+ duplicateCount <- queryDBSync dbSync DB . queryPoolStatDuplicates
433433 assertEqual " Should have no duplicate pool stats after rollback" 0 duplicateCount
434434 where
435435 args = initCommandLineArgs {claFullMode = False }
436436 testLabel = " conwayPoolStatRollbackNoDuplicates"
437437
438438poolStatRollbackGeneral :: IOManager -> [(Text , Text )] -> Assertion
439439poolStatRollbackGeneral =
440- withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel
441- $ \ interpreter mockServer dbSync -> do
440+ withCustomConfigDropDB args (Just configPoolStats) conwayConfigDir testLabel $
441+ \ interpreter mockServer dbSync -> do
442442 startDBSync dbSync
443443
444444 -- Create pools and stake to generate pool stats
@@ -451,15 +451,15 @@ poolStatRollbackGeneral =
451451 assertBlockNoBackoff dbSync totalBeforeRollback
452452
453453 -- Check initial pool stat count
454- initialCount <- queryDBSync dbSync Db . queryPoolStatCount
454+ initialCount <- queryDBSync dbSync DB . queryPoolStatCount
455455
456456 -- Forge more blocks to create additional pool stats
457457 epochBlks2 <- fillEpochs interpreter mockServer 1
458458 let totalAfterEpoch = totalBeforeRollback + length epochBlks2
459459 assertBlockNoBackoff dbSync totalAfterEpoch
460460
461461 -- Verify pool stats increased
462- afterCount <- queryDBSync dbSync Db . queryPoolStatCount
462+ afterCount <- queryDBSync dbSync DB . queryPoolStatCount
463463 assertBool " Pool stats should have increased" (afterCount > initialCount)
464464
465465 -- Rollback to previous point
@@ -470,13 +470,13 @@ poolStatRollbackGeneral =
470470 epochBlks3 <- fillEpochs interpreter mockServer 1
471471 let finalTotal = totalBeforeRollback + length epochBlks3 + 1
472472 assertBlockNoBackoff dbSync finalTotal
473- finalCount <- queryDBSync dbSync Db . queryPoolStatCount
473+ finalCount <- queryDBSync dbSync DB . queryPoolStatCount
474474
475475 -- Verify count matches and no constraint violations occurred
476476 assertEqual " Pool stat count should match after rollback" afterCount finalCount
477477
478478 -- Also verify no duplicates
479- duplicateCount <- queryDBSync dbSync Db . queryPoolStatDuplicates
479+ duplicateCount <- queryDBSync dbSync DB . queryPoolStatDuplicates
480480 assertEqual " Should have no duplicate pool stats" 0 duplicateCount
481481 where
482482 args = initCommandLineArgs {claFullMode = False }
0 commit comments