Skip to content

Commit 9594784

Browse files
committed
wip
1 parent a48864f commit 9594784

File tree

8 files changed

+955
-981
lines changed
  • eras
    • allegra/impl/testlib/Test/Cardano/Ledger/Allegra
    • alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo
    • babbage/impl/testlib/Test/Cardano/Ledger/Babbage
    • conway/impl/testlib/Test/Cardano/Ledger/Conway
    • dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra
    • mary/impl/testlib/Test/Cardano/Ledger/Mary
    • shelley/impl/testlib/Test/Cardano/Ledger/Shelley
  • libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary

8 files changed

+955
-981
lines changed

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212

1313
module Test.Cardano.Ledger.Allegra.CDDL (
1414
module Test.Cardano.Ledger.Shelley.CDDL,
15-
module Test.Cardano.Ledger.Allegra.CDDL,
15+
allegraCDDL,
16+
allegra_native_script,
17+
allegra_transaction_witness_set,
18+
allegra_auxiliary_data,
19+
allegra_auxiliary_scripts,
20+
allegra_script_pubkey,
21+
allegra_script_all,
22+
allegra_script_any,
23+
allegra_invalid_before,
24+
allegra_invalid_hereafter,
1625
) where
1726

1827
import Cardano.Ledger.Allegra (AllegraEra)
1928
import Cardano.Ledger.Core (Era)
2029
import Codec.CBOR.Cuddle.Huddle
2130
import Data.Function (($))
22-
import Test.Cardano.Ledger.Shelley.CDDL hiding (
23-
block,
24-
transaction,
25-
transaction_body,
26-
transaction_witness_set,
27-
)
31+
import Test.Cardano.Ledger.Shelley.CDDL
2832
import Text.Heredoc
2933

3034
allegraCDDL :: Huddle
@@ -34,8 +38,8 @@ allegraCDDL =
3438
, HIRule $ transaction @AllegraEra
3539
]
3640

37-
native_script :: Rule
38-
native_script =
41+
allegra_native_script :: Rule
42+
allegra_native_script =
3943
comment
4044
[str|Timelock validity intervals are half-open intervals [a, b).
4145
|
@@ -46,44 +50,41 @@ native_script =
4650
| specifies the right (excluded) endpoint b.
4751
|]
4852
$ "native_script"
49-
=:= arr [a script_pubkey]
50-
/ arr [a script_all]
51-
/ arr [a script_any]
53+
=:= arr [a allegra_script_pubkey]
54+
/ arr [a allegra_script_all]
55+
/ arr [a allegra_script_any]
5256
/ arr [a script_n_of_k]
53-
/ arr [a invalid_before]
54-
/ arr [a invalid_hereafter]
57+
/ arr [a allegra_invalid_before]
58+
/ arr [a allegra_invalid_hereafter]
5559

56-
script_pubkey :: Named Group
57-
script_pubkey = "script_pubkey" =:~ grp [0, a addr_keyhash]
60+
allegra_script_pubkey :: Named Group
61+
allegra_script_pubkey = "script_pubkey" =:~ grp [0, a addr_keyhash]
5862

59-
script_all :: Named Group
60-
script_all = "script_all" =:~ grp [1, a (arr [0 <+ a native_script])]
63+
allegra_script_all :: Named Group
64+
allegra_script_all = "script_all" =:~ grp [1, a (arr [0 <+ a allegra_native_script])]
6165

62-
script_any :: Named Group
63-
script_any = "script_any" =:~ grp [2, a (arr [0 <+ a native_script])]
66+
allegra_script_any :: Named Group
67+
allegra_script_any = "script_any" =:~ grp [2, a (arr [0 <+ a allegra_native_script])]
6468

6569
script_n_of_k :: Named Group
66-
script_n_of_k = "script_n_of_k" =:~ grp [3, "n" ==> int64, a (arr [0 <+ a native_script])]
70+
script_n_of_k = "script_n_of_k" =:~ grp [3, "n" ==> int64, a (arr [0 <+ a allegra_native_script])]
6771

68-
invalid_before :: Named Group
69-
invalid_before = "invalid_before" =:~ grp [4, a VUInt]
72+
allegra_invalid_before :: Named Group
73+
allegra_invalid_before = "invalid_before" =:~ grp [4, a VUInt]
7074

