@@ -56,168 +56,6 @@ def test_protocol_mode(self, cluster: clusterlib.ClusterLib):
56
56
]
57
57
)
58
58
59
- @allure .link (helpers .get_vcs_link ())
60
- @common .SKIPIF_WRONG_ERA
61
- def test_whole_utxo (self , cluster : clusterlib .ClusterLib ):
62
- """Check that it is possible to return the whole UTxO on local cluster."""
63
- if cluster .protocol != clusterlib .Protocols .CARDANO :
64
- pytest .skip ("runs on cluster in full cardano mode" )
65
-
66
- common .get_test_id (cluster )
67
-
68
- cluster .cli (
69
- [
70
- "query" ,
71
- "utxo" ,
72
- "--whole-utxo" ,
73
- * cluster .magic_args ,
74
- ]
75
- )
76
-
77
- @allure .link (helpers .get_vcs_link ())
78
- @pytest .mark .testnets
79
- @pytest .mark .skipif (
80
- VERSIONS .transaction_era != VERSIONS .LAST_KNOWN_ERA ,
81
- reason = "works only with the latest TX era" ,
82
- )
83
- def test_pretty_utxo (
84
- self , cluster_manager : cluster_management .ClusterManager , cluster : clusterlib .ClusterLib
85
- ):
86
- """Check that pretty printed `query utxo` output looks as expected."""
87
- temp_template = common .get_test_id (cluster )
88
- amount1 = 2_000_000
89
- amount2 = 2_500_000
90
-
91
- # create source and destination payment addresses
92
- payment_addrs = clusterlib_utils .create_payment_addr_records (
93
- f"{ temp_template } _src" ,
94
- f"{ temp_template } _dst" ,
95
- cluster_obj = cluster ,
96
- )
97
-
98
- # fund source addresses
99
- clusterlib_utils .fund_from_faucet (
100
- payment_addrs [0 ],
101
- cluster_obj = cluster ,
102
- faucet_data = cluster_manager .cache .addrs_data ["user1" ],
103
- amount = amount1 + amount2 + 10_000_000 ,
104
- )
105
-
106
- src_address = payment_addrs [0 ].address
107
- dst_address = payment_addrs [1 ].address
108
-
109
- txouts = [
110
- clusterlib .TxOut (address = dst_address , amount = amount1 ),
111
- clusterlib .TxOut (address = dst_address , amount = amount2 ),
112
- ]
113
- tx_files = clusterlib .TxFiles (signing_key_files = [payment_addrs [0 ].skey_file ])
114
- tx_raw_output = cluster .g_transaction .send_tx (
115
- src_address = src_address ,
116
- tx_name = temp_template ,
117
- txouts = txouts ,
118
- tx_files = tx_files ,
119
- join_txouts = False ,
120
- )
121
-
122
- utxo_out = (
123
- cluster .cli (
124
- [
125
- "query" ,
126
- "utxo" ,
127
- "--address" ,
128
- dst_address ,
129
- * cluster .magic_args ,
130
- ]
131
- )
132
- .stdout .decode ("utf-8" )
133
- .split ()
134
- )
135
-
136
- txid = cluster .g_transaction .get_txid (tx_body_file = tx_raw_output .out_file )
137
- expected_out = [
138
- "TxHash" ,
139
- "TxIx" ,
140
- "Amount" ,
141
- "--------------------------------------------------------------------------------"
142
- "------" ,
143
- txid ,
144
- "0" ,
145
- str (amount1 ),
146
- "lovelace" ,
147
- "+" ,
148
- "TxOutDatumNone" ,
149
- txid ,
150
- "1" ,
151
- str (amount2 ),
152
- "lovelace" ,
153
- "+" ,
154
- "TxOutDatumNone" ,
155
- ]
156
-
157
- assert utxo_out == expected_out
158
-
159
- @allure .link (helpers .get_vcs_link ())
160
- @common .SKIPIF_WRONG_ERA
161
- @pytest .mark .parametrize ("invalid_param" , ("tx_hash" , "tx_ix" ))
162
- @hypothesis .given (filter_str = st .text (alphabet = string .ascii_letters , min_size = 1 ))
163
- @common .hypothesis_settings (max_examples = 300 )
164
- def test_tx_in_invalid_data (
165
- self , cluster : clusterlib .ClusterLib , filter_str : str , invalid_param : str
166
- ):
167
- """Try to use 'query utxo' with invalid 'tx-in' (property-based test).
168
-
169
- Expect failure.
170
- """
171
- common .get_test_id (cluster )
172
-
173
- tx_hash = "a4c141cfae907aa1c4b418f65f384a6d860d52786b412481bc63733acfab1541"
174
-
175
- with pytest .raises (clusterlib .CLIError ) as excinfo :
176
- cluster .cli (
177
- [
178
- "query" ,
179
- "utxo" ,
180
- "--tx-in" ,
181
- f"{ filter_str } #0" if invalid_param == "tx_hash" else f"{ tx_hash } #{ filter_str } " ,
182
- * cluster .magic_args ,
183
- ]
184
- )
185
-
186
- err_str = str (excinfo .value )
187
-
188
- if invalid_param == "tx_hash" :
189
- assert (
190
- "expecting hexadecimal digit" in err_str
191
- or "expecting transaction id (hexadecimal)" in err_str
192
- ), err_str
193
- else :
194
- assert "expecting digit" in err_str , err_str
195
-
196
- @allure .link (helpers .get_vcs_link ())
197
- @common .SKIPIF_WRONG_ERA
198
- @hypothesis .given (filter_str = st .text (alphabet = ADDR_ALPHABET , min_size = 1 ))
199
- @common .hypothesis_settings (max_examples = 300 )
200
- def test_address_invalid_data (self , cluster : clusterlib .ClusterLib , filter_str : str ):
201
- """Try to use 'query utxo' with invalid 'address' (property-based test).
202
-
203
- Expect failure.
204
- """
205
- common .get_test_id (cluster )
206
-
207
- with pytest .raises (clusterlib .CLIError ) as excinfo :
208
- cluster .cli (
209
- [
210
- "query" ,
211
- "utxo" ,
212
- "--address" ,
213
- filter_str ,
214
- * cluster .magic_args ,
215
- ]
216
- )
217
-
218
- err_str = str (excinfo .value )
219
- assert "invalid address" in err_str , err_str
220
-
221
59
@allure .link (helpers .get_vcs_link ())
222
60
@common .SKIPIF_WRONG_ERA
223
61
def test_txid_with_process_substitution (self , cluster : clusterlib .ClusterLib ):
@@ -525,6 +363,173 @@ def test_non_extended_key_error(self, cluster: clusterlib.ClusterLib):
525
363
), err_str
526
364
527
365
366
+ @pytest .mark .smoke
367
+ class TestQueryUTxO :
368
+ """Tests for cardano-cli query utxo."""
369
+
370
+ @allure .link (helpers .get_vcs_link ())
371
+ @common .SKIPIF_WRONG_ERA
372
+ def test_whole_utxo (self , cluster : clusterlib .ClusterLib ):
373
+ """Check that it is possible to return the whole UTxO on local cluster."""
374
+ if cluster .protocol != clusterlib .Protocols .CARDANO :
375
+ pytest .skip ("runs on cluster in full cardano mode" )
376
+
377
+ common .get_test_id (cluster )
378
+
379
+ cluster .cli (
380
+ [
381
+ "query" ,
382
+ "utxo" ,
383
+ "--whole-utxo" ,
384
+ * cluster .magic_args ,
385
+ ]
386
+ )
387
+
388
+ @allure .link (helpers .get_vcs_link ())
389
+ @pytest .mark .testnets
390
+ @pytest .mark .skipif (
391
+ VERSIONS .transaction_era != VERSIONS .LAST_KNOWN_ERA ,
392
+ reason = "works only with the latest TX era" ,
393
+ )
394
+ def test_pretty_utxo (
395
+ self , cluster_manager : cluster_management .ClusterManager , cluster : clusterlib .ClusterLib
396
+ ):
397
+ """Check that pretty printed `query utxo` output looks as expected."""
398
+ temp_template = common .get_test_id (cluster )
399
+ amount1 = 2_000_000
400
+ amount2 = 2_500_000
401
+
402
+ # create source and destination payment addresses
403
+ payment_addrs = clusterlib_utils .create_payment_addr_records (
404
+ f"{ temp_template } _src" ,
405
+ f"{ temp_template } _dst" ,
406
+ cluster_obj = cluster ,
407
+ )
408
+
409
+ # fund source addresses
410
+ clusterlib_utils .fund_from_faucet (
411
+ payment_addrs [0 ],
412
+ cluster_obj = cluster ,
413
+ faucet_data = cluster_manager .cache .addrs_data ["user1" ],
414
+ amount = amount1 + amount2 + 10_000_000 ,
415
+ )
416
+
417
+ src_address = payment_addrs [0 ].address
418
+ dst_address = payment_addrs [1 ].address
419
+
420
+ txouts = [
421
+ clusterlib .TxOut (address = dst_address , amount = amount1 ),
422
+ clusterlib .TxOut (address = dst_address , amount = amount2 ),
423
+ ]
424
+ tx_files = clusterlib .TxFiles (signing_key_files = [payment_addrs [0 ].skey_file ])
425
+ tx_raw_output = cluster .g_transaction .send_tx (
426
+ src_address = src_address ,
427
+ tx_name = temp_template ,
428
+ txouts = txouts ,
429
+ tx_files = tx_files ,
430
+ join_txouts = False ,
431
+ )
432
+
433
+ utxo_out = (
434
+ cluster .cli (
435
+ [
436
+ "query" ,
437
+ "utxo" ,
438
+ "--address" ,
439
+ dst_address ,
440
+ * cluster .magic_args ,
441
+ ]
442
+ )
443
+ .stdout .decode ("utf-8" )
444
+ .split ()
445
+ )
446
+
447
+ txid = cluster .g_transaction .get_txid (tx_body_file = tx_raw_output .out_file )
448
+ expected_out = [
449
+ "TxHash" ,
450
+ "TxIx" ,
451
+ "Amount" ,
452
+ "--------------------------------------------------------------------------------"
453
+ "------" ,
454
+ txid ,
455
+ "0" ,
456
+ str (amount1 ),
457
+ "lovelace" ,
458
+ "+" ,
459
+ "TxOutDatumNone" ,
460
+ txid ,
461
+ "1" ,
462
+ str (amount2 ),
463
+ "lovelace" ,
464
+ "+" ,
465
+ "TxOutDatumNone" ,
466
+ ]
467
+
468
+ assert utxo_out == expected_out
469
+
470
+ @allure .link (helpers .get_vcs_link ())
471
+ @common .SKIPIF_WRONG_ERA
472
+ @pytest .mark .parametrize ("invalid_param" , ("tx_hash" , "tx_ix" ))
473
+ @hypothesis .given (filter_str = st .text (alphabet = string .ascii_letters , min_size = 1 ))
474
+ @common .hypothesis_settings (max_examples = 300 )
475
+ def test_tx_in_invalid_data (
476
+ self , cluster : clusterlib .ClusterLib , filter_str : str , invalid_param : str
477
+ ):
478
+ """Try to use 'query utxo' with invalid 'tx-in' (property-based test).
479
+
480
+ Expect failure.
481
+ """
482
+ common .get_test_id (cluster )
483
+
484
+ tx_hash = "a4c141cfae907aa1c4b418f65f384a6d860d52786b412481bc63733acfab1541"
485
+
486
+ with pytest .raises (clusterlib .CLIError ) as excinfo :
487
+ cluster .cli (
488
+ [
489
+ "query" ,
490
+ "utxo" ,
491
+ "--tx-in" ,
492
+ f"{ filter_str } #0" if invalid_param == "tx_hash" else f"{ tx_hash } #{ filter_str } " ,
493
+ * cluster .magic_args ,
494
+ ]
495
+ )
496
+
497
+ err_str = str (excinfo .value )
498
+
499
+ if invalid_param == "tx_hash" :
500
+ assert (
501
+ "expecting hexadecimal digit" in err_str
502
+ or "expecting transaction id (hexadecimal)" in err_str
503
+ ), err_str
504
+ else :
505
+ assert "expecting digit" in err_str , err_str
506
+
507
+ @allure .link (helpers .get_vcs_link ())
508
+ @common .SKIPIF_WRONG_ERA
509
+ @hypothesis .given (filter_str = st .text (alphabet = ADDR_ALPHABET , min_size = 1 ))
510
+ @common .hypothesis_settings (max_examples = 300 )
511
+ def test_address_invalid_data (self , cluster : clusterlib .ClusterLib , filter_str : str ):
512
+ """Try to use 'query utxo' with invalid 'address' (property-based test).
513
+
514
+ Expect failure.
515
+ """
516
+ common .get_test_id (cluster )
517
+
518
+ with pytest .raises (clusterlib .CLIError ) as excinfo :
519
+ cluster .cli (
520
+ [
521
+ "query" ,
522
+ "utxo" ,
523
+ "--address" ,
524
+ filter_str ,
525
+ * cluster .magic_args ,
526
+ ]
527
+ )
528
+
529
+ err_str = str (excinfo .value )
530
+ assert "invalid address" in err_str , err_str
531
+
532
+
528
533
@common .SKIPIF_WRONG_ERA
529
534
class TestAdvancedQueries :
530
535
"""Basic sanity tests for advanced cardano-cli query commands.
0 commit comments