Skip to content

Commit 69f372b

Browse files
committed
move all queries to cardano-db library
1 parent b3b0a34 commit 69f372b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2363
-3285
lines changed

cardano-chain-gen/cardano-chain-gen.cabal

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ library
4444
Cardano.Mock.ChainDB
4545
Cardano.Mock.ChainSync.Server
4646
Cardano.Mock.ChainSync.State
47-
Cardano.Mock.Query
4847
Cardano.Mock.Forging.Crypto
4948
Cardano.Mock.Forging.Interpreter
5049
Cardano.Mock.Forging.Tx.Alonzo
@@ -65,7 +64,6 @@ library
6564
, cardano-binary
6665
, cardano-crypto-class
6766
, cardano-data
68-
, cardano-db
6967
, cardano-ledger-allegra
7068
, cardano-ledger-alonzo
7169
, cardano-ledger-babbage
@@ -81,7 +79,6 @@ library
8179
, containers
8280
, contra-tracer
8381
, directory
84-
, esqueleto
8582
, extra
8683
, mtl
8784
, microlens
@@ -179,7 +176,6 @@ test-suite cardano-chain-gen
179176
, contra-tracer
180177
, data-default-class
181178
, directory
182-
, esqueleto
183179
, extra
184180
, filepath
185181
, silently
@@ -188,16 +184,13 @@ test-suite cardano-chain-gen
188184
, tasty
189185
, tasty-quickcheck
190186
, text
191-
, transformers
192187
, transformers-except
193188
, tree-diff
194189
, tasty-hunit
195190
, monad-logger
196191
, ouroboros-consensus
197192
, ouroboros-consensus-cardano
198193
, ouroboros-network-api
199-
, persistent
200-
, persistent-postgresql
201194
, postgresql-simple
202195
, QuickCheck
203196
, quickcheck-state-machine:no-vendored-treediff

cardano-chain-gen/src/Cardano/Mock/Query.hs

Lines changed: 0 additions & 274 deletions
This file was deleted.

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import Cardano.Mock.ChainSync.Server
7373
import Cardano.Mock.Forging.Interpreter
7474
import Cardano.Node.Protocol.Shelley (readLeaderCredentials)
7575
import Cardano.Node.Types (ProtocolFilepaths (..))
76-
import Cardano.Prelude (NonEmpty ((:|)), ReaderT, panic, stderr, textShow)
76+
import Cardano.Prelude (NonEmpty ((:|)), panic, stderr, textShow, throwIO)
7777
import Cardano.SMASH.Server.PoolDataLayer
7878
import Control.Concurrent.Async (Async, async, cancel, poll)
7979
import Control.Concurrent.STM (atomically)
@@ -87,12 +87,10 @@ import Control.Concurrent.STM.TMVar (
8787
import Control.Exception (SomeException, bracket)
8888
import Control.Monad (void)
8989
import Control.Monad.Extra (eitherM)
90-
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
90+
import Control.Monad.Logger (NoLoggingT)
9191
import Control.Monad.Trans.Except.Extra (runExceptT)
9292
import Control.Tracer (nullTracer)
9393
import Data.Text (Text)
94-
import Database.Persist.Postgresql (createPostgresqlPool)
95-
import Database.Persist.Sql (SqlBackend)
9694
import Ouroboros.Consensus.Block.Forging
9795
import Ouroboros.Consensus.Config (TopLevelConfig)
9896
import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
@@ -232,7 +230,12 @@ queryDBSync env = DB.runWithConnectionNoLogging (getDBSyncPGPass env)
232230
getPoolLayer :: DBSyncEnv -> IO PoolDataLayer
233231
getPoolLayer env = do
234232
pgconfig <- runOrThrowIO $ DB.readPGPass (enpPGPassSource $ dbSyncParams env)
235-
pool <- runNoLoggingT $ createPostgresqlPool (DB.toConnectionSetting pgconfig) 1 -- Pool size of 1 for tests
233+
connSetting <- case DB.toConnectionSetting pgconfig of
234+
Left err -> throwIO $ userError err
235+
Right setting -> pure setting
236+
237+
-- Create the Hasql connection pool (using port as pool identifier, similar to your server)
238+
pool <- DB.createHasqlConnectionPool [connSetting] 1 -- Pool size of 1 for tests
236239
pure $
237240
postgresqlPoolDataLayer
238241
nullTracer

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37+
, sioDbDebug = False
3738
}
3839

3940
dncInsertOptions cfg @?= expected

0 commit comments

Comments
 (0)