71-
invalid_hereafter :: Named Group
72-
invalid_hereafter = "invalid_hereafter" =:~ grp [5, a VUInt]
75+
allegra_invalid_hereafter :: Named Group
76+
allegra_invalid_hereafter = "invalid_hereafter" =:~ grp [5, a VUInt]
7377

74-
metadata :: Rule
75-
metadata = "metadata" =:= mp [0 <+ asKey transaction_metadatum_label ==> transaction_metadatum]
78+
allegra_auxiliary_scripts :: Rule
79+
allegra_auxiliary_scripts = "auxiliary_scripts" =:= arr [0 <+ a allegra_native_script]
7680

77-
auxiliary_scripts :: Rule
78-
auxiliary_scripts = "auxiliary_scripts" =:= arr [0 <+ a native_script]
79-
80-
auxiliary_data :: Rule
81-
auxiliary_data =
81+
allegra_auxiliary_data :: Rule
82+
allegra_auxiliary_data =
8283
"auxiliary_data"
83-
=:= metadata
84+
=:= shelley_auxiliary_data
8485
/ sarr
85-
[ "transaction_metadata" ==> metadata
86-
, "auxiliary_scripts" ==> auxiliary_scripts
86+
[ "transaction_metadata" ==> shelley_auxiliary_data
87+
, "auxiliary_scripts" ==> allegra_auxiliary_scripts
8788
]
8889

8990
transaction_body :: forall era. Era era => Rule
@@ -93,41 +94,41 @@ transaction_body =
9394
|]
9495
$ "transaction_body"
9596
=:= mp
96-
[ idx 0 ==> set transaction_input
97-
, idx 1 ==> arr [0 <+ a transaction_output]
97+
[ idx 0 ==> untagged_set transaction_input
98+
, idx 1 ==> arr [0 <+ a shelley_transaction_output]
9899
, idx 2 ==> coin
99100
, opt (idx 3 ==> VUInt)
100-
, opt (idx 4 ==> arr [0 <+ a certificate])
101-
, opt (idx 5 ==> withdrawals)
102-
, opt (idx 6 ==> update @era)
103-
, opt (idx 7 ==> metadata_hash)
101+
, opt (idx 4 ==> arr [0 <+ a shelley_certificate])
102+
, opt (idx 5 ==> shelley_withdrawals)
103+
, opt (idx 6 ==> arr [a $ shelley_protocol_param_updates @era, a shelley_epoch])
104+
, opt (idx 7 ==> auxiliary_data_hash)
104105
, opt (idx 8 ==> VUInt)
105106
]
106107

107108
block :: forall era. Era era => Rule
108109
block =
109110
"block"
110111
=:= arr
111-
[ a $ header @era
112+
[ a $ shelley_header @era
112113
, "transaction_bodies" ==> arr [0 <+ a (transaction_body @era)]
113-
, "transaction_witness_sets" ==> arr [0 <+ a transaction_witness_set]
114-
, "auxiliary_data_set" ==> mp [0 <+ asKey transaction_index ==> auxiliary_data]
114+
, "transaction_witness_sets" ==> arr [0 <+ a allegra_transaction_witness_set]
115+
, "auxiliary_data_set" ==> mp [0 <+ asKey transaction_ix ==> allegra_auxiliary_data]
115116
]
116117

117118
transaction :: forall era. Era era => Rule
118119
transaction =
119120
"transaction"
120121
=:= arr
121122
[ a $ transaction_body @era
122-
, a transaction_witness_set
123-
, a (auxiliary_data / VNil)
123+
, a allegra_transaction_witness_set
124+
, a (allegra_auxiliary_data / VNil)
124125
]
125126

126-
transaction_witness_set :: Rule
127-
transaction_witness_set =
127+
allegra_transaction_witness_set :: Rule
128+
allegra_transaction_witness_set =
128129
"transaction_witness_set"
129130
=:= mp
130-
[ opt $ idx 0 ==> arr [0 <+ a vkeywitness]
131-
, opt $ idx 1 ==> arr [0 <+ a native_script]
131+
[ opt $ idx 0 ==> arr [0 <+ a vkey_witness]
132+
, opt $ idx 1 ==> arr [0 <+ a allegra_native_script]
132133
, opt $ idx 2 ==> arr [0 <+ a bootstrap_witness]
133134
]

0 commit comments

Comments
 (0)