genlayer-test 0.1.3__py3-none-any.whl → 0.3.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.
- {genlayer_test-0.1.3.dist-info → genlayer_test-0.3.0.dist-info}/METADATA +77 -10
- genlayer_test-0.3.0.dist-info/RECORD +65 -0
- {genlayer_test-0.1.3.dist-info → genlayer_test-0.3.0.dist-info}/entry_points.txt +1 -1
- gltest/__init__.py +4 -4
- gltest/artifacts/__init__.py +5 -2
- gltest/artifacts/contract.py +94 -14
- gltest/glchain/__init__.py +3 -3
- gltest/glchain/account.py +15 -11
- gltest/glchain/client.py +39 -3
- gltest/glchain/contract.py +98 -31
- gltest/helpers/fixture_snapshot.py +3 -2
- gltest_cli/config/__init__.py +0 -0
- gltest_cli/config/constants.py +10 -0
- gltest_cli/config/general.py +10 -0
- gltest_cli/config/plugin.py +102 -0
- gltest_cli/config/types.py +137 -0
- gltest_cli/config/user.py +222 -0
- gltest_cli/logging.py +51 -0
- tests/__init__.py +0 -0
- tests/examples/tests/test_llm_erc20.py +2 -2
- tests/examples/tests/test_multi_read_erc20.py +13 -3
- tests/examples/tests/test_multi_tenant_storage.py +12 -3
- tests/examples/tests/test_read_erc20.py +2 -2
- tests/examples/tests/test_storage.py +4 -2
- tests/examples/tests/test_user_storage.py +17 -3
- tests/gltest/__init__.py +0 -0
- tests/gltest/artifact/__init__.py +0 -0
- tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +22 -0
- tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +22 -0
- tests/{artifact → gltest/artifact}/test_contract_definition.py +29 -30
- tests/gltest_cli/__init__.py +0 -0
- tests/gltest_cli/config/test_plugin.py +127 -0
- tests/gltest_cli/config/test_user.py +351 -0
- genlayer_test-0.1.3.dist-info/RECORD +0 -53
- gltest/plugin_config.py +0 -42
- gltest/plugin_hooks.py +0 -51
- tests/plugin/test_plugin_hooks.py +0 -78
- {genlayer_test-0.1.3.dist-info → genlayer_test-0.3.0.dist-info}/WHEEL +0 -0
- {genlayer_test-0.1.3.dist-info → genlayer_test-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {genlayer_test-0.1.3.dist-info → genlayer_test-0.3.0.dist-info}/top_level.txt +0 -0
- /tests/{plugin/conftest.py → conftest.py} +0 -0
- /tests/{artifact → gltest/artifact}/contracts/not_ic_contract.py +0 -0
- /tests/{assertions → gltest/assertions}/test_assertions.py +0 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
def test_help_message(pytester):
|
2
|
+
result = pytester.runpytest(
|
3
|
+
"--help",
|
4
|
+
)
|
5
|
+
# fnmatch_lines does an assertion internally
|
6
|
+
result.stdout.fnmatch_lines(
|
7
|
+
[
|
8
|
+
"gltest:",
|
9
|
+
" --contracts-dir=CONTRACTS_DIR",
|
10
|
+
" Path to directory containing contract files",
|
11
|
+
" --default-wait-interval=DEFAULT_WAIT_INTERVAL",
|
12
|
+
" Default interval (ms) between transaction receipt checks",
|
13
|
+
" --default-wait-retries=DEFAULT_WAIT_RETRIES",
|
14
|
+
" Default number of retries for transaction receipt checks",
|
15
|
+
" --rpc-url=RPC_URL RPC endpoint URL for the GenLayer network",
|
16
|
+
" --network=NETWORK Target network (defaults to 'localnet' if no config",
|
17
|
+
" file)",
|
18
|
+
]
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
def test_default_wait_interval(pytester):
|
23
|
+
|
24
|
+
pytester.makepyfile(
|
25
|
+
"""
|
26
|
+
from gltest_cli.config.general import get_general_config
|
27
|
+
|
28
|
+
def test_default_wait_interval():
|
29
|
+
general_config = get_general_config()
|
30
|
+
assert general_config.get_default_wait_interval() == 5000
|
31
|
+
"""
|
32
|
+
)
|
33
|
+
|
34
|
+
result = pytester.runpytest("--default-wait-interval=5000", "-v")
|
35
|
+
|
36
|
+
result.stdout.fnmatch_lines(
|
37
|
+
[
|
38
|
+
"*::test_default_wait_interval PASSED*",
|
39
|
+
]
|
40
|
+
)
|
41
|
+
assert result.ret == 0
|
42
|
+
|
43
|
+
|
44
|
+
def test_default_wait_retries(pytester):
|
45
|
+
pytester.makepyfile(
|
46
|
+
"""
|
47
|
+
from gltest_cli.config.general import get_general_config
|
48
|
+
|
49
|
+
def test_default_wait_retries():
|
50
|
+
general_config = get_general_config()
|
51
|
+
assert general_config.get_default_wait_retries() == 4000
|
52
|
+
"""
|
53
|
+
)
|
54
|
+
|
55
|
+
result = pytester.runpytest("--default-wait-retries=4000", "-v")
|
56
|
+
|
57
|
+
result.stdout.fnmatch_lines(
|
58
|
+
[
|
59
|
+
"*::test_default_wait_retries PASSED*",
|
60
|
+
]
|
61
|
+
)
|
62
|
+
assert result.ret == 0
|
63
|
+
|
64
|
+
|
65
|
+
def test_rpc_url(pytester):
|
66
|
+
pytester.makepyfile(
|
67
|
+
"""
|
68
|
+
from gltest_cli.config.general import get_general_config
|
69
|
+
|
70
|
+
def test_rpc_url():
|
71
|
+
general_config = get_general_config()
|
72
|
+
assert general_config.get_rpc_url() == 'http://custom-rpc-url:8545'
|
73
|
+
"""
|
74
|
+
)
|
75
|
+
|
76
|
+
result = pytester.runpytest("--rpc-url=http://custom-rpc-url:8545", "-v")
|
77
|
+
|
78
|
+
result.stdout.fnmatch_lines(
|
79
|
+
[
|
80
|
+
"*::test_rpc_url PASSED*",
|
81
|
+
]
|
82
|
+
)
|
83
|
+
assert result.ret == 0
|
84
|
+
|
85
|
+
|
86
|
+
def test_network_localnet(pytester):
|
87
|
+
pytester.makepyfile(
|
88
|
+
"""
|
89
|
+
from gltest_cli.config.general import get_general_config
|
90
|
+
|
91
|
+
def test_network():
|
92
|
+
general_config = get_general_config()
|
93
|
+
assert general_config.get_network_name() == "localnet"
|
94
|
+
"""
|
95
|
+
)
|
96
|
+
|
97
|
+
result = pytester.runpytest("--network=localnet", "-v")
|
98
|
+
|
99
|
+
result.stdout.fnmatch_lines(
|
100
|
+
[
|
101
|
+
"*::test_network PASSED*",
|
102
|
+
]
|
103
|
+
)
|
104
|
+
assert result.ret == 0
|
105
|
+
|
106
|
+
|
107
|
+
def test_network_testnet(pytester):
|
108
|
+
pytester.makepyfile(
|
109
|
+
"""
|
110
|
+
from gltest_cli.config.general import get_general_config
|
111
|
+
|
112
|
+
def test_network():
|
113
|
+
general_config = get_general_config()
|
114
|
+
assert general_config.get_network_name() == "testnet_asimov"
|
115
|
+
"""
|
116
|
+
)
|
117
|
+
|
118
|
+
result = pytester.runpytest(
|
119
|
+
"--network=testnet_asimov", "--rpc-url=http://test.example.com:9151", "-v"
|
120
|
+
)
|
121
|
+
|
122
|
+
result.stdout.fnmatch_lines(
|
123
|
+
[
|
124
|
+
"*::test_network PASSED*",
|
125
|
+
]
|
126
|
+
)
|
127
|
+
assert result.ret == 0
|
@@ -0,0 +1,351 @@
|
|
1
|
+
import pytest
|
2
|
+
import yaml
|
3
|
+
from unittest.mock import patch, mock_open
|
4
|
+
from gltest_cli.config.user import (
|
5
|
+
get_default_user_config,
|
6
|
+
load_user_config,
|
7
|
+
validate_raw_user_config,
|
8
|
+
transform_raw_to_user_config_with_defaults,
|
9
|
+
user_config_exists,
|
10
|
+
VALID_ROOT_KEYS,
|
11
|
+
DEFAULT_NETWORK,
|
12
|
+
DEFAULT_ENVIRONMENT,
|
13
|
+
DEFAULT_CONTRACTS_DIR,
|
14
|
+
)
|
15
|
+
from gltest_cli.config.constants import DEFAULT_RPC_URL
|
16
|
+
from gltest_cli.config.types import UserConfig, NetworkConfigData, PathConfig
|
17
|
+
from unittest.mock import MagicMock
|
18
|
+
from pathlib import Path
|
19
|
+
|
20
|
+
# Test data
|
21
|
+
VALID_CONFIG = {
|
22
|
+
"networks": {
|
23
|
+
"default": "localnet",
|
24
|
+
"localnet": {
|
25
|
+
"url": "http://localhost:8545",
|
26
|
+
"accounts": ["0x123", "0x456"],
|
27
|
+
"from": "0x123",
|
28
|
+
},
|
29
|
+
"testnet_asimov": {
|
30
|
+
"id": 4221,
|
31
|
+
"url": "http://34.32.169.58:9151",
|
32
|
+
"accounts": ["0x123", "0x456"],
|
33
|
+
"from": "0x123",
|
34
|
+
},
|
35
|
+
},
|
36
|
+
"paths": {"contracts": "contracts"},
|
37
|
+
"environment": ".env",
|
38
|
+
}
|
39
|
+
|
40
|
+
INVALID_CONFIG = {
|
41
|
+
"networks": {
|
42
|
+
"default": "invalid_network",
|
43
|
+
"localnet": {
|
44
|
+
"url": 123, # Invalid type
|
45
|
+
"accounts": "not_a_list", # Invalid type
|
46
|
+
"from": 456, # Invalid type
|
47
|
+
},
|
48
|
+
},
|
49
|
+
"paths": {"invalid_path": "value"},
|
50
|
+
"environment": 123, # Invalid type
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
def test_get_default_user_config():
|
55
|
+
config = get_default_user_config()
|
56
|
+
|
57
|
+
# Check root structure
|
58
|
+
assert isinstance(config, UserConfig)
|
59
|
+
assert all(key in config.__dict__ for key in VALID_ROOT_KEYS)
|
60
|
+
|
61
|
+
# Check networks
|
62
|
+
assert DEFAULT_NETWORK == config.default_network
|
63
|
+
assert DEFAULT_NETWORK in config.networks
|
64
|
+
|
65
|
+
# Check network configuration
|
66
|
+
network = config.networks[DEFAULT_NETWORK]
|
67
|
+
assert isinstance(network, NetworkConfigData)
|
68
|
+
assert network.url == DEFAULT_RPC_URL
|
69
|
+
assert isinstance(network.accounts, list)
|
70
|
+
assert isinstance(network.from_account, str)
|
71
|
+
assert network.from_account in network.accounts
|
72
|
+
|
73
|
+
# Check paths
|
74
|
+
assert isinstance(config.paths, PathConfig)
|
75
|
+
assert config.paths.contracts == DEFAULT_CONTRACTS_DIR
|
76
|
+
|
77
|
+
# Check environment
|
78
|
+
assert config.environment == DEFAULT_ENVIRONMENT
|
79
|
+
|
80
|
+
|
81
|
+
def test_validate_raw_user_config_valid():
|
82
|
+
# Should not raise any exceptions
|
83
|
+
validate_raw_user_config(VALID_CONFIG)
|
84
|
+
|
85
|
+
|
86
|
+
def test_validate_raw_user_config_invalid():
|
87
|
+
with pytest.raises(ValueError, match="Invalid configuration keys"):
|
88
|
+
validate_raw_user_config({"invalid_key": "value"})
|
89
|
+
|
90
|
+
with pytest.raises(ValueError, match="networks must be a dictionary"):
|
91
|
+
validate_raw_user_config({"networks": "not_a_dict"})
|
92
|
+
|
93
|
+
with pytest.raises(ValueError, match="default network invalid_network not found"):
|
94
|
+
validate_raw_user_config(
|
95
|
+
{
|
96
|
+
"networks": {
|
97
|
+
"default": "invalid_network",
|
98
|
+
"localnet": {"url": "http://localhost:8545"},
|
99
|
+
}
|
100
|
+
}
|
101
|
+
)
|
102
|
+
|
103
|
+
with pytest.raises(ValueError, match="network localnet must be a dictionary"):
|
104
|
+
validate_raw_user_config(
|
105
|
+
{"networks": {"default": "localnet", "localnet": "not_a_dict"}}
|
106
|
+
)
|
107
|
+
|
108
|
+
with pytest.raises(ValueError, match="Invalid network key"):
|
109
|
+
validate_raw_user_config(
|
110
|
+
{"networks": {"default": "localnet", "localnet": {"invalid_key": "value"}}}
|
111
|
+
)
|
112
|
+
|
113
|
+
with pytest.raises(ValueError, match="url must be a string"):
|
114
|
+
validate_raw_user_config(
|
115
|
+
{"networks": {"default": "localnet", "localnet": {"url": 123}}}
|
116
|
+
)
|
117
|
+
|
118
|
+
with pytest.raises(ValueError, match="accounts must be a list"):
|
119
|
+
validate_raw_user_config(
|
120
|
+
{
|
121
|
+
"networks": {
|
122
|
+
"default": "localnet",
|
123
|
+
"localnet": {"accounts": "not_a_list"},
|
124
|
+
}
|
125
|
+
}
|
126
|
+
)
|
127
|
+
|
128
|
+
with pytest.raises(ValueError, match="accounts must be strings"):
|
129
|
+
validate_raw_user_config(
|
130
|
+
{"networks": {"default": "localnet", "localnet": {"accounts": [123]}}}
|
131
|
+
)
|
132
|
+
|
133
|
+
with pytest.raises(ValueError, match="from must be a string"):
|
134
|
+
validate_raw_user_config(
|
135
|
+
{"networks": {"default": "localnet", "localnet": {"from": 123}}}
|
136
|
+
)
|
137
|
+
|
138
|
+
with pytest.raises(ValueError, match="paths must be a dictionary"):
|
139
|
+
validate_raw_user_config({"paths": "not_a_dict"})
|
140
|
+
|
141
|
+
with pytest.raises(ValueError, match="Invalid path keys"):
|
142
|
+
validate_raw_user_config({"paths": {"invalid_path": "value"}})
|
143
|
+
|
144
|
+
with pytest.raises(ValueError, match="environment must be a string"):
|
145
|
+
validate_raw_user_config({"environment": 123})
|
146
|
+
|
147
|
+
# Test validation for non-default networks
|
148
|
+
with pytest.raises(ValueError, match="network testnet must be a dictionary"):
|
149
|
+
validate_raw_user_config(
|
150
|
+
{"networks": {"default": "localnet", "testnet": "not_a_dict"}}
|
151
|
+
)
|
152
|
+
|
153
|
+
with pytest.raises(ValueError, match="Invalid network key"):
|
154
|
+
validate_raw_user_config(
|
155
|
+
{"networks": {"default": "localnet", "testnet": {"invalid_key": "value"}}}
|
156
|
+
)
|
157
|
+
|
158
|
+
with pytest.raises(ValueError, match="url must be a string"):
|
159
|
+
validate_raw_user_config(
|
160
|
+
{"networks": {"default": "localnet", "testnet": {"url": 123}}}
|
161
|
+
)
|
162
|
+
|
163
|
+
with pytest.raises(ValueError, match="accounts must be a list"):
|
164
|
+
validate_raw_user_config(
|
165
|
+
{
|
166
|
+
"networks": {
|
167
|
+
"default": "localnet",
|
168
|
+
"testnet": {"accounts": "not_a_list"},
|
169
|
+
}
|
170
|
+
}
|
171
|
+
)
|
172
|
+
|
173
|
+
with pytest.raises(ValueError, match="accounts must be strings"):
|
174
|
+
validate_raw_user_config(
|
175
|
+
{"networks": {"default": "localnet", "testnet": {"accounts": [123]}}}
|
176
|
+
)
|
177
|
+
|
178
|
+
with pytest.raises(ValueError, match="from must be a string"):
|
179
|
+
validate_raw_user_config(
|
180
|
+
{"networks": {"default": "localnet", "testnet": {"from": 123}}}
|
181
|
+
)
|
182
|
+
|
183
|
+
# Test required fields for non-default networks
|
184
|
+
with pytest.raises(ValueError, match="network testnet must have an id"):
|
185
|
+
validate_raw_user_config(
|
186
|
+
{"networks": {"default": "localnet", "testnet": {"accounts": ["0x123"]}}}
|
187
|
+
)
|
188
|
+
|
189
|
+
with pytest.raises(ValueError, match="network testnet must have a url"):
|
190
|
+
validate_raw_user_config(
|
191
|
+
{
|
192
|
+
"networks": {
|
193
|
+
"default": "localnet",
|
194
|
+
"testnet": {"id": 4221, "accounts": ["0x123"]},
|
195
|
+
}
|
196
|
+
}
|
197
|
+
)
|
198
|
+
|
199
|
+
with pytest.raises(ValueError, match="network testnet must have accounts"):
|
200
|
+
validate_raw_user_config(
|
201
|
+
{
|
202
|
+
"networks": {
|
203
|
+
"default": "localnet",
|
204
|
+
"testnet": {"id": 4221, "url": "http://testnet:8545"},
|
205
|
+
}
|
206
|
+
}
|
207
|
+
)
|
208
|
+
|
209
|
+
# Test that 'from' is optional for non-default networks
|
210
|
+
valid_config_without_from = {
|
211
|
+
"networks": {
|
212
|
+
"default": "localnet",
|
213
|
+
"testnet": {
|
214
|
+
"id": 4221,
|
215
|
+
"url": "http://testnet:8545",
|
216
|
+
"accounts": ["0x123", "0x456"],
|
217
|
+
},
|
218
|
+
}
|
219
|
+
}
|
220
|
+
# Should not raise any exception
|
221
|
+
validate_raw_user_config(valid_config_without_from)
|
222
|
+
|
223
|
+
|
224
|
+
@patch("builtins.open", new_callable=mock_open, read_data=yaml.dump(VALID_CONFIG))
|
225
|
+
@patch("gltest_cli.config.user.load_dotenv")
|
226
|
+
def test_load_user_config(mock_load_dotenv, mock_file):
|
227
|
+
config = load_user_config("dummy_path")
|
228
|
+
|
229
|
+
# Check if file was opened
|
230
|
+
mock_file.assert_called_once_with("dummy_path", "r")
|
231
|
+
|
232
|
+
# Check if environment was loaded
|
233
|
+
mock_load_dotenv.assert_called_once_with(
|
234
|
+
dotenv_path=DEFAULT_ENVIRONMENT, override=True
|
235
|
+
)
|
236
|
+
|
237
|
+
# Check config structure
|
238
|
+
assert isinstance(config, UserConfig)
|
239
|
+
|
240
|
+
# Check default network
|
241
|
+
assert config.default_network == "localnet"
|
242
|
+
assert isinstance(config.networks["localnet"], NetworkConfigData)
|
243
|
+
assert config.networks["localnet"].id == 61999
|
244
|
+
assert config.networks["localnet"].url == "http://localhost:8545"
|
245
|
+
assert config.networks["localnet"].accounts == ["0x123", "0x456"]
|
246
|
+
assert config.networks["localnet"].from_account == "0x123"
|
247
|
+
|
248
|
+
# Check testnet_asimov network
|
249
|
+
assert isinstance(config.networks["testnet_asimov"], NetworkConfigData)
|
250
|
+
assert config.networks["testnet_asimov"].id == 4221
|
251
|
+
assert config.networks["testnet_asimov"].url == "http://34.32.169.58:9151"
|
252
|
+
assert config.networks["testnet_asimov"].accounts == ["0x123", "0x456"]
|
253
|
+
assert config.networks["testnet_asimov"].from_account == "0x123"
|
254
|
+
|
255
|
+
# Check paths
|
256
|
+
assert isinstance(config.paths, PathConfig)
|
257
|
+
assert config.paths.contracts == Path("contracts")
|
258
|
+
|
259
|
+
# Check environment
|
260
|
+
assert config.environment == ".env"
|
261
|
+
|
262
|
+
|
263
|
+
def test_transform_raw_to_user_config_with_defaults():
|
264
|
+
# Test with empty config
|
265
|
+
config = transform_raw_to_user_config_with_defaults({})
|
266
|
+
assert isinstance(config, UserConfig)
|
267
|
+
assert all(key in config.__dict__ for key in VALID_ROOT_KEYS)
|
268
|
+
|
269
|
+
# Test with partial config
|
270
|
+
partial_config = {
|
271
|
+
"networks": {"default": "localnet", "localnet": {"url": "custom_url"}}
|
272
|
+
}
|
273
|
+
config = transform_raw_to_user_config_with_defaults(partial_config)
|
274
|
+
assert isinstance(config.networks["localnet"], NetworkConfigData)
|
275
|
+
assert config.networks["localnet"].url == "custom_url"
|
276
|
+
assert config.networks["localnet"].accounts is not None
|
277
|
+
assert config.networks["localnet"].from_account is not None
|
278
|
+
|
279
|
+
# Test with None network config
|
280
|
+
config = transform_raw_to_user_config_with_defaults(
|
281
|
+
{"networks": {"default": "localnet", "localnet": None}}
|
282
|
+
)
|
283
|
+
assert config.networks["localnet"] is not None
|
284
|
+
assert isinstance(config.networks["localnet"], NetworkConfigData)
|
285
|
+
|
286
|
+
# Test setting 'from' for non-default networks
|
287
|
+
test_config = {
|
288
|
+
"networks": {
|
289
|
+
"default": "localnet",
|
290
|
+
"localnet": {"url": "http://localhost:8545"},
|
291
|
+
"testnet": {"url": "http://testnet:8545", "accounts": ["0x123", "0x456"]},
|
292
|
+
"mainnet": {
|
293
|
+
"url": "http://mainnet:8545",
|
294
|
+
"accounts": ["0xabc", "0x789"],
|
295
|
+
"from": "0x789", # Already set
|
296
|
+
},
|
297
|
+
}
|
298
|
+
}
|
299
|
+
config = transform_raw_to_user_config_with_defaults(test_config)
|
300
|
+
|
301
|
+
# Verify testnet got 'from' set to first account
|
302
|
+
assert config.networks["testnet"].from_account == "0x123"
|
303
|
+
|
304
|
+
# Verify mainnet kept its existing 'from' value
|
305
|
+
assert config.networks["mainnet"].from_account == "0x789"
|
306
|
+
|
307
|
+
# Verify localnet (default network) behavior remains unchanged
|
308
|
+
assert config.networks["localnet"].from_account is not None
|
309
|
+
assert (
|
310
|
+
config.networks["localnet"].from_account in config.networks["localnet"].accounts
|
311
|
+
)
|
312
|
+
|
313
|
+
# Test with custom paths
|
314
|
+
custom_paths_config = {
|
315
|
+
"networks": {"default": "localnet"},
|
316
|
+
"paths": {"contracts": "custom/contracts/path"},
|
317
|
+
}
|
318
|
+
config = transform_raw_to_user_config_with_defaults(custom_paths_config)
|
319
|
+
assert config.paths.contracts == Path("custom/contracts/path")
|
320
|
+
|
321
|
+
# Test with custom environment
|
322
|
+
custom_env_config = {
|
323
|
+
"networks": {"default": "localnet"},
|
324
|
+
"environment": "custom.env",
|
325
|
+
}
|
326
|
+
config = transform_raw_to_user_config_with_defaults(custom_env_config)
|
327
|
+
assert config.environment == "custom.env"
|
328
|
+
|
329
|
+
|
330
|
+
@patch("pathlib.Path.cwd")
|
331
|
+
def test_user_config_exists(mock_cwd):
|
332
|
+
mock_path = MagicMock()
|
333
|
+
mock_cwd.return_value = mock_path
|
334
|
+
|
335
|
+
# Test when config exists
|
336
|
+
config_file = MagicMock()
|
337
|
+
config_file.name = "gltest.config.yaml"
|
338
|
+
config_file.is_file.return_value = True
|
339
|
+
mock_path.iterdir.return_value = [config_file]
|
340
|
+
assert user_config_exists() is True
|
341
|
+
|
342
|
+
# Test when config doesn't exist
|
343
|
+
other_file = MagicMock()
|
344
|
+
other_file.name = "other_file.txt"
|
345
|
+
other_file.is_file.return_value = True
|
346
|
+
mock_path.iterdir.return_value = [other_file]
|
347
|
+
assert user_config_exists() is False
|
348
|
+
|
349
|
+
# Test with no files
|
350
|
+
mock_path.iterdir.return_value = []
|
351
|
+
assert user_config_exists() is False
|
@@ -1,53 +0,0 @@
|
|
1
|
-
genlayer_test-0.1.3.dist-info/licenses/LICENSE,sha256=che_H4vE0QUx3HvWrAa1_jDEVInift0U6VO15-QqEls,1064
|
2
|
-
gltest/__init__.py,sha256=AK_YfRvwlhrOheOelUG8qIRG17on0-nFCF747dopg2w,332
|
3
|
-
gltest/assertions.py,sha256=0dEk0VxcHK4I7GZPHxJmz-2jaA60V499gOSR74rZbfM,1748
|
4
|
-
gltest/exceptions.py,sha256=deJPmrTe5gF33qkkKF2IVJY7lc_knI7Ql3N7jZ8aLZs,510
|
5
|
-
gltest/plugin_config.py,sha256=8Z97RtEJ89OcRbki_oRuBBVct_q56BFmKvthan1y9Y4,840
|
6
|
-
gltest/plugin_hooks.py,sha256=py1rzIR9QSsFOt8SEePPL96e-8DeiPFxvcPZurRlExM,1436
|
7
|
-
gltest/types.py,sha256=BODmwTr2gAUEiO9FjiuTiWwuKvXgo4xZWstQWNUfnlw,156
|
8
|
-
gltest/artifacts/__init__.py,sha256=qiJN5F1cVh_3fmxZeDFznoABxAdLhLqBfUUKwqXqvgo,87
|
9
|
-
gltest/artifacts/contract.py,sha256=0Sp8YTKBw7hwuhIQ7Q-PnchxNfusF0HNAcWaWPWT9Cg,3570
|
10
|
-
gltest/glchain/__init__.py,sha256=X-mEbREoAOe9K4n74C55gCiXH4wItzY5HTJcg3_F3mI,412
|
11
|
-
gltest/glchain/account.py,sha256=ZxYsfbtBXKVC5vV4pko3yyL6lhPljqIb68NgIgvInSc,403
|
12
|
-
gltest/glchain/client.py,sha256=q04LIQy5SCIrYZflZiTapfeQ-AaSTa0w369ehnVbJLM,532
|
13
|
-
gltest/glchain/contract.py,sha256=1pd4eAQlHXjnRF7hBvnoR-9f-HORUaYKVyV5P42io4o,8747
|
14
|
-
gltest/helpers/__init__.py,sha256=I7HiTu_H7_hP65zY6Wl02r-5eAMr2eZvqBVmusuQLX4,180
|
15
|
-
gltest/helpers/fixture_snapshot.py,sha256=DWLTsMbTnfhpv0_7_gkJpDKX4hJx-tlruX7x3FWL6UI,2073
|
16
|
-
gltest/helpers/take_snapshot.py,sha256=eXqEKXM2hcox3pLGIcNddobU8zXPQvD-Iwf87eHqW2s,1276
|
17
|
-
gltest_cli/main.py,sha256=Ti2-0Ev1x5_cM0D1UKqdgaDt80CDHEQGtdRne2qLm4M,53
|
18
|
-
tests/artifact/test_contract_definition.py,sha256=8X829MsNfEObtIMmotk6nRVLDEp5KfJE6zrAK4IPfCc,3323
|
19
|
-
tests/artifact/contracts/not_ic_contract.py,sha256=hQyGnYiiVceYdLI2WrvcFgPqzy1S4-YMb9FPhiHEGSA,510
|
20
|
-
tests/assertions/test_assertions.py,sha256=qzVrOdOM4xYtIy1sFHVAD_-naDHOequ23tEN0MELh0k,10781
|
21
|
-
tests/examples/contracts/football_prediction_market.py,sha256=kdouFijjeCdIJyaVJlgXcqbBAXecA9_YdhklSsIW-QM,3219
|
22
|
-
tests/examples/contracts/intelligent_oracle.py,sha256=WrNZWWoi1sz22Azt2EXgdWHDg5Ihca2pWUHrM9pVfQE,12319
|
23
|
-
tests/examples/contracts/intelligent_oracle_factory.py,sha256=ax496IZuDCA728rRcbjwTaM4Q4E-Y1jGkHsEcyf1cig,1490
|
24
|
-
tests/examples/contracts/llm_erc20.py,sha256=nfIs-7A79L46NgHQzWbPyEOUlzAlFLsf4K05acwKr_M,2523
|
25
|
-
tests/examples/contracts/log_indexer.py,sha256=VwMC8_Gy1Z1qjuy5GeEMyepjZ3Z5y7VAOrHMl5MrjxI,1852
|
26
|
-
tests/examples/contracts/multi_read_erc20.py,sha256=HsMJKGT9a9eZAO43Em7hCRfh1yyHDgcUbQ0gmOE1MXs,850
|
27
|
-
tests/examples/contracts/multi_tenant_storage.py,sha256=aGLPC76FegXdnIjMjeGsu3s3AbKK9dtV6t1d_KoI8rI,1897
|
28
|
-
tests/examples/contracts/read_erc20.py,sha256=kstiB93JHHajJe1GldzeawxnVYutjT8KE2d1bYTgggU,390
|
29
|
-
tests/examples/contracts/storage.py,sha256=GZHBXhjc94eEkdSO1UWgcop0fEo0hD57KZM0ds3pUFM,490
|
30
|
-
tests/examples/contracts/user_storage.py,sha256=j-RXxTIqb1dePYqP_pkeoCxxDq07VURryvzF_Q-sZmI,638
|
31
|
-
tests/examples/contracts/wizard_of_coin.py,sha256=BJ0Nv6N-JJP_Pk7YUSXPPRxX5_mDRBDlfL6nabeaoyA,1606
|
32
|
-
tests/examples/contracts/multi_file_contract/__init__.py,sha256=8O3BvoUrLSmc4uTf2jm7MyrmcaiGD0w8wPwotdAqZHQ,485
|
33
|
-
tests/examples/contracts/multi_file_contract/other.py,sha256=jHDtjUL3eAUgE6yOYKFw_RfAH7kIwk8CvxUjbWHNruk,236
|
34
|
-
tests/examples/tests/test_football_prediction_market.py,sha256=wFu024sq3IURLL1zyLyO_G1sRCjPTV7iImi87__dZ4Y,657
|
35
|
-
tests/examples/tests/test_intelligent_oracle_factory.py,sha256=Nw7jO9bjD79AETT2QQl0Vun-yxSAAuqGSdkQn2Y3WUw,5377
|
36
|
-
tests/examples/tests/test_llm_erc20.py,sha256=yL_5bbH2VC7jL3E6dDvSI6PfZ36bPtA4OxoysZpuLFc,1390
|
37
|
-
tests/examples/tests/test_log_indexer.py,sha256=Km44SiA8dlA4WBqwugXVBCQUlODdf1dB4p4nt24HG9k,2649
|
38
|
-
tests/examples/tests/test_multi_file_contract.py,sha256=pWmK6lcZrSAnDH09Z6Q-cXs8V6VGFhHkvgThvJKEB4U,512
|
39
|
-
tests/examples/tests/test_multi_file_contract_legacy.py,sha256=Jx_u0rDrQJspQgFo1KUddcFgTcOhcE-YLuLgk3tKrCA,527
|
40
|
-
tests/examples/tests/test_multi_read_erc20.py,sha256=Q3AKK7OZyTKRrG-tXmkPkoQOzQqVVDnFEWKDVVNVQLI,3062
|
41
|
-
tests/examples/tests/test_multi_tenant_storage.py,sha256=XNR1AUpxkzXlRv_ltdgAF-HUkpAvWqIQ7Fb93zEeR2o,2376
|
42
|
-
tests/examples/tests/test_read_erc20.py,sha256=_dXwdZoUTSMKwPhEmU3N2X3wNu2ke9ob0L3JKEyNjdE,1198
|
43
|
-
tests/examples/tests/test_storage.py,sha256=FmA-pJohMBHlNFVzLlY3-asnq0kV33E5SRDCM-lWzoQ,664
|
44
|
-
tests/examples/tests/test_storage_legacy.py,sha256=RNVnD0G9ilb4I2s0CPAAgJEuKUgEkkbItuesOfmv-pg,677
|
45
|
-
tests/examples/tests/test_user_storage.py,sha256=QEgt2p22LAyzBnBb0YW4BWa_Jasrt15vrr1GuxXqqbI,2180
|
46
|
-
tests/examples/tests/test_wizard_of_coin.py,sha256=aUDeV5w0XONMMS71Vzw80lHfcSM0z8RKPJSXAuDwRto,392
|
47
|
-
tests/plugin/conftest.py,sha256=RKdoE5_zcMimeojAoA_GSFI9du4pMzMi1vZ1njtfoAs,28
|
48
|
-
tests/plugin/test_plugin_hooks.py,sha256=FQOrkhoXLinq0sjvoYjr63Oqg-ZVPcNFeUrK4bqrn4E,2020
|
49
|
-
genlayer_test-0.1.3.dist-info/METADATA,sha256=10N09rjm2S2uoCmyyVu6A9hPuU6w2-_rP8jU4HYsNc0,14814
|
50
|
-
genlayer_test-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
51
|
-
genlayer_test-0.1.3.dist-info/entry_points.txt,sha256=rXhrPVq2IhVsd4uWzxzwCTx7jA1KcQIVNxDCUuxq4f8,89
|
52
|
-
genlayer_test-0.1.3.dist-info/top_level.txt,sha256=-qiGZxTRBytujzgVcKpxjvQ-WNeUDjXa59ceGMwMpko,24
|
53
|
-
genlayer_test-0.1.3.dist-info/RECORD,,
|
gltest/plugin_config.py
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
|
3
|
-
_contracts_dir = None
|
4
|
-
_rpc_url = None
|
5
|
-
_default_wait_interval = None
|
6
|
-
_default_wait_retries = None
|
7
|
-
|
8
|
-
|
9
|
-
def set_contracts_dir(path: Path):
|
10
|
-
global _contracts_dir
|
11
|
-
_contracts_dir = path
|
12
|
-
|
13
|
-
|
14
|
-
def get_contracts_dir() -> Path:
|
15
|
-
return Path(_contracts_dir)
|
16
|
-
|
17
|
-
|
18
|
-
def set_rpc_url(rpc_url: str):
|
19
|
-
global _rpc_url
|
20
|
-
_rpc_url = rpc_url
|
21
|
-
|
22
|
-
|
23
|
-
def get_rpc_url() -> str:
|
24
|
-
return _rpc_url
|
25
|
-
|
26
|
-
|
27
|
-
def set_default_wait_interval(default_wait_interval: int):
|
28
|
-
global _default_wait_interval
|
29
|
-
_default_wait_interval = default_wait_interval
|
30
|
-
|
31
|
-
|
32
|
-
def get_default_wait_interval() -> int:
|
33
|
-
return _default_wait_interval
|
34
|
-
|
35
|
-
|
36
|
-
def set_default_wait_retries(default_wait_retries: int):
|
37
|
-
global _default_wait_retries
|
38
|
-
_default_wait_retries = default_wait_retries
|
39
|
-
|
40
|
-
|
41
|
-
def get_default_wait_retries() -> int:
|
42
|
-
return _default_wait_retries
|
gltest/plugin_hooks.py
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
from gltest.plugin_config import (
|
2
|
-
set_contracts_dir,
|
3
|
-
set_default_wait_interval,
|
4
|
-
set_default_wait_retries,
|
5
|
-
set_rpc_url,
|
6
|
-
)
|
7
|
-
from pathlib import Path
|
8
|
-
from genlayer_py.chains.localnet import SIMULATOR_JSON_RPC_URL
|
9
|
-
|
10
|
-
|
11
|
-
def pytest_addoption(parser):
|
12
|
-
group = parser.getgroup("gltest")
|
13
|
-
group.addoption(
|
14
|
-
"--contracts-dir",
|
15
|
-
action="store",
|
16
|
-
default="contracts",
|
17
|
-
help="Directory containing contract files",
|
18
|
-
)
|
19
|
-
|
20
|
-
group.addoption(
|
21
|
-
"--default-wait-interval",
|
22
|
-
action="store",
|
23
|
-
default=10000,
|
24
|
-
help="Default wait interval for waiting transaction receipts",
|
25
|
-
)
|
26
|
-
|
27
|
-
group.addoption(
|
28
|
-
"--default-wait-retries",
|
29
|
-
action="store",
|
30
|
-
default=15,
|
31
|
-
help="Default wait retries for waiting transaction receipts",
|
32
|
-
)
|
33
|
-
|
34
|
-
group.addoption(
|
35
|
-
"--rpc-url",
|
36
|
-
action="store",
|
37
|
-
default=SIMULATOR_JSON_RPC_URL,
|
38
|
-
help="RPC URL for the genlayer network",
|
39
|
-
)
|
40
|
-
|
41
|
-
|
42
|
-
def pytest_configure(config):
|
43
|
-
contracts_dir = config.getoption("--contracts-dir")
|
44
|
-
default_wait_interval = config.getoption("--default-wait-interval")
|
45
|
-
default_wait_retries = config.getoption("--default-wait-retries")
|
46
|
-
rpc_url = config.getoption("--rpc-url")
|
47
|
-
|
48
|
-
set_contracts_dir(Path(contracts_dir))
|
49
|
-
set_default_wait_interval(int(default_wait_interval))
|
50
|
-
set_default_wait_retries(int(default_wait_retries))
|
51
|
-
set_rpc_url(str(rpc_url))
|