genlayer-test 0.8.0__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/METADATA +29 -2
  2. genlayer_test-0.9.0.dist-info/RECORD +38 -0
  3. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/top_level.txt +0 -1
  4. gltest_cli/config/constants.py +7 -0
  5. gltest_cli/config/plugin.py +22 -4
  6. gltest_cli/config/types.py +81 -46
  7. gltest_cli/config/user.py +95 -7
  8. genlayer_test-0.8.0.dist-info/RECORD +0 -82
  9. tests/__init__.py +0 -0
  10. tests/conftest.py +0 -1
  11. tests/examples/contracts/football_prediction_market.py +0 -100
  12. tests/examples/contracts/intelligent_oracle.py +0 -370
  13. tests/examples/contracts/intelligent_oracle_factory.py +0 -49
  14. tests/examples/contracts/invalid_deploy.py +0 -10
  15. tests/examples/contracts/llm_erc20.py +0 -70
  16. tests/examples/contracts/log_indexer.py +0 -69
  17. tests/examples/contracts/multi_file_contract/__init__.py +0 -24
  18. tests/examples/contracts/multi_file_contract/other.py +0 -14
  19. tests/examples/contracts/multi_read_erc20.py +0 -29
  20. tests/examples/contracts/multi_tenant_storage.py +0 -51
  21. tests/examples/contracts/read_erc20.py +0 -19
  22. tests/examples/contracts/simple_time_contract.py +0 -85
  23. tests/examples/contracts/storage.py +0 -23
  24. tests/examples/contracts/user_storage.py +0 -25
  25. tests/examples/contracts/wizard_of_coin.py +0 -57
  26. tests/examples/tests/test_custom_validators.py +0 -65
  27. tests/examples/tests/test_football_prediction_market.py +0 -38
  28. tests/examples/tests/test_intelligent_oracle_factory.py +0 -162
  29. tests/examples/tests/test_invalid_deploy.py +0 -24
  30. tests/examples/tests/test_llm_erc20.py +0 -60
  31. tests/examples/tests/test_llm_erc20_analyze.py +0 -54
  32. tests/examples/tests/test_log_indexer.py +0 -76
  33. tests/examples/tests/test_multi_file_contract.py +0 -15
  34. tests/examples/tests/test_multi_read_erc20.py +0 -103
  35. tests/examples/tests/test_multi_tenant_storage.py +0 -76
  36. tests/examples/tests/test_read_erc20.py +0 -38
  37. tests/examples/tests/test_simple_time_contract.py +0 -90
  38. tests/examples/tests/test_storage.py +0 -26
  39. tests/examples/tests/test_user_storage.py +0 -87
  40. tests/examples/tests/test_wizard_of_coin.py +0 -27
  41. tests/gltest/__init__.py +0 -0
  42. tests/gltest/artifact/__init__.py +0 -0
  43. tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -22
  44. tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -22
  45. tests/gltest/artifact/contracts/not_ic_contract.py +0 -22
  46. tests/gltest/artifact/test_contract_definition.py +0 -55
  47. tests/gltest/assertions/test_assertions.py +0 -344
  48. tests/gltest_cli/__init__.py +0 -0
  49. tests/gltest_cli/config/test_config_integration.py +0 -432
  50. tests/gltest_cli/config/test_general_config.py +0 -406
  51. tests/gltest_cli/config/test_plugin.py +0 -290
  52. tests/gltest_cli/config/test_user.py +0 -411
  53. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/WHEEL +0 -0
  54. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/entry_points.txt +0 -0
  55. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,55 +0,0 @@
