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 db64fb4 + 3bf9bf0 commit 4e838b058a736f926e95039f7fd7b08be1111d8c
@@ -2081,8 +2081,8 @@ \chapter{CDDL Specification of the Protocol Messages}
This means that there is no need to tag messages at all
and the protocol can directly transmit the plain request and response data.

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

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

Oops, something went wrong.
@@ -36,6 +36,8 @@ let
packages.io-sim.configureFlags = [ "--ghc-option=-Werror" ];
packages.io-sim-classes.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" ];
}
];
@@ -9,7 +9,9 @@ maintainer:
copyright: 2018 IOHK
category: Network
build-type: Simple
extra-source-files: ChangeLog.md
extra-source-files:
ChangeLog.md
test/messages.cddl
cabal-version: >=1.10

Flag ipv6
@@ -18,6 +20,12 @@ Flag ipv6
-- Default to False since travis lacks IPv6 support
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
type: git
location: https://github.com/input-output-hk/ouroboros-network
@@ -219,10 +227,12 @@ test-suite tests
if flag(ipv6)
cpp-options: -DOUROBOROS_NETWORK_IPV6

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

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

main :: IO ()
main = getArgs >>= \case
[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
main = generateAndDecode "cddl" "diag2cbor.rb" "test/messages.cddl" 100

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

0 comments on commit 4e838b0

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