Skip to content

Commit f49e846

Browse files
committed
Test also golden GenTx and GenTxId
1 parent ea6b8d6 commit f49e846

File tree

5 files changed

+25
-4
lines changed
  • ouroboros-consensus-cardano
  • ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation

5 files changed

+25
-4
lines changed

ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/tx.cddl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tx =
2-
base.ns7<byron.tx,
2+
base.ns7<byron.transaction,
33
serialisedShelleyTx<shelley.transaction>,
44
serialisedShelleyTx<allegra.transaction>,
55
serialisedShelleyTx<mary.transaction>,
@@ -10,6 +10,10 @@ tx =
1010
serialisedShelleyTx<era> = #6.24(bytes .cbor era)
1111

1212
;# include byron as byron
13+
14+
; See https://github.com/IntersectMBO/cardano-ledger/issues/5124
15+
byron.transaction = [0, [byron.tx, [+ byron.twit]]] / [1, any] / [2, any] / [3, any]
16+
1317
;# include shelley as shelley
1418
;# include allegra as allegra
1519
;# include mary as mary

ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/GenCDDLs.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ withCDDLs f =
4545

4646
ntnHeader <- cddlc "cddl/node-to-node/chainsync/header.cddl"
4747
BS.writeFile "ntnheader.cddl" . cddlSpec $ ntnHeader
48+
49+
ntnTx <- cddlc "cddl/node-to-node/txsubmission2/tx.cddl"
50+
ntnTx' <- fixupBlockCDDL ntnTx
51+
BS.writeFile "ntntx.cddl" . cddlSpec $ ntnTx'
52+
53+
ntnTxId <- cddlc "cddl/node-to-node/txsubmission2/txId.cddl"
54+
BS.writeFile "ntntxid.cddl" . cddlSpec $ ntnTxId
4855
)
4956
( \() -> do
5057
D.removeFile "ntnblock.cddl"
5158
D.removeFile "ntnheader.cddl"
59+
D.removeFile "ntntx.cddl"
60+
D.removeFile "ntntxid.cddl"
5261
)
5362
(\_ -> f)
5463

ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Golden.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ tests =
2525
goldenTest_all
2626
codecConfig
2727
($(getGoldenDir) </> "cardano")
28-
(Just $ CDDLsForNodeToNode ("ntnblock.cddl", "serialisedCardanoBlock") ("ntnheader.cddl", "header"))
28+
( Just $
29+
CDDLsForNodeToNode
30+
("ntnblock.cddl", "serialisedCardanoBlock")
31+
("ntnheader.cddl", "header")
32+
("ntntx.cddl", "tx")
33+
("ntntxid.cddl", "txId")
34+
)
2935
examples
3036

3137
instance

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/CDDL.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ cddlTest cborM cddl rule =
4242
data CDDLsForNodeToNode = CDDLsForNodeToNode
4343
{ blockCDDL :: (FilePath, T.Text)
4444
, headerCDDL :: (FilePath, T.Text)
45+
, txCDDL :: (FilePath, T.Text)
46+
, txIdCDDL :: (FilePath, T.Text)
4547
}

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Golden.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ goldenTest_SerialiseNodeToNode codecConfig goldenDir mCDDLs Examples{..} =
379379
, test "Header" exampleHeader $ fmap headerCDDL mCDDLs
380380
, test "SerialisedBlock" exampleSerialisedBlock Nothing
381381
, test "SerialisedHeader" exampleSerialisedHeader Nothing
382-
, test "GenTx" exampleGenTx Nothing
383-
, test "GenTxId" exampleGenTxId Nothing
382+
, test "GenTx" exampleGenTx $ fmap txCDDL mCDDLs
383+
, test "GenTxId" exampleGenTxId $ fmap txIdCDDL mCDDLs
384384
]
385385
where
386386
test :: SerialiseNodeToNode blk a => TestName -> Labelled a -> Maybe (FilePath, T.Text) -> TestTree

0 commit comments

Comments
 (0)