Skip to content
Permalink
Browse files

Merge #491

491: Turn the CDDL test into a cabal test-suite and run test in the CI r=MarcFontaine a=MarcFontaine

Part 1: Turn CDDL test into conditional cabal test-suite. To run the tests set the flag  `cddl`
Part 2: Run the CDDL test as part of the CI.


Co-authored-by: MarcFontaine <marc.fontaine@iohk.io>
  • Loading branch information...
iohk-bors and MarcFontaine committed May 15, 2019
2 parents e2e2415 + 2eb68ef commit 71d3a25acb08a14251ddde79d7333b02f625f13c
@@ -2081,8 +2081,8 @@ \chapter{CDDL Specification of the Protocol Messages}
This means that there is no need to tag messages at all This means that there is no need to tag messages at all
and the protocol can directly transmit the plain request and response data. and the protocol can directly transmit the plain request and response data.


\wip{TODO: test that messages.cddl actually works !} \wip{TODO: test that haskell(message) => cddl(message) }
\lstinputlisting{messages.cddl} \lstinputlisting{../ouroboros-network/test-cddl/messages.cddl}
\bibliographystyle{apalike} \bibliographystyle{apalike}
\bibliography{references} \bibliography{references}


Some generated files are not rendered by default. Learn more.

@@ -36,6 +36,8 @@ let
packages.io-sim.configureFlags = [ "--ghc-option=-Werror" ]; packages.io-sim.configureFlags = [ "--ghc-option=-Werror" ];
packages.io-sim-classes.configureFlags = [ "--ghc-option=-Werror" ]; packages.io-sim-classes.configureFlags = [ "--ghc-option=-Werror" ];
packages.ouroboros-network.configureFlags = [ "--ghc-option=-Werror" ]; packages.ouroboros-network.configureFlags = [ "--ghc-option=-Werror" ];
packages.ouroboros-network.flags.cddl = true;
packages.ouroboros-network.components.tests.cddl.build-tools = [pkgs.cddl pkgs.cbor-diag];
packages.ouroboros-consensus.configureFlags = [ "--ghc-option=-Werror" ]; packages.ouroboros-consensus.configureFlags = [ "--ghc-option=-Werror" ];
} }
]; ];
@@ -9,7 +9,9 @@ maintainer:
copyright: 2018 IOHK copyright: 2018 IOHK
category: Network category: Network
build-type: Simple build-type: Simple
extra-source-files: ChangeLog.md extra-source-files:
ChangeLog.md
test/messages.cddl
cabal-version: >=1.10 cabal-version: >=1.10


Flag ipv6 Flag ipv6
@@ -18,6 +20,12 @@ Flag ipv6
-- Default to False since travis lacks IPv6 support -- Default to False since travis lacks IPv6 support
Default: False Default: False


flag cddl
Description: Enable CDDL based tests of the CBOR encoding
Manual: True
-- These tests need the cddl and the cbor-diag Ruby-package
Default: False

source-repository head source-repository head
type: git type: git
location: https://github.com/input-output-hk/ouroboros-network location: https://github.com/input-output-hk/ouroboros-network
@@ -225,10 +233,12 @@ test-suite tests
if flag(ipv6) if flag(ipv6)
cpp-options: -DOUROBOROS_NETWORK_IPV6 cpp-options: -DOUROBOROS_NETWORK_IPV6


test-suite test-cddl test-suite cddl
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
hs-source-dirs: test-cddl src hs-source-dirs: test src
main-is: Main.hs main-is: CDDL.hs
if !flag(cddl)
buildable: False
other-modules: Ouroboros.Network.AnchoredFragment other-modules: Ouroboros.Network.AnchoredFragment
Ouroboros.Network.Protocol.ChainSync.Codec Ouroboros.Network.Protocol.ChainSync.Codec
Ouroboros.Network.Protocol.ChainSync.Type Ouroboros.Network.Protocol.ChainSync.Type
@@ -5,7 +5,6 @@
module Main module Main
where where


import System.Environment (getArgs)
import System.Exit (ExitCode(..)) import System.Exit (ExitCode(..))
import System.Process.ByteString.Lazy import System.Process.ByteString.Lazy
import Control.Monad import Control.Monad
@@ -35,13 +34,7 @@ type RR = ReqResp DummyBytes DummyBytes
type BF = BlockFetch BlockHeader BlockBody type BF = BlockFetch BlockHeader BlockBody


main :: IO () main :: IO ()
main = getArgs >>= \case main = generateAndDecode "cddl" "diag2cbor.rb" "test/messages.cddl" 100
[cddlCmd,diag2cborCmd,cddlSpec,rounds]
-> generateAndDecode cddlCmd diag2cborCmd cddlSpec (read rounds)
_ -> error "call with 4 arguments"

test :: IO ()
test = generateAndDecode "./cddl" "./diag2cbor.rb" "../doc/messages.cddl" 100


generateAndDecode :: FilePath -> FilePath -> FilePath -> Int -> IO () generateAndDecode :: FilePath -> FilePath -> FilePath -> Int -> IO ()
generateAndDecode cddlCmd diag2cborCmd cddlSpec rounds = do generateAndDecode cddlCmd diag2cborCmd cddlSpec rounds = do
File renamed without changes.
@@ -108,3 +108,5 @@ nix:
packages: packages:
- zlib - zlib
- openssl - openssl
- cddl
- cbor-diag

0 comments on commit 71d3a25

Please sign in to comment.
You can’t perform that action at this time.