genlayer-test 0.4.0__py3-none-any.whl → 0.5.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.4.0.dist-info → genlayer_test-0.5.0.dist-info}/METADATA +257 -24
- genlayer_test-0.5.0.dist-info/RECORD +76 -0
- gltest/__init__.py +7 -6
- gltest/{glchain/client.py → clients.py} +1 -1
- gltest/contracts/__init__.py +4 -0
- gltest/contracts/contract.py +205 -0
- gltest/{glchain/contract.py → contracts/contract_factory.py} +47 -144
- gltest/contracts/contract_functions.py +62 -0
- gltest/contracts/method_stats.py +163 -0
- gltest/contracts/stats_collector.py +259 -0
- gltest/contracts/utils.py +12 -0
- gltest/fixtures.py +2 -6
- gltest/helpers/take_snapshot.py +1 -1
- gltest/logging.py +17 -0
- gltest/types.py +1 -0
- gltest_cli/config/constants.py +2 -0
- gltest_cli/config/plugin.py +121 -49
- gltest_cli/config/pytest_context.py +9 -0
- gltest_cli/config/types.py +73 -8
- gltest_cli/config/user.py +71 -28
- gltest_cli/logging.py +4 -3
- tests/examples/contracts/football_prediction_market.py +1 -1
- tests/examples/tests/test_football_prediction_market.py +2 -2
- tests/examples/tests/test_intelligent_oracle_factory.py +8 -24
- tests/examples/tests/test_llm_erc20.py +5 -5
- tests/examples/tests/test_llm_erc20_analyze.py +50 -0
- tests/examples/tests/test_log_indexer.py +23 -11
- tests/examples/tests/test_multi_file_contract.py +2 -2
- tests/examples/tests/test_multi_file_contract_legacy.py +2 -2
- tests/examples/tests/test_multi_read_erc20.py +14 -12
- tests/examples/tests/test_multi_tenant_storage.py +11 -7
- tests/examples/tests/test_read_erc20.py +1 -1
- tests/examples/tests/test_storage.py +4 -4
- tests/examples/tests/test_storage_legacy.py +5 -3
- tests/examples/tests/test_user_storage.py +20 -10
- tests/examples/tests/test_wizard_of_coin.py +1 -1
- tests/gltest_cli/config/test_config_integration.py +432 -0
- tests/gltest_cli/config/test_general_config.py +406 -0
- tests/gltest_cli/config/test_plugin.py +164 -1
- tests/gltest_cli/config/test_user.py +61 -1
- genlayer_test-0.4.0.dist-info/RECORD +0 -66
- gltest/glchain/__init__.py +0 -16
- {genlayer_test-0.4.0.dist-info → genlayer_test-0.5.0.dist-info}/WHEEL +0 -0
- {genlayer_test-0.4.0.dist-info → genlayer_test-0.5.0.dist-info}/entry_points.txt +0 -0
- {genlayer_test-0.4.0.dist-info → genlayer_test-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {genlayer_test-0.4.0.dist-info → genlayer_test-0.5.0.dist-info}/top_level.txt +0 -0
- /gltest/{glchain/account.py → accounts.py} +0 -0
@@ -61,11 +61,11 @@ def test_multi_read_erc20(setup_validators):
|
|
61
61
|
from_account_doge.address,
|
62
62
|
[doge_contract.address, shiba_contract.address],
|
63
63
|
]
|
64
|
-
)
|
64
|
+
).transact()
|
65
65
|
assert tx_execution_succeeded(transaction_response_call)
|
66
66
|
|
67
67
|
# check balances
|
68
|
-
call_method_response_get_balances = multi_read_contract.get_balances(args=[])
|
68
|
+
call_method_response_get_balances = multi_read_contract.get_balances(args=[]).call()
|
69
69
|
assert call_method_response_get_balances == {
|
70
70
|
from_account_doge.address: {
|
71
71
|
doge_contract.address: TOKEN_TOTAL_SUPPLY,
|
@@ -74,20 +74,22 @@ def test_multi_read_erc20(setup_validators):
|
|
74
74
|
}
|
75
75
|
|
76
76
|
# update balances for shiba account
|
77
|
-
transaction_response_call =
|
78
|
-
from_account_shiba
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
transaction_response_call = (
|
78
|
+
multi_read_contract.connect(from_account_shiba)
|
79
|
+
.update_token_balances(
|
80
|
+
args=[
|
81
|
+
from_account_shiba.address,
|
82
|
+
[doge_contract.address, shiba_contract.address],
|
83
|
+
]
|
84
|
+
)
|
85
|
+
.transact()
|
84
86
|
)
|
85
87
|
assert tx_execution_succeeded(transaction_response_call)
|
86
88
|
|
87
89
|
# check balances
|
88
|
-
call_method_response_get_balances =
|
89
|
-
from_account_shiba
|
90
|
-
)
|
90
|
+
call_method_response_get_balances = (
|
91
|
+
multi_read_contract.connect(from_account_shiba).get_balances(args=[]).call()
|
92
|
+
)
|
91
93
|
|
92
94
|
assert call_method_response_get_balances == {
|
93
95
|
from_account_doge.address: {
|
@@ -48,19 +48,23 @@ def test_multi_tenant_storage(setup_validators):
|
|
48
48
|
]
|
49
49
|
)
|
50
50
|
# update storage for first contract
|
51
|
-
transaction_response_call =
|
52
|
-
account=user_account_a
|
53
|
-
|
51
|
+
transaction_response_call = (
|
52
|
+
multi_tenant_storage_contract.connect(account=user_account_a)
|
53
|
+
.update_storage(args=["user_a_storage"])
|
54
|
+
.transact()
|
55
|
+
)
|
54
56
|
assert tx_execution_succeeded(transaction_response_call)
|
55
57
|
|
56
58
|
# update storage for second contract
|
57
|
-
transaction_response_call =
|
58
|
-
account=user_account_b
|
59
|
-
|
59
|
+
transaction_response_call = (
|
60
|
+
multi_tenant_storage_contract.connect(account=user_account_b)
|
61
|
+
.update_storage(args=["user_b_storage"])
|
62
|
+
.transact()
|
63
|
+
)
|
60
64
|
assert tx_execution_succeeded(transaction_response_call)
|
61
65
|
|
62
66
|
# get all storages
|
63
|
-
storages = multi_tenant_storage_contract.get_all_storages(args=[])
|
67
|
+
storages = multi_tenant_storage_contract.get_all_storages(args=[]).call()
|
64
68
|
|
65
69
|
assert storages == {
|
66
70
|
second_storage_contract.address: "user_a_storage",
|
@@ -12,15 +12,15 @@ def test_storage(setup_validators):
|
|
12
12
|
contract = factory.deploy(args=[INITIAL_STATE], wait_retries=40)
|
13
13
|
|
14
14
|
# Get initial state
|
15
|
-
contract_state_1 = contract.get_storage(args=[])
|
15
|
+
contract_state_1 = contract.get_storage(args=[]).call()
|
16
16
|
assert contract_state_1 == INITIAL_STATE
|
17
17
|
|
18
18
|
# Update State
|
19
19
|
transaction_response_call_1 = contract.update_storage(
|
20
|
-
args=[UPDATED_STATE]
|
21
|
-
)
|
20
|
+
args=[UPDATED_STATE]
|
21
|
+
).transact(wait_retries=40)
|
22
22
|
assert tx_execution_succeeded(transaction_response_call_1)
|
23
23
|
|
24
24
|
# Get Updated State
|
25
|
-
contract_state_2 = contract.get_storage(args=[])
|
25
|
+
contract_state_2 = contract.get_storage(args=[]).call()
|
26
26
|
assert contract_state_2 == UPDATED_STATE
|
@@ -12,13 +12,15 @@ def test_storage_legacy(setup_validators):
|
|
12
12
|
contract = factory.deploy(args=[INITIAL_STATE])
|
13
13
|
|
14
14
|
# Get initial state
|
15
|
-
contract_state_1 = contract.get_storage(args=[])
|
15
|
+
contract_state_1 = contract.get_storage(args=[]).call()
|
16
16
|
assert contract_state_1 == INITIAL_STATE
|
17
17
|
|
18
18
|
# Update State
|
19
|
-
transaction_response_call_1 = contract.update_storage(
|
19
|
+
transaction_response_call_1 = contract.update_storage(
|
20
|
+
args=[UPDATED_STATE]
|
21
|
+
).transact()
|
20
22
|
assert tx_execution_succeeded(transaction_response_call_1)
|
21
23
|
|
22
24
|
# Get Updated State
|
23
|
-
contract_state_2 = contract.get_storage(args=[])
|
25
|
+
contract_state_2 = contract.get_storage(args=[]).call()
|
24
26
|
assert contract_state_2 == UPDATED_STATE
|
@@ -37,41 +37,51 @@ def test_user_storage(setup_validators):
|
|
37
37
|
contract = factory.deploy()
|
38
38
|
|
39
39
|
# GET Initial State
|
40
|
-
contract_state_1 = contract.get_complete_storage(args=[])
|
40
|
+
contract_state_1 = contract.get_complete_storage(args=[]).call()
|
41
41
|
assert contract_state_1 == {}
|
42
42
|
|
43
43
|
# ADD User A State
|
44
|
-
transaction_response_call_1 = contract.update_storage(
|
44
|
+
transaction_response_call_1 = contract.update_storage(
|
45
|
+
args=[INITIAL_STATE_USER_A]
|
46
|
+
).transact()
|
45
47
|
assert tx_execution_succeeded(transaction_response_call_1)
|
46
48
|
|
47
49
|
# Get Updated State
|
48
|
-
contract_state_2_1 = contract.get_complete_storage(args=[])
|
50
|
+
contract_state_2_1 = contract.get_complete_storage(args=[]).call()
|
49
51
|
assert contract_state_2_1[from_account_a.address] == INITIAL_STATE_USER_A
|
50
52
|
|
51
53
|
# Get Updated State
|
52
|
-
contract_state_2_2 = contract.get_account_storage(
|
54
|
+
contract_state_2_2 = contract.get_account_storage(
|
55
|
+
args=[from_account_a.address]
|
56
|
+
).call()
|
53
57
|
assert contract_state_2_2 == INITIAL_STATE_USER_A
|
54
58
|
|
55
59
|
# ADD User B State
|
56
|
-
transaction_response_call_2 =
|
57
|
-
|
60
|
+
transaction_response_call_2 = (
|
61
|
+
contract.connect(from_account_b)
|
62
|
+
.update_storage(args=[INITIAL_STATE_USER_B])
|
63
|
+
.transact()
|
58
64
|
)
|
59
65
|
assert tx_execution_succeeded(transaction_response_call_2)
|
60
66
|
|
61
67
|
# Get Updated State
|
62
|
-
contract_state_3 = contract.get_complete_storage(args=[])
|
68
|
+
contract_state_3 = contract.get_complete_storage(args=[]).call()
|
63
69
|
assert contract_state_3[from_account_a.address] == INITIAL_STATE_USER_A
|
64
70
|
assert contract_state_3[from_account_b.address] == INITIAL_STATE_USER_B
|
65
71
|
|
66
72
|
# UPDATE User A State
|
67
|
-
transaction_response_call_3 = contract.update_storage(
|
73
|
+
transaction_response_call_3 = contract.update_storage(
|
74
|
+
args=[UPDATED_STATE_USER_A]
|
75
|
+
).transact()
|
68
76
|
assert tx_execution_succeeded(transaction_response_call_3)
|
69
77
|
|
70
78
|
# Get Updated State
|
71
|
-
contract_state_4_1 = contract.get_complete_storage(args=[])
|
79
|
+
contract_state_4_1 = contract.get_complete_storage(args=[]).call()
|
72
80
|
assert contract_state_4_1[from_account_a.address] == UPDATED_STATE_USER_A
|
73
81
|
assert contract_state_4_1[from_account_b.address] == INITIAL_STATE_USER_B
|
74
82
|
|
75
83
|
# Get Updated State
|
76
|
-
contract_state_4_2 = contract.get_account_storage(
|
84
|
+
contract_state_4_2 = contract.get_account_storage(
|
85
|
+
args=[from_account_b.address]
|
86
|
+
).call()
|
77
87
|
assert contract_state_4_2 == INITIAL_STATE_USER_B
|
@@ -0,0 +1,432 @@
|
|
1
|
+
def test_leader_only_network_config_true(pytester):
|
2
|
+
pytester.makepyfile(
|
3
|
+
"""
|
4
|
+
from gltest_cli.config.general import get_general_config
|
5
|
+
|
6
|
+
def test_leader_only_network_config():
|
7
|
+
general_config = get_general_config()
|
8
|
+
assert general_config.get_leader_only() == True
|
9
|
+
"""
|
10
|
+
)
|
11
|
+
|
12
|
+
config_content = """
|
13
|
+
networks:
|
14
|
+
default: localnet
|
15
|
+
localnet:
|
16
|
+
url: "http://127.0.0.1:4000/api"
|
17
|
+
leader_only: true
|
18
|
+
|
19
|
+
paths:
|
20
|
+
contracts: "contracts"
|
21
|
+
|
22
|
+
environment: .env
|
23
|
+
"""
|
24
|
+
|
25
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
26
|
+
|
27
|
+
result = pytester.runpytest("-v")
|
28
|
+
|
29
|
+
result.stdout.fnmatch_lines(
|
30
|
+
[
|
31
|
+
"*::test_leader_only_network_config PASSED*",
|
32
|
+
]
|
33
|
+
)
|
34
|
+
assert result.ret == 0
|
35
|
+
|
36
|
+
|
37
|
+
def test_leader_only_network_config_false(pytester):
|
38
|
+
pytester.makepyfile(
|
39
|
+
"""
|
40
|
+
from gltest_cli.config.general import get_general_config
|
41
|
+
|
42
|
+
def test_leader_only_network_config():
|
43
|
+
general_config = get_general_config()
|
44
|
+
assert general_config.get_leader_only() == False
|
45
|
+
"""
|
46
|
+
)
|
47
|
+
|
48
|
+
config_content = """
|
49
|
+
networks:
|
50
|
+
default: localnet
|
51
|
+
localnet:
|
52
|
+
url: "http://127.0.0.1:4000/api"
|
53
|
+
leader_only: false
|
54
|
+
|
55
|
+
paths:
|
56
|
+
contracts: "contracts"
|
57
|
+
|
58
|
+
environment: .env
|
59
|
+
"""
|
60
|
+
|
61
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
62
|
+
|
63
|
+
result = pytester.runpytest("-v")
|
64
|
+
|
65
|
+
result.stdout.fnmatch_lines(
|
66
|
+
[
|
67
|
+
"*::test_leader_only_network_config PASSED*",
|
68
|
+
]
|
69
|
+
)
|
70
|
+
assert result.ret == 0
|
71
|
+
|
72
|
+
|
73
|
+
def test_leader_only_cli_overrides_network_config(pytester):
|
74
|
+
pytester.makepyfile(
|
75
|
+
"""
|
76
|
+
from gltest_cli.config.general import get_general_config
|
77
|
+
|
78
|
+
def test_leader_only_cli_overrides():
|
79
|
+
general_config = get_general_config()
|
80
|
+
assert general_config.get_leader_only() == True
|
81
|
+
"""
|
82
|
+
)
|
83
|
+
|
84
|
+
config_content = """
|
85
|
+
networks:
|
86
|
+
default: localnet
|
87
|
+
localnet:
|
88
|
+
url: "http://127.0.0.1:4000/api"
|
89
|
+
leader_only: false
|
90
|
+
|
91
|
+
paths:
|
92
|
+
contracts: "contracts"
|
93
|
+
|
94
|
+
environment: .env
|
95
|
+
"""
|
96
|
+
|
97
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
98
|
+
|
99
|
+
# CLI flag should override network config
|
100
|
+
result = pytester.runpytest("--leader-only", "-v")
|
101
|
+
|
102
|
+
result.stdout.fnmatch_lines(
|
103
|
+
[
|
104
|
+
"*::test_leader_only_cli_overrides PASSED*",
|
105
|
+
]
|
106
|
+
)
|
107
|
+
assert result.ret == 0
|
108
|
+
|
109
|
+
|
110
|
+
def test_leader_only_network_config_default(pytester):
|
111
|
+
pytester.makepyfile(
|
112
|
+
"""
|
113
|
+
from gltest_cli.config.general import get_general_config
|
114
|
+
|
115
|
+
def test_leader_only_network_config_default():
|
116
|
+
general_config = get_general_config()
|
117
|
+
assert general_config.get_leader_only() == False
|
118
|
+
"""
|
119
|
+
)
|
120
|
+
|
121
|
+
config_content = """
|
122
|
+
networks:
|
123
|
+
default: localnet
|
124
|
+
localnet:
|
125
|
+
url: "http://127.0.0.1:4000/api"
|
126
|
+
|
127
|
+
paths:
|
128
|
+
contracts: "contracts"
|
129
|
+
|
130
|
+
environment: .env
|
131
|
+
"""
|
132
|
+
|
133
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
134
|
+
|
135
|
+
result = pytester.runpytest("-v")
|
136
|
+
result.stdout.fnmatch_lines(
|
137
|
+
[
|
138
|
+
"*::test_leader_only_network_config_default PASSED*",
|
139
|
+
]
|
140
|
+
)
|
141
|
+
assert result.ret == 0
|
142
|
+
|
143
|
+
|
144
|
+
def test_custom_accounts_config(pytester):
|
145
|
+
"""Test custom accounts configuration."""
|
146
|
+
pytester.makepyfile(
|
147
|
+
"""
|
148
|
+
from gltest_cli.config.general import get_general_config
|
149
|
+
|
150
|
+
def test_custom_accounts():
|
151
|
+
general_config = get_general_config()
|
152
|
+
accounts = general_config.get_accounts_keys()
|
153
|
+
assert len(accounts) == 3
|
154
|
+
assert accounts[0] == "account1_private_key"
|
155
|
+
assert accounts[1] == "account2_private_key"
|
156
|
+
assert accounts[2] == "account3_private_key"
|
157
|
+
from_account = general_config.get_default_account_key()
|
158
|
+
assert from_account == "account1_private_key"
|
159
|
+
"""
|
160
|
+
)
|
161
|
+
|
162
|
+
config_content = """
|
163
|
+
networks:
|
164
|
+
default: localnet
|
165
|
+
localnet:
|
166
|
+
url: "http://127.0.0.1:4000/api"
|
167
|
+
accounts:
|
168
|
+
- "account1_private_key"
|
169
|
+
- "account2_private_key"
|
170
|
+
- "account3_private_key"
|
171
|
+
|
172
|
+
paths:
|
173
|
+
contracts: "contracts"
|
174
|
+
|
175
|
+
environment: .env
|
176
|
+
"""
|
177
|
+
|
178
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
179
|
+
|
180
|
+
result = pytester.runpytest("-v")
|
181
|
+
result.stdout.fnmatch_lines(
|
182
|
+
[
|
183
|
+
"*::test_custom_accounts PASSED*",
|
184
|
+
]
|
185
|
+
)
|
186
|
+
assert result.ret == 0
|
187
|
+
|
188
|
+
|
189
|
+
def test_from_account_config(pytester):
|
190
|
+
"""Test 'from' account configuration."""
|
191
|
+
pytester.makepyfile(
|
192
|
+
"""
|
193
|
+
from gltest_cli.config.general import get_general_config
|
194
|
+
|
195
|
+
def test_from_account():
|
196
|
+
general_config = get_general_config()
|
197
|
+
from_account = general_config.get_default_account_key()
|
198
|
+
assert from_account == "account2_private_key"
|
199
|
+
"""
|
200
|
+
)
|
201
|
+
|
202
|
+
config_content = """
|
203
|
+
networks:
|
204
|
+
default: localnet
|
205
|
+
localnet:
|
206
|
+
url: "http://127.0.0.1:4000/api"
|
207
|
+
accounts:
|
208
|
+
- "account1_private_key"
|
209
|
+
- "account2_private_key"
|
210
|
+
- "account3_private_key"
|
211
|
+
from: "account2_private_key"
|
212
|
+
|
213
|
+
paths:
|
214
|
+
contracts: "contracts"
|
215
|
+
|
216
|
+
environment: .env
|
217
|
+
"""
|
218
|
+
|
219
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
220
|
+
|
221
|
+
result = pytester.runpytest("-v")
|
222
|
+
result.stdout.fnmatch_lines(
|
223
|
+
[
|
224
|
+
"*::test_from_account PASSED*",
|
225
|
+
]
|
226
|
+
)
|
227
|
+
assert result.ret == 0
|
228
|
+
|
229
|
+
|
230
|
+
def test_multiple_networks_config(pytester):
|
231
|
+
"""Test multiple networks configuration."""
|
232
|
+
pytester.makepyfile(
|
233
|
+
"""
|
234
|
+
from gltest_cli.config.general import get_general_config
|
235
|
+
|
236
|
+
def test_multiple_networks():
|
237
|
+
general_config = get_general_config()
|
238
|
+
# Default should be testnet
|
239
|
+
assert general_config.get_network_name() == "testnet"
|
240
|
+
rpc_url = general_config.get_rpc_url()
|
241
|
+
assert rpc_url == "https://testnet.example.com"
|
242
|
+
"""
|
243
|
+
)
|
244
|
+
|
245
|
+
config_content = """
|
246
|
+
networks:
|
247
|
+
default: testnet
|
248
|
+
localnet:
|
249
|
+
id: 61999
|
250
|
+
url: "http://127.0.0.1:4000/api"
|
251
|
+
accounts:
|
252
|
+
- "local_account1"
|
253
|
+
- "local_account2"
|
254
|
+
testnet:
|
255
|
+
id: 5555
|
256
|
+
url: "https://testnet.example.com"
|
257
|
+
accounts:
|
258
|
+
- "testnet_account1"
|
259
|
+
- "testnet_account2"
|
260
|
+
leader_only: true
|
261
|
+
|
262
|
+
paths:
|
263
|
+
contracts: "contracts"
|
264
|
+
|
265
|
+
environment: .env
|
266
|
+
"""
|
267
|
+
|
268
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
269
|
+
|
270
|
+
result = pytester.runpytest("-v")
|
271
|
+
result.stdout.fnmatch_lines(
|
272
|
+
[
|
273
|
+
"*::test_multiple_networks PASSED*",
|
274
|
+
]
|
275
|
+
)
|
276
|
+
assert result.ret == 0
|
277
|
+
|
278
|
+
|
279
|
+
def test_custom_paths_config(pytester):
|
280
|
+
"""Test custom paths configuration."""
|
281
|
+
pytester.makepyfile(
|
282
|
+
"""
|
283
|
+
from gltest_cli.config.general import get_general_config
|
284
|
+
from pathlib import Path
|
285
|
+
|
286
|
+
def test_custom_paths():
|
287
|
+
general_config = get_general_config()
|
288
|
+
assert general_config.get_contracts_dir() == Path("src/contracts")
|
289
|
+
assert general_config.get_artifacts_dir() == Path("build/artifacts")
|
290
|
+
"""
|
291
|
+
)
|
292
|
+
|
293
|
+
config_content = """
|
294
|
+
networks:
|
295
|
+
default: localnet
|
296
|
+
localnet:
|
297
|
+
url: "http://127.0.0.1:4000/api"
|
298
|
+
|
299
|
+
paths:
|
300
|
+
contracts: "src/contracts"
|
301
|
+
artifacts: "build/artifacts"
|
302
|
+
|
303
|
+
environment: .env
|
304
|
+
"""
|
305
|
+
|
306
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
307
|
+
|
308
|
+
result = pytester.runpytest("-v")
|
309
|
+
result.stdout.fnmatch_lines(
|
310
|
+
[
|
311
|
+
"*::test_custom_paths PASSED*",
|
312
|
+
]
|
313
|
+
)
|
314
|
+
assert result.ret == 0
|
315
|
+
|
316
|
+
|
317
|
+
def test_custom_environment_file(pytester):
|
318
|
+
"""Test custom environment file configuration."""
|
319
|
+
pytester.makepyfile(
|
320
|
+
"""
|
321
|
+
from gltest_cli.config.general import get_general_config
|
322
|
+
|
323
|
+
def test_custom_environment():
|
324
|
+
general_config = get_general_config()
|
325
|
+
assert general_config.user_config.environment == ".env.test"
|
326
|
+
"""
|
327
|
+
)
|
328
|
+
|
329
|
+
config_content = """
|
330
|
+
networks:
|
331
|
+
default: localnet
|
332
|
+
localnet:
|
333
|
+
url: "http://127.0.0.1:4000/api"
|
334
|
+
|
335
|
+
paths:
|
336
|
+
contracts: "contracts"
|
337
|
+
|
338
|
+
environment: .env.test
|
339
|
+
"""
|
340
|
+
|
341
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
342
|
+
|
343
|
+
result = pytester.runpytest("-v")
|
344
|
+
result.stdout.fnmatch_lines(
|
345
|
+
[
|
346
|
+
"*::test_custom_environment PASSED*",
|
347
|
+
]
|
348
|
+
)
|
349
|
+
assert result.ret == 0
|
350
|
+
|
351
|
+
|
352
|
+
def test_cli_network_override(pytester):
|
353
|
+
"""Test CLI network override of config file."""
|
354
|
+
pytester.makepyfile(
|
355
|
+
"""
|
356
|
+
from gltest_cli.config.general import get_general_config
|
357
|
+
|
358
|
+
def test_network_override():
|
359
|
+
general_config = get_general_config()
|
360
|
+
assert general_config.get_network_name() == "testnet"
|
361
|
+
rpc_url = general_config.get_rpc_url()
|
362
|
+
assert rpc_url == "https://testnet.example.com"
|
363
|
+
"""
|
364
|
+
)
|
365
|
+
|
366
|
+
config_content = """
|
367
|
+
networks:
|
368
|
+
default: localnet
|
369
|
+
localnet:
|
370
|
+
id: 61999
|
371
|
+
url: "http://127.0.0.1:4000/api"
|
372
|
+
accounts:
|
373
|
+
- "local_account1"
|
374
|
+
testnet:
|
375
|
+
id: 5555
|
376
|
+
url: "https://testnet.example.com"
|
377
|
+
accounts:
|
378
|
+
- "testnet_account1"
|
379
|
+
|
380
|
+
paths:
|
381
|
+
contracts: "contracts"
|
382
|
+
|
383
|
+
environment: .env
|
384
|
+
"""
|
385
|
+
|
386
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
387
|
+
|
388
|
+
result = pytester.runpytest("--network=testnet", "-v")
|
389
|
+
result.stdout.fnmatch_lines(
|
390
|
+
[
|
391
|
+
"*::test_network_override PASSED*",
|
392
|
+
]
|
393
|
+
)
|
394
|
+
assert result.ret == 0
|
395
|
+
|
396
|
+
|
397
|
+
def test_wait_interval_and_retries_config(pytester):
|
398
|
+
"""Test default wait interval and retries from CLI."""
|
399
|
+
pytester.makepyfile(
|
400
|
+
"""
|
401
|
+
from gltest_cli.config.general import get_general_config
|
402
|
+
|
403
|
+
def test_wait_config():
|
404
|
+
general_config = get_general_config()
|
405
|
+
assert general_config.get_default_wait_interval() == 3000
|
406
|
+
assert general_config.get_default_wait_retries() == 20
|
407
|
+
"""
|
408
|
+
)
|
409
|
+
|
410
|
+
config_content = """
|
411
|
+
networks:
|
412
|
+
default: localnet
|
413
|
+
localnet:
|
414
|
+
url: "http://127.0.0.1:4000/api"
|
415
|
+
|
416
|
+
paths:
|
417
|
+
contracts: "contracts"
|
418
|
+
|
419
|
+
environment: .env
|
420
|
+
"""
|
421
|
+
|
422
|
+
pytester.makefile(".config.yaml", **{"gltest": config_content})
|
423
|
+
|
424
|
+
result = pytester.runpytest(
|
425
|
+
"--default-wait-interval=3000", "--default-wait-retries=20", "-v"
|
426
|
+
)
|
427
|
+
result.stdout.fnmatch_lines(
|
428
|
+
[
|
429
|
+
"*::test_wait_config PASSED*",
|
430
|
+
]
|
431
|
+
)
|
432
|
+
assert result.ret == 0
|