|
4 | 4 | {-# LANGUAGE NumericUnderscores #-}
|
5 | 5 | {-# LANGUAGE OverloadedStrings #-}
|
6 | 6 | {-# LANGUAGE ScopedTypeVariables #-}
|
7 |
| -{-# LANGUAGE TypeApplications #-} |
8 | 7 |
|
9 | 8 | module Test.Cardano.Db.Mock.Unit.Conway.Other (
|
10 | 9 | -- * Different configs
|
@@ -33,16 +32,16 @@ import Cardano.Ledger.Credential (StakeCredential ())
|
33 | 32 | import Cardano.Ledger.Crypto (StandardCrypto ())
|
34 | 33 | import Cardano.Ledger.Keys (KeyHash (), KeyRole (..))
|
35 | 34 | import Cardano.Mock.ChainSync.Server (IOManager (), addBlock, rollback)
|
36 |
| -import Cardano.Mock.Forging.Interpreter (Interpreter (), forgeNext, getCurrentEpoch) |
| 35 | +import Cardano.Mock.Forging.Interpreter (forgeNext, getCurrentEpoch) |
37 | 36 | import qualified Cardano.Mock.Forging.Tx.Babbage as Babbage
|
38 | 37 | import qualified Cardano.Mock.Forging.Tx.Conway as Conway
|
39 | 38 | import Cardano.Mock.Forging.Tx.Generic (resolvePool)
|
40 | 39 | import Cardano.Mock.Forging.Types
|
| 40 | +import Cardano.Mock.Query (queryParamProposalFromEpoch, queryVersionMajorFromEpoch) |
41 | 41 | import Cardano.Prelude hiding (from)
|
42 | 42 | import Cardano.SMASH.Server.PoolDataLayer (PoolDataLayer (..), dbToServantPoolId)
|
43 | 43 | import Cardano.SMASH.Server.Types (DBFail (..))
|
44 | 44 | import Data.List (last)
|
45 |
| -import Database.Esqueleto.Experimental |
46 | 45 | import Ouroboros.Consensus.Shelley.Eras (StandardConway ())
|
47 | 46 | import Ouroboros.Network.Block (blockPoint)
|
48 | 47 | import Test.Cardano.Db.Mock.Config
|
@@ -497,35 +496,9 @@ forkParam =
|
497 | 496 | where
|
498 | 497 | testLabel = "conwayForkParam"
|
499 | 498 | configDir = babbageConfigDir
|
500 |
| - |
501 |
| - queryCurrentMajVer :: |
502 |
| - MonadIO m => |
503 |
| - Interpreter -> |
504 |
| - ReaderT SqlBackend m (Maybe Word16) |
505 |
| - queryCurrentMajVer interpreter = do |
506 |
| - -- Look up current epoch from ledger |
507 |
| - EpochNo currentEpoch <- liftIO $ getCurrentEpoch interpreter |
508 |
| - |
509 |
| - -- Query epoch params from database |
510 |
| - res <- selectOne $ do |
511 |
| - param <- from $ table @Db.EpochParam |
512 |
| - where_ (param ^. Db.EpochParamEpochNo ==. val currentEpoch) |
513 |
| - pure (param ^. Db.EpochParamProtocolMajor) |
514 |
| - |
515 |
| - pure $ unValue <$> res |
516 |
| - |
517 |
| - queryMajVerProposal :: |
518 |
| - MonadIO m => |
519 |
| - Interpreter -> |
520 |
| - ReaderT SqlBackend m (Maybe Word16) |
| 499 | + queryCurrentMajVer interpreter = queryVersionMajorFromEpoch =<< getEpochNo interpreter |
521 | 500 | queryMajVerProposal interpreter = do
|
522 |
| - -- Look up current epoch from ledger |
523 |
| - EpochNo currentEpoch <- liftIO $ getCurrentEpoch interpreter |
524 |
| - |
525 |
| - -- Query proposals from database |
526 |
| - res <- selectOne $ do |
527 |
| - prop <- from $ table @Db.ParamProposal |
528 |
| - where_ $ prop ^. Db.ParamProposalEpochNo ==. val (Just currentEpoch) |
529 |
| - pure (prop ^. Db.ParamProposalProtocolMajor) |
530 |
| - |
531 |
| - pure $ join (unValue <$> res) |
| 501 | + epochNo <- getEpochNo interpreter |
| 502 | + prop <- queryParamProposalFromEpoch epochNo |
| 503 | + pure (Db.paramProposalProtocolMajor =<< prop) |
| 504 | + getEpochNo = fmap unEpochNo . liftIO . getCurrentEpoch |
0 commit comments