Skip to content

Commit baee6d0

Browse files
author
euonymos
committed
add flag to run indexing tests
1 parent 3af9d69 commit baee6d0

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

docs/catalyst_milestone_reports.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
## Summary
44

55
* L1 indexing:
6-
* [pr]()
7-
* [source]()
8-
* [tests]()
6+
* [Basic indexing support PR #98](https://github.com/mlabs-haskell/cem-script/pull/98)
7+
* [Oura config generation PR #100](https://github.com/mlabs-haskell/cem-script/pull/100)
8+
* [Source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Indexing.hs)
9+
* [Tests for Auction example](https://github.com/mlabs-haskell/cem-script/blob/master/test/OuraFilter/Auction.hs)
10+
* Final code clean-up
11+
* Final tutorial and docs
912

1013
# Milestone 4
1114

src/Cardano/CEM/Indexing.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import Cardano.Ledger.BaseTypes qualified as Ledger
1414
import Data.Data (Proxy)
1515
import Data.String (IsString)
1616
import Data.Text qualified as T
17+
import Toml (Table)
1718
import Toml qualified
19+
import Toml.Pretty qualified
1820
import Toml.Schema ((.=))
1921
import Toml.Schema.ToValue qualified as Toml.ToValue
2022
import Prelude
@@ -62,7 +64,7 @@ ouraMonitoringScript p network sourcePath sinkPath =
6264
. pure
6365
. selectByAddress
6466
. Address.cardanoAddressBech32
65-
<$> Address.scriptC2ardanoAddress p network
67+
<$> Address.scriptCardanoAddress p network
6668

6769
cursor :: Toml.Table
6870
cursor =

test/Main.hs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ import Prelude
77
import Test.Hspec (hspec, runIO)
88

99
import Auction (auctionSpec)
10+
import Data.Maybe (isJust)
1011
import Dynamic (dynamicSpec)
1112
import OffChain (offChainSpec)
1213
import OuraFilters (ouraFiltersSpec)
14+
import System.Environment (lookupEnv)
1315
import Utils (clearLogs)
1416
import Voting (votingSpec)
1517

1618
main :: IO ()
17-
main = hspec do
18-
auctionSpec
19-
votingSpec
20-
offChainSpec
21-
dynamicSpec
22-
runIO clearLogs
23-
ouraFiltersSpec
19+
main = do
20+
runIndexing <- isJust <$> lookupEnv "INDEXING_TEST"
21+
hspec do
22+
auctionSpec
23+
votingSpec
24+
offChainSpec
25+
dynamicSpec
26+
if runIndexing
27+
then do
28+
-- These tests are not currently supported on CI
29+
runIO clearLogs
30+
ouraFiltersSpec
31+
else pure mempty

test/Oura.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Oura (
1010

1111
import Prelude
1212

13-
import Cardano.CEM.Indexing qualified as Config
13+
import Cardano.CEM.Indexing qualified as Indexing
1414
import Control.Concurrent (threadDelay)
1515
import Control.Concurrent.Async (Async)
1616
import Control.Concurrent.Async qualified as Async
@@ -45,7 +45,7 @@ newtype WorkDir = MkWorkDir {unWorkDir :: T.Text}
4545
withOura ::
4646
WorkDir ->
4747
Utils.SpotGarbage IO Process.ProcessHandle ->
48-
(Config.SourcePath -> Config.SinkPath -> Table) ->
48+
(Indexing.SourcePath -> Indexing.SinkPath -> Table) ->
4949
(Oura IO -> IO r) ->
5050
IO r
5151
withOura spotHandle workdir makeConfig =
@@ -54,25 +54,25 @@ withOura spotHandle workdir makeConfig =
5454
runOura ::
5555
WorkDir ->
5656
Utils.SpotGarbage IO Process.ProcessHandle ->
57-
(Config.SourcePath -> Config.SinkPath -> Table) ->
57+
(Indexing.SourcePath -> Indexing.SinkPath -> Table) ->
5858
Maybe Communication.Interval ->
5959
ContT r IO (Oura IO)
6060
runOura (MkWorkDir (T.unpack -> workdir)) spotHandle makeConfig outputCheckingInterval = do
6161
writerPath <-
6262
ContT $
6363
withNewFile "writer.socket" workdir
64-
sinkPath :: Config.SinkPath <-
64+
sinkPath :: Indexing.SinkPath <-
6565
fmap fromString $
6666
ContT $
6767
withNewFile "sink.socket" workdir
68-
sourcePath :: Config.SourcePath <-
68+
sourcePath :: Indexing.SourcePath <-
6969
fmap fromString $
7070
ContT $
7171
withNewFile "source.socket" workdir
72-
lift $ removeFile $ T.unpack $ Config.unSourcePath sourcePath
72+
lift $ removeFile $ T.unpack $ Indexing.unSourcePath sourcePath
7373
let
74-
config = configToText $ makeConfig sourcePath sinkPath
75-
configPath <- ContT $ withNewFile "config.toml" workdir
74+
config = Indexing.configToText $ makeConfig sourcePath sinkPath
75+
configPath <- ContT $ withNewFile "Indexing.toml" workdir
7676
lift $ T.IO.writeFile configPath config
7777
(ouraHandle, waitingForClose) <- launchOura configPath spotHandle
7878
lift $ Async.link waitingForClose

0 commit comments

Comments
 (0)