1
- import pytest
2
- from gltest.artifacts.contract import (
3
- find_contract_definition_from_name,
4
- compute_contract_code,
5
- )
6
- from gltest_cli.config.general import get_general_config
7
- from pathlib import Path
8
-
9
- CONTRACTS_DIR = Path("tests/examples/contracts")
10
-
11
-
12
- def test_single_file():
13
- general_config = get_general_config()
14
- general_config.set_contracts_dir(Path("."))
15
- contract_definition = find_contract_definition_from_name("PredictionMarket")
16
-
17
- assert contract_definition.contract_name == "PredictionMarket"
18
-
19
- # Assert complete contract definition
20
- expected_main_file_path = CONTRACTS_DIR / "football_prediction_market.py"
21
- expected_runner_file_path = None
22
- contract_code = compute_contract_code(
23
- expected_main_file_path, expected_runner_file_path
24
- )
25
- assert contract_definition.contract_code == contract_code
26
- assert str(contract_definition.main_file_path) == str(
27
- CONTRACTS_DIR / "football_prediction_market.py"
28
- )
29
- assert contract_definition.runner_file_path is None
30
-
31
-
32
- def test_multiple_files():
33
- general_config = get_general_config()
34
- general_config.set_contracts_dir(Path("."))
35
- contract_definition = find_contract_definition_from_name("MultiFileContract")
36
-
37
- assert contract_definition.contract_name == "MultiFileContract"
38
-
39
- # Assert complete contract definition
40
- expected_main_file_path = CONTRACTS_DIR / "multi_file_contract/__init__.py"
41
- expected_runner_file_path = CONTRACTS_DIR / "multi_file_contract/runner.json"
42
- assert contract_definition.main_file_path == expected_main_file_path
43
- assert contract_definition.runner_file_path == expected_runner_file_path
44
- contract_code = compute_contract_code(
45
- expected_main_file_path, expected_runner_file_path
46
- )
47
- assert contract_definition.contract_code == contract_code
48
-
49
-
50
- def test_class_is_not_intelligent_contract():
51
- general_config = get_general_config()
52
- general_config.set_contracts_dir(Path("."))
53
-
54
- with pytest.raises(FileNotFoundError):
55
- _ = find_contract_definition_from_name("NotICContract")
@@ -1,344 +0,0 @@
1
- from gltest.assertions import tx_execution_succeeded, tx_execution_failed
2
-
3
- GENLAYER_SUCCESS_TRANSACTION = {
4
- "consensus_data": {"leader_receipt": [{"execution_result": "SUCCESS"}]}
5
- }
6
-
7
- GENLAYER_FAILED_TRANSACTION = {
8
- "consensus_data": {"leader_receipt": [{"execution_result": "ERROR"}]}
9
- }
10
-
11
- GENLAYER_EMPTY_LEADER_RECEIPT = {"consensus_data": {"leader_receipt": []}}
12
-
13
- GENLAYER_GENVM_TRANSACTION = {
14
- "consensus_data": {
15
- "leader_receipt": [
16
- {
17
- "execution_result": "SUCCESS",
18
- "genvm_result": {
19
- "stdout": "Process completed successfully with code 123 items",
20
- "stderr": "Warning: deprecated function used",
21
- },
22
- }
23
- ]
24
- }
25
- }
26
-
27
- GENLAYER_GENVM_EMPTY_STDERR = {
28
- "consensus_data": {
29
- "leader_receipt": [
30
- {
31
- "execution_result": "SUCCESS",
32
- "genvm_result": {
33
- "stdout": "Task finished without errors",
34
- "stderr": "",
35
- },
36
- }
37
- ]
38
- }
39
- }
40
-
41
- GENLAYER_GENVM_NO_STDOUT = {
42
- "consensus_data": {
43
- "leader_receipt": [
44
- {
45
- "execution_result": "SUCCESS",
46
- "genvm_result": {"stderr": "Error occurred"},
47
- }
48
- ]
49
- }
50
- }
51
-
52
- GENLAYER_GENVM_FAILED = {
53
- "consensus_data": {
54
- "leader_receipt": [
55
- {
56
- "execution_result": "ERROR",
57
- "genvm_result": {
58
- "stdout": "Process failed",
59
- "stderr": "Critical error occurred",
60
- },
61
- }
62
- ]
63
- }
64
- }
65
-
66
-
67
- def test_with_successful_transaction():
68
- """Test assertion functions with a basic successful transaction.
69
-
70
- Validates that:
71
- - tx_execution_succeeded returns True for successful transactions
72
- - tx_execution_failed returns False for successful transactions
73
- """
74
- assert tx_execution_succeeded(GENLAYER_SUCCESS_TRANSACTION) is True
75
- assert tx_execution_failed(GENLAYER_SUCCESS_TRANSACTION) is False
76
-
77
-
78
- def test_with_failed_transaction():
79
- """Test assertion functions with a basic failed transaction.
80
-
81
- Validates that:
82
- - tx_execution_succeeded returns False for failed transactions
83
- - tx_execution_failed returns True for failed transactions
84
- """
85
- assert tx_execution_succeeded(GENLAYER_FAILED_TRANSACTION) is False
86
- assert tx_execution_failed(GENLAYER_FAILED_TRANSACTION) is True
87
-
88
-
89
- def test_with_empty_leader_receipt():
90
- """Test assertion functions with empty leader_receipt array.
91
-
92
- Validates that:
93
- - Both functions handle empty leader_receipt gracefully
94
- - Empty leader_receipt is treated as a failed transaction
95
- """
96
- assert tx_execution_succeeded(GENLAYER_EMPTY_LEADER_RECEIPT) is False
97
- assert tx_execution_failed(GENLAYER_EMPTY_LEADER_RECEIPT) is True
98
-
99
-
100
- def test_with_invalid_transaction():
101
- """Test assertion functions with completely invalid transaction structure.
102
-
103
- Validates that:
104
- - Both functions handle malformed transactions gracefully
105
- - Invalid transactions are treated as failed
106
- """
107
- assert tx_execution_succeeded({}) is False
108
- assert tx_execution_failed({}) is True
109
-
110
-
111
- def test_genvm_result_without_match():
112
- """Test assertion functions with genvm_result but no match parameters.
113
-
114
- Validates that:
115
- - Transactions with genvm_result succeed when execution_result is SUCCESS
116
- - No match parameters means only basic execution status is checked
117
- """
118
- assert tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION) is True
119
- assert tx_execution_failed(GENLAYER_GENVM_TRANSACTION) is False
120
-
121
-
122
- def test_match_std_out_simple_string():
123
- """Test stdout matching with simple string patterns.
124
-
125
- Validates that:
126
- - Simple string matching works correctly in stdout
127
- - Non-matching strings cause the assertion to fail
128
- - tx_execution_failed behaves oppositely to tx_execution_succeeded
129
- """
130
- assert (
131
- tx_execution_succeeded(
132
- GENLAYER_GENVM_TRANSACTION, match_std_out="Process completed"
133
- )
134
- is True
135
- )
136
- assert (
137
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_out="nonexistent")
138
- is False
139
- )
140
- assert (
141
- tx_execution_failed(GENLAYER_GENVM_TRANSACTION, match_std_out="nonexistent")
142
- is True
143
- )
144
-
145
-
146
- def test_match_std_err_simple_string():
147
- """Test stderr matching with simple string patterns.
148
-
149
- Validates that:
150
- - Simple string matching works correctly in stderr
151
- - Non-matching strings cause the assertion to fail
152
- - tx_execution_failed behaves oppositely to tx_execution_succeeded
153
- """
154
- assert (
155
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_err="Warning")
156
- is True
157
- )
158
- assert (
159
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_err="nonexistent")
160
- is False
161
- )
162
- assert (
163
- tx_execution_failed(GENLAYER_GENVM_TRANSACTION, match_std_err="nonexistent")
164
- is True
165
- )
166
-
167
-
168
- def test_match_std_out_regex():
169
- """Test stdout matching with regex patterns.
170
-
171
- Validates that:
172
- - Complex regex patterns work correctly in stdout
173
- - Different regex patterns match appropriately
174
- - Non-matching regex patterns cause assertions to fail
175
- - Tests various regex features like \\d+, .*, word boundaries
176
- """
177
- assert (
178
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_out=r".*code \d+")
179
- is True
180
- )
181
- assert (
182
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_out=r".* 123 .*")
183
- is True
184
- )
185
- assert (
186
- tx_execution_succeeded(
187
- GENLAYER_GENVM_TRANSACTION, match_std_out=r"Process.*successfully"
188
- )
189
- is True
190
- )
191
- assert (
192
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_out=r"code \d{4}")
193
- is False
194
- )
195
-
196
-
197
- def test_match_std_err_regex():
198
- """Test stderr matching with regex patterns.
199
-
200
- Validates that:
201
- - Complex regex patterns work correctly in stderr
202
- - Different regex patterns match appropriately
203
- - Non-matching regex patterns cause assertions to fail
204
- - Tests various regex features like .*, word boundaries
205
- """
206
- assert (
207
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_err=r"Warning:.*")
208
- is True
209
- )
210
- assert (
211
- tx_execution_succeeded(
212
- GENLAYER_GENVM_TRANSACTION, match_std_err=r".*deprecated.*"
213
- )
214
- is True
215
- )
216
- assert (
217
- tx_execution_succeeded(GENLAYER_GENVM_TRANSACTION, match_std_err=r"Error:.*")
218
- is False
219
- )
220
-
221
-
222
- def test_match_both_stdout_and_stderr():
223
- """Test matching both stdout and stderr simultaneously.
224
-
225
- Validates that:
226
- - Both stdout and stderr patterns must match for success
227
- - If either pattern fails to match, the assertion fails
228
- - Combined matching works with both simple strings and regex
229
- """
230
- assert (
231
- tx_execution_succeeded(
232
- GENLAYER_GENVM_TRANSACTION,
233
- match_std_out="Process completed",
234
- match_std_err="Warning",
235
- )
236
- is True
237
- )
238
-
239
- assert (
240
- tx_execution_succeeded(
241
- GENLAYER_GENVM_TRANSACTION,
242
- match_std_out="Process completed",
243
- match_std_err="nonexistent",
244
- )
245
- is False
246
- )
247
-
248
-
249
- def test_match_empty_stderr():
250
- """Test matching empty stderr with different approaches.
251
-
252
- Validates that:
253
- - Empty stderr can be matched with regex pattern ^$
254
- - Empty stderr can be matched with empty string
255
- - Non-empty patterns fail when stderr is empty
256
- """
257
- assert (
258
- tx_execution_succeeded(GENLAYER_GENVM_EMPTY_STDERR, match_std_err=r"^$") is True
259
- )
260
- assert tx_execution_succeeded(GENLAYER_GENVM_EMPTY_STDERR, match_std_err="") is True
261
- assert (
262
- tx_execution_succeeded(GENLAYER_GENVM_EMPTY_STDERR, match_std_err="Warning")
263
- is False
264
- )
265
-
266
-
267
- def test_missing_stdout_field():
268
- """Test behavior when stdout field is missing from genvm_result.
269
-
270
- Validates that:
271
- - Missing stdout field causes match_std_out to fail
272
- - The assertion handles missing fields gracefully
273
- - tx_execution_failed returns True when stdout matching is requested but field is missing
274
- """
275
- assert (
276
- tx_execution_succeeded(GENLAYER_GENVM_NO_STDOUT, match_std_out="anything")
277
- is False
278
- )
279
- assert (
280
- tx_execution_failed(GENLAYER_GENVM_NO_STDOUT, match_std_out="anything") is True
281
- )
282
-
283
-
284
- def test_missing_stderr_field():
285
- """Test behavior when stderr field is missing from genvm_result.
286
-
287
- Validates that:
288
- - Missing stderr field causes match_std_err to fail
289
- - The assertion handles missing fields gracefully
290
- - tx_execution_failed returns True when stderr matching is requested but field is missing
291
- """
292
- genvm_no_stderr = {
293
- "consensus_data": {
294
- "leader_receipt": [
295
- {"execution_result": "SUCCESS", "genvm_result": {"stdout": "Success"}}
296
- ]
297
- }
298
- }
299
- assert tx_execution_succeeded(genvm_no_stderr, match_std_err="anything") is False
300
- assert tx_execution_failed(genvm_no_stderr, match_std_err="anything") is True
301
-
302
-
303
- def test_failed_execution_with_genvm_result():
304
- """Test assertion behavior with failed execution but present genvm_result.
305
-
306
- Validates that:
307
- - execution_result takes precedence over output matching
308
- - Even with matching stdout/stderr, failed executions return False
309
- - The basic execution status is checked before output matching
310
- """
311
- assert tx_execution_succeeded(GENLAYER_GENVM_FAILED) is False
312
- assert tx_execution_failed(GENLAYER_GENVM_FAILED) is True
313
-
314
- # Even with matching stdout/stderr, should still fail if execution_result is not SUCCESS
315
- assert (
316
- tx_execution_succeeded(GENLAYER_GENVM_FAILED, match_std_out="Process failed")
317
- is False
318
- )
319
- assert (
320
- tx_execution_succeeded(GENLAYER_GENVM_FAILED, match_std_err="Critical error")
321
- is False
322
- )
323
-
324
-
325
- def test_missing_genvm_result_with_match():
326
- """Test behavior when genvm_result is missing but match parameters are provided.
327
-
328
- Validates that:
329
- - Missing genvm_result causes output matching to fail
330
- - Both stdout and stderr matching fail when genvm_result is absent
331
- - tx_execution_failed returns True when match parameters are used without genvm_result
332
- """
333
- assert (
334
- tx_execution_succeeded(GENLAYER_SUCCESS_TRANSACTION, match_std_out="anything")
335
- is False
336
- )
337
- assert (
338
- tx_execution_succeeded(GENLAYER_SUCCESS_TRANSACTION, match_std_err="anything")
339
- is False
340
- )
341
- assert (
342
- tx_execution_failed(GENLAYER_SUCCESS_TRANSACTION, match_std_out="anything")
343
- is True
344
- )
File without changes