Skip to content

Commit aeaede0

Browse files
authored
Merge pull request #1312 from IntersectMBO/newhoggy/add-transaction-view-golden-tests-across-eras
test(transaction): add golden tests for transaction view across all eras
2 parents 14ffb4c + 62674ee commit aeaede0

25 files changed

Lines changed: 719 additions & 0 deletions

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ test-suite cardano-cli-golden
476476
Test.Golden.Conway.Transaction.CreateWitness
477477
Test.Golden.CreateStaked
478478
Test.Golden.CreateTestnetData
479+
Test.Golden.Debug.TransactionView
479480
Test.Golden.ErrorsSpec
480481
Test.Golden.Governance.Action
481482
Test.Golden.Governance.Committee
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
module Test.Golden.Debug.TransactionView where
4+
5+
import System.FilePath ((</>))
6+
7+
import Test.Cardano.CLI.Util (execCardanoCLI, watchdogProp)
8+
9+
import Hedgehog (Property)
10+
import Hedgehog.Extras.Test (propertyOnce)
11+
import Hedgehog.Extras.Test qualified as H
12+
13+
inputDir, goldenDir :: FilePath
14+
inputDir = "test/cardano-cli-golden/files/input"
15+
goldenDir = "test/cardano-cli-golden/files/golden"
16+
17+
-- ----------------------------------------------------------------------------
18+
-- Shelley era tests
19+
-- ----------------------------------------------------------------------------
20+
21+
-- | Execute me with:
22+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view shelley json/"'@
23+
hprop_golden_debug_transaction_view_shelley_json :: Property
24+
hprop_golden_debug_transaction_view_shelley_json =
25+
watchdogProp . propertyOnce $ do
26+
result <-
27+
execCardanoCLI
28+
[ "debug"
29+
, "transaction"
30+
, "view"
31+
, "--tx-file"
32+
, inputDir </> "shelley/tx/signed.tx"
33+
, "--output-json"
34+
]
35+
H.diffVsGoldenFile result $ goldenDir </> "shelley/transaction-view.json"
36+
37+
-- | Execute me with:
38+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view shelley yaml/"'@
39+
hprop_golden_debug_transaction_view_shelley_yaml :: Property
40+
hprop_golden_debug_transaction_view_shelley_yaml =
41+
watchdogProp . propertyOnce $ do
42+
result <-
43+
execCardanoCLI
44+
[ "debug"
45+
, "transaction"
46+
, "view"
47+
, "--tx-file"
48+
, inputDir </> "shelley/tx/signed.tx"
49+
, "--output-yaml"
50+
]
51+
H.diffVsGoldenFile result $ goldenDir </> "shelley/transaction-view.yaml"
52+
53+
-- ----------------------------------------------------------------------------
54+
-- Allegra era tests
55+
-- ----------------------------------------------------------------------------
56+
57+
-- | Execute me with:
58+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view allegra json/"'@
59+
hprop_golden_debug_transaction_view_allegra_json :: Property
60+
hprop_golden_debug_transaction_view_allegra_json =
61+
watchdogProp . propertyOnce $ do
62+
result <-
63+
execCardanoCLI
64+
[ "debug"
65+
, "transaction"
66+
, "view"
67+
, "--tx-file"
68+
, inputDir </> "allegra/tx/signed.tx"
69+
, "--output-json"
70+
]
71+
H.diffVsGoldenFile result $ goldenDir </> "allegra/transaction-view.json"
72+
73+
-- | Execute me with:
74+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view allegra yaml/"'@
75+
hprop_golden_debug_transaction_view_allegra_yaml :: Property
76+
hprop_golden_debug_transaction_view_allegra_yaml =
77+
watchdogProp . propertyOnce $ do
78+
result <-
79+
execCardanoCLI
80+
[ "debug"
81+
, "transaction"
82+
, "view"
83+
, "--tx-file"
84+
, inputDir </> "allegra/tx/signed.tx"
85+
, "--output-yaml"
86+
]
87+
H.diffVsGoldenFile result $ goldenDir </> "allegra/transaction-view.yaml"
88+
89+
-- ----------------------------------------------------------------------------
90+
-- Mary era tests
91+
-- ----------------------------------------------------------------------------
92+
93+
-- | Execute me with:
94+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view mary json/"'@
95+
hprop_golden_debug_transaction_view_mary_json :: Property
96+
hprop_golden_debug_transaction_view_mary_json =
97+
watchdogProp . propertyOnce $ do
98+
result <-
99+
execCardanoCLI
100+
[ "debug"
101+
, "transaction"
102+
, "view"
103+
, "--tx-file"
104+
, inputDir </> "mary/tx/signed.tx"
105+
, "--output-json"
106+
]
107+
H.diffVsGoldenFile result $ goldenDir </> "mary/transaction-view.json"
108+
109+
-- | Execute me with:
110+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view mary yaml/"'@
111+
hprop_golden_debug_transaction_view_mary_yaml :: Property
112+
hprop_golden_debug_transaction_view_mary_yaml =
113+
watchdogProp . propertyOnce $ do
114+
result <-
115+
execCardanoCLI
116+
[ "debug"
117+
, "transaction"
118+
, "view"
119+
, "--tx-file"
120+
, inputDir </> "mary/tx/signed.tx"
121+
, "--output-yaml"
122+
]
123+
H.diffVsGoldenFile result $ goldenDir </> "mary/transaction-view.yaml"
124+
125+
-- ----------------------------------------------------------------------------
126+
-- Alonzo era tests
127+
-- ----------------------------------------------------------------------------
128+
129+
-- | Execute me with:
130+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view alonzo json/"'@
131+
hprop_golden_debug_transaction_view_alonzo_json :: Property
132+
hprop_golden_debug_transaction_view_alonzo_json =
133+
watchdogProp . propertyOnce $ do
134+
result <-
135+
execCardanoCLI
136+
[ "debug"
137+
, "transaction"
138+
, "view"
139+
, "--tx-file"
140+
, inputDir </> "alonzo/tx/signed.tx"
141+
, "--output-json"
142+
]
143+
H.diffVsGoldenFile result $ goldenDir </> "alonzo/transaction-view.json"
144+
145+
-- ----------------------------------------------------------------------------
146+
-- Babbage era tests
147+
-- ----------------------------------------------------------------------------
148+
149+
-- | Execute me with:
150+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view babbage json/"'@
151+
hprop_golden_debug_transaction_view_babbage_json :: Property
152+
hprop_golden_debug_transaction_view_babbage_json =
153+
watchdogProp . propertyOnce $ do
154+
result <-
155+
execCardanoCLI
156+
[ "debug"
157+
, "transaction"
158+
, "view"
159+
, "--tx-file"
160+
, inputDir </> "babbage/tx/signed.tx"
161+
, "--output-json"
162+
]
163+
H.diffVsGoldenFile result $ goldenDir </> "babbage/transaction-view.json"
164+
165+
-- | Execute me with:
166+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view babbage yaml/"'@
167+
hprop_golden_debug_transaction_view_babbage_yaml :: Property
168+
hprop_golden_debug_transaction_view_babbage_yaml =
169+
watchdogProp . propertyOnce $ do
170+
result <-
171+
execCardanoCLI
172+
[ "debug"
173+
, "transaction"
174+
, "view"
175+
, "--tx-file"
176+
, inputDir </> "babbage/tx/signed.tx"
177+
, "--output-yaml"
178+
]
179+
H.diffVsGoldenFile result $ goldenDir </> "babbage/transaction-view.yaml"
180+
181+
-- ----------------------------------------------------------------------------
182+
-- Conway era tests
183+
-- ----------------------------------------------------------------------------
184+
185+
-- | Execute me with:
186+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view conway json/"'@
187+
hprop_golden_debug_transaction_view_conway_json :: Property
188+
hprop_golden_debug_transaction_view_conway_json =
189+
watchdogProp . propertyOnce $ do
190+
result <-
191+
execCardanoCLI
192+
[ "debug"
193+
, "transaction"
194+
, "view"
195+
, "--tx-file"
196+
, inputDir </> "conway/tx/signed.tx"
197+
, "--output-json"
198+
]
199+
H.diffVsGoldenFile result $ goldenDir </> "conway/transaction-view.json"
200+
201+
-- | Execute me with:
202+
-- @cabal test cardano-cli-golden --test-options '-p "/golden debug transaction view conway yaml/"'@
203+
hprop_golden_debug_transaction_view_conway_yaml :: Property
204+
hprop_golden_debug_transaction_view_conway_yaml =
205+
watchdogProp . propertyOnce $ do
206+
result <-
207+
execCardanoCLI
208+
[ "debug"
209+
, "transaction"
210+
, "view"
211+
, "--tx-file"
212+
, inputDir </> "conway/tx/signed.tx"
213+
, "--output-yaml"
214+
]
215+
H.diffVsGoldenFile result $ goldenDir </> "conway/transaction-view.yaml"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"auxiliary scripts": null,
3+
"certificates": null,
4+
"collateral inputs": null,
5+
"era": "Allegra",
6+
"fee": "200000 Lovelace",
7+
"inputs": [
8+
"aabbccdd01234567aabbccdd01234567aabbccdd01234567aabbccdd01234567#0"
9+
],
10+
"metadata": null,
11+
"mint": null,
12+
"outputs": [
13+
{
14+
"address": "addr1q98lftnu9ejleqjz8n34znw96c5cf6jt9ar4de7kk90gz6vcjs3ct30t2c255cm29d3pm4m69sazxf25vs9elax8exgsqlcmz9",
15+
"address era": "Shelley",
16+
"amount": {
17+
"lovelace": 5000000
18+
},
19+
"network": "Mainnet",
20+
"payment credential key hash": "4ff4ae7c2e65fc82423ce3514dc5d62984ea4b2f4756e7d6b15e8169",
21+
"reference script": null,
22+
"stake reference": {
23+
"stake credential key hash": "98942385c5eb56154a636a2b621dd77a2c3a232554640b9ff4c7c991"
24+
}
25+
}
26+
],
27+
"reference inputs": null,
28+
"required signers (payment key hashes needed for scripts)": null,
29+
"return collateral": null,
30+
"total collateral": null,
31+
"update proposal": null,
32+
"validity range": {
33+
"lower bound": null,
34+
"upper bound": null
35+
},
36+
"withdrawals": null,
37+
"witnesses": []
38+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
auxiliary scripts: null
2+
certificates: null
3+
collateral inputs: null
4+
era: Allegra
5+
fee: 200000 Lovelace
6+
inputs:
7+
- aabbccdd01234567aabbccdd01234567aabbccdd01234567aabbccdd01234567#0
8+
metadata: null
9+
mint: null
10+
outputs:
11+
- address: addr1q98lftnu9ejleqjz8n34znw96c5cf6jt9ar4de7kk90gz6vcjs3ct30t2c255cm29d3pm4m69sazxf25vs9elax8exgsqlcmz9
12+
address era: Shelley
13+
amount:
14+
lovelace: 5000000
15+
network: Mainnet
16+
payment credential key hash: 4ff4ae7c2e65fc82423ce3514dc5d62984ea4b2f4756e7d6b15e8169
17+
reference script: null
18+
stake reference:
19+
stake credential key hash: 98942385c5eb56154a636a2b621dd77a2c3a232554640b9ff4c7c991
20+
reference inputs: null
21+
required signers (payment key hashes needed for scripts): null
22+
return collateral: null
23+
total collateral: null
24+
update proposal: null
25+
validity range:
26+
lower bound: null
27+
upper bound: null
28+
withdrawals: null
29+
witnesses: []
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"auxiliary scripts": null,
3+
"certificates": null,
4+
"collateral inputs": [],
5+
"era": "Alonzo",
6+
"fee": "200000 Lovelace",
7+
"inputs": [
8+
"aabbccdd01234567aabbccdd01234567aabbccdd01234567aabbccdd01234567#0"
9+
],
10+
"metadata": null,
11+
"mint": null,
12+
"outputs": [
13+
{
14+
"address": "addr1q98lftnu9ejleqjz8n34znw96c5cf6jt9ar4de7kk90gz6vcjs3ct30t2c255cm29d3pm4m69sazxf25vs9elax8exgsqlcmz9",
15+
"address era": "Shelley",
16+
"amount": {
17+
"lovelace": 5000000
18+
},
19+
"datum": "fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3571",
20+
"network": "Mainnet",
21+
"payment credential key hash": "4ff4ae7c2e65fc82423ce3514dc5d62984ea4b2f4756e7d6b15e8169",
22+
"reference script": null,
23+
"stake reference": {
24+
"stake credential key hash": "98942385c5eb56154a636a2b621dd77a2c3a232554640b9ff4c7c991"
25+
}
26+
}
27+
],
28+
"reference inputs": null,
29+
"required signers (payment key hashes needed for scripts)": null,
30+
"return collateral": null,
31+
"total collateral": null,
32+
"update proposal": null,
33+
"validity range": {
34+
"lower bound": null,
35+
"upper bound": null
36+
},
37+
"withdrawals": null,
38+
"witnesses": []
39+
}

0 commit comments

Comments
 (0)