Skip to content

Commit c63dbb3

Browse files
committed
move all queries to cardano-db library
1 parent c789449 commit c63dbb3

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

+2364
-3287
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
@@ -82,7 +80,6 @@ library
8280
, containers
8381
, contra-tracer
8482
, directory
85-
, esqueleto
8683
, extra
8784
, mtl
8885
, microlens
@@ -182,7 +179,6 @@ test-suite cardano-chain-gen
182179
, contra-tracer
183180
, data-default-class
184181
, directory
185-
, esqueleto
186182
, extra
187183
, filepath
188184
, int-cast
@@ -192,16 +188,13 @@ test-suite cardano-chain-gen
192188
, tasty
193189
, tasty-quickcheck
194190
, text
195-
, transformers
196191
, transformers-except
197192
, tree-diff
198193
, tasty-hunit
199194
, monad-logger
200195
, ouroboros-consensus
201196
, ouroboros-consensus-cardano
202197
, ouroboros-network-api
203-
, persistent
204-
, persistent-postgresql
205198
, postgresql-simple
206199
, QuickCheck
207200
, 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.Byron.Ledger.Mempool ()
9896
import Ouroboros.Consensus.Config (TopLevelConfig)
@@ -235,7 +233,12 @@ queryDBSync env = DB.runWithConnectionNoLogging (getDBSyncPGPass env)
235233
getPoolLayer :: DBSyncEnv -> IO PoolDataLayer
236234
getPoolLayer env = do
237235
pgconfig <- runOrThrowIO $ DB.readPGPass (enpPGPassSource $ dbSyncParams env)
238-
pool <- runNoLoggingT $ createPostgresqlPool (DB.toConnectionSetting pgconfig) 1 -- Pool size of 1 for tests
236+
connSetting <- case DB.toConnectionSetting pgconfig of
237+
Left err -> throwIO $ userError err
238+
Right setting -> pure setting
239+
240+
-- Create the Hasql connection pool (using port as pool identifier, similar to your server)
241+
pool <- DB.createHasqlConnectionPool [connSetting] 1 -- Pool size of 1 for tests
239242
pure $
240243
postgresqlPoolDataLayer
241244
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)