genlayer-test 2.0.0__py3-none-any.whl → 2.1.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-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/METADATA +1 -1
- {genlayer_test-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/RECORD +12 -12
- gltest/contracts/contract.py +13 -5
- gltest/contracts/contract_factory.py +25 -7
- gltest/contracts/contract_functions.py +9 -6
- gltest/types.py +1 -0
- gltest_cli/config/plugin.py +2 -2
- tests/examples/tests/test_intelligent_oracle_factory.py +5 -21
- {genlayer_test-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/WHEEL +0 -0
- {genlayer_test-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/entry_points.txt +0 -0
- {genlayer_test-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/licenses/LICENSE +0 -0
- {genlayer_test-2.0.0.dist-info → genlayer_test-2.1.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
genlayer_test-2.
|
1
|
+
genlayer_test-2.1.0.dist-info/licenses/LICENSE,sha256=che_H4vE0QUx3HvWrAa1_jDEVInift0U6VO15-QqEls,1064
|
2
2
|
gltest/__init__.py,sha256=qoBV3IgDJr8uh9262XsWNMhi-ilkSgMqKVC9FVMk7cw,372
|
3
3
|
gltest/accounts.py,sha256=HUmWguJMolggQaZNRPw-LGlRlQCjLLdUanKRowMv6pI,812
|
4
4
|
gltest/assertions.py,sha256=0dEk0VxcHK4I7GZPHxJmz-2jaA60V499gOSR74rZbfM,1748
|
@@ -6,13 +6,13 @@ gltest/clients.py,sha256=1dX6wmG3QCevQRLbSaFlHymZSb-sJ5aYwet1IoX2nbA,1554
|
|
6
6
|
gltest/exceptions.py,sha256=deJPmrTe5gF33qkkKF2IVJY7lc_knI7Ql3N7jZ8aLZs,510
|
7
7
|
gltest/fixtures.py,sha256=EJXmqcC3LD03v07mepacFl58lAdhbLj6bP5rtALYISk,2507
|
8
8
|
gltest/logging.py,sha256=jAkHsuMm-AEx1Xu1srU6W-0YzTwXJB48mCK-OVzAiN4,342
|
9
|
-
gltest/types.py,sha256=
|
9
|
+
gltest/types.py,sha256=Kj6UuTpRXkA4c5ystKfwgXuCiRJ1VMkbgvP7Auvznhw,184
|
10
10
|
gltest/artifacts/__init__.py,sha256=qTt3TE19gVNWnQLUlt5aDe4nNvJ2YJ1jzDkMmYIsCG0,194
|
11
11
|
gltest/artifacts/contract.py,sha256=KChpmfjZod_0dVB8y-dvWz6IVm7QlIJsgG2ArtvVDaU,6457
|
12
12
|
gltest/contracts/__init__.py,sha256=A9bvEtYOoqoHS8TLlFBfmNOnfwdsJPEf-AZuikagCHM,166
|
13
|
-
gltest/contracts/contract.py,sha256=
|
14
|
-
gltest/contracts/contract_factory.py,sha256
|
15
|
-
gltest/contracts/contract_functions.py,sha256=
|
13
|
+
gltest/contracts/contract.py,sha256=se8wpRIu-PGkLkvqz-DWikacw4n4vl2JAJD84YVn4sc,6735
|
14
|
+
gltest/contracts/contract_factory.py,sha256=-AA0G-mQdLffQSpOzkNg_P4nRsqLYLmUJoYrrs8_dD4,7607
|
15
|
+
gltest/contracts/contract_functions.py,sha256=5gNQYzN47rCJtmcMtUkl4ZK-yDifdZup2YhtlFlrx7E,2203
|
16
16
|
gltest/contracts/method_stats.py,sha256=zWWjvf7K5VC4yrHpDIR717VF7LYp1RaZ1Hr_RZvWxJA,5150
|
17
17
|
gltest/contracts/stats_collector.py,sha256=fuCc8L8hd0tsVGzH4adtZWwPa7ORf0A0zR5Dt1w92Qk,9033
|
18
18
|
gltest/contracts/utils.py,sha256=TTXgcXn9BuRIlKJrjwmU7R3l1IgXsXk2luM-r3lfbbg,296
|
@@ -24,7 +24,7 @@ gltest_cli/main.py,sha256=Ti2-0Ev1x5_cM0D1UKqdgaDt80CDHEQGtdRne2qLm4M,53
|
|
24
24
|
gltest_cli/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
gltest_cli/config/constants.py,sha256=3iSK337AeupyYl_6Sf8MR_o91XfLmul8m1rVmi3Fvmo,342
|
26
26
|
gltest_cli/config/general.py,sha256=ezpoGsT8grO9zQH6RugV14b1GzeFt-htYToHQBJhNvY,186
|
27
|
-
gltest_cli/config/plugin.py,sha256=
|
27
|
+
gltest_cli/config/plugin.py,sha256=sByVyPt9IikLFg4PiVe7xFrO56mVwyDdn4nzYa_HTNo,5411
|
28
28
|
gltest_cli/config/pytest_context.py,sha256=Ze8JSkrwMTCE8jIhpzU_71CEXg92SiEPvSgNTp-gbS4,243
|
29
29
|
gltest_cli/config/types.py,sha256=KDAA_vNqI7o_sYMj21ks3WaIXGrbLVb76E17TSlWUwI,7241
|
30
30
|
gltest_cli/config/user.py,sha256=WNX_Wi2eJpjW0UstQuQiDjzRpOIOwx9iiXOx4ntt93U,8759
|
@@ -44,7 +44,7 @@ tests/examples/contracts/wizard_of_coin.py,sha256=Y8daPpoSKdM8wfbCPOIgEdpkLIA1ZM
|
|
44
44
|
tests/examples/contracts/multi_file_contract/__init__.py,sha256=CCdaK5p12GDf35hgbBWURNM5KUn6SWAcuyieTmZwVWE,548
|
45
45
|
tests/examples/contracts/multi_file_contract/other.py,sha256=jHDtjUL3eAUgE6yOYKFw_RfAH7kIwk8CvxUjbWHNruk,236
|
46
46
|
tests/examples/tests/test_football_prediction_market.py,sha256=f2hfDK76WrNJZtFkTPKoPRR6bkmFLEssnlwwltSnU9A,1111
|
47
|
-
tests/examples/tests/test_intelligent_oracle_factory.py,sha256=
|
47
|
+
tests/examples/tests/test_intelligent_oracle_factory.py,sha256=uOpoMIktXltfPhnLwlothXUZy6s0luPSXiIeZkPJ2hI,7729
|
48
48
|
tests/examples/tests/test_llm_erc20.py,sha256=zb5F_7NgvZXhvqL2nULwzuTT6LGDprSy0WgrdjY7pZc,2096
|
49
49
|
tests/examples/tests/test_llm_erc20_analyze.py,sha256=ccWQenEOG-U4TJdu-0i-3qNM4xRRCHSr3Iwz7pxknws,1729
|
50
50
|
tests/examples/tests/test_log_indexer.py,sha256=46AqL7qquNc9GX2wxFxVcQXLqruMnPmxXl1yeB0-KZ4,2869
|
@@ -69,8 +69,8 @@ tests/gltest_cli/config/test_config_integration.py,sha256=vPTzr3_h9UMw7m72HogBJE
|
|
69
69
|
tests/gltest_cli/config/test_general_config.py,sha256=UHtSwVnso-ZwNtYM0Z4v2sCLKwyrVbHlk6b1leVfV84,14703
|
70
70
|
tests/gltest_cli/config/test_plugin.py,sha256=87kJpSYcWbNuKDqfc_jiN7hoRnFkMEnOOTINwuXKBY0,7981
|
71
71
|
tests/gltest_cli/config/test_user.py,sha256=JxR655oUFoM9quWQO68CVPKRpT0TMpzS3bF6j6NWyT4,14401
|
72
|
-
genlayer_test-2.
|
73
|
-
genlayer_test-2.
|
74
|
-
genlayer_test-2.
|
75
|
-
genlayer_test-2.
|
76
|
-
genlayer_test-2.
|
72
|
+
genlayer_test-2.1.0.dist-info/METADATA,sha256=Mj2oQbtObBd2TgEWNPGYIyZKmfnMxswurXuu2tFHas4,24978
|
73
|
+
genlayer_test-2.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
74
|
+
genlayer_test-2.1.0.dist-info/entry_points.txt,sha256=RWPcSArBpz_G4BYioh5L8Q8hyClRbSgzLimjcWMp-BQ,94
|
75
|
+
genlayer_test-2.1.0.dist-info/top_level.txt,sha256=-qiGZxTRBytujzgVcKpxjvQ-WNeUDjXa59ceGMwMpko,24
|
76
|
+
genlayer_test-2.1.0.dist-info/RECORD,,
|
gltest/contracts/contract.py
CHANGED
@@ -2,7 +2,12 @@ import types
|
|
2
2
|
from eth_account.signers.local import LocalAccount
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from gltest.clients import get_gl_client
|
5
|
-
from gltest.types import
|
5
|
+
from gltest.types import (
|
6
|
+
CalldataEncodable,
|
7
|
+
GenLayerTransaction,
|
8
|
+
TransactionStatus,
|
9
|
+
TransactionHashVariant,
|
10
|
+
)
|
6
11
|
from typing import List, Any, Optional, Dict, Callable
|
7
12
|
from gltest_cli.config.general import get_general_config
|
8
13
|
from .contract_functions import ContractFunction
|
@@ -18,13 +23,16 @@ def read_contract_wrapper(
|
|
18
23
|
Wrapper to the contract read method.
|
19
24
|
"""
|
20
25
|
|
21
|
-
def call_method(
|
26
|
+
def call_method(
|
27
|
+
transaction_hash_variant: TransactionHashVariant = TransactionHashVariant.LATEST_NONFINAL,
|
28
|
+
):
|
22
29
|
client = get_gl_client()
|
23
30
|
return client.read_contract(
|
24
31
|
address=self.address,
|
25
32
|
function_name=method_name,
|
26
33
|
account=self.account,
|
27
34
|
args=args,
|
35
|
+
transaction_hash_variant=transaction_hash_variant,
|
28
36
|
)
|
29
37
|
|
30
38
|
return ContractFunction(
|
@@ -46,11 +54,11 @@ def write_contract_wrapper(
|
|
46
54
|
def transact_method(
|
47
55
|
value: int = 0,
|
48
56
|
consensus_max_rotations: Optional[int] = None,
|
49
|
-
wait_transaction_status: TransactionStatus = TransactionStatus.
|
57
|
+
wait_transaction_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
50
58
|
wait_interval: Optional[int] = None,
|
51
59
|
wait_retries: Optional[int] = None,
|
52
|
-
wait_triggered_transactions: bool =
|
53
|
-
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.
|
60
|
+
wait_triggered_transactions: bool = False,
|
61
|
+
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
54
62
|
):
|
55
63
|
"""
|
56
64
|
Transact the contract method.
|
@@ -109,16 +109,24 @@ class ContractFactory:
|
|
109
109
|
consensus_max_rotations: Optional[int] = None,
|
110
110
|
wait_interval: Optional[int] = None,
|
111
111
|
wait_retries: Optional[int] = None,
|
112
|
-
wait_transaction_status: TransactionStatus = TransactionStatus.
|
112
|
+
wait_transaction_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
113
|
+
wait_triggered_transactions: bool = False,
|
114
|
+
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
113
115
|
) -> Contract:
|
114
116
|
"""
|
115
117
|
Deploy the contract
|
116
118
|
"""
|
117
119
|
general_config = get_general_config()
|
118
|
-
|
119
|
-
wait_interval
|
120
|
-
|
121
|
-
|
120
|
+
actual_wait_interval = (
|
121
|
+
wait_interval
|
122
|
+
if wait_interval is not None
|
123
|
+
else general_config.get_default_wait_interval()
|
124
|
+
)
|
125
|
+
actual_wait_retries = (
|
126
|
+
wait_retries
|
127
|
+
if wait_retries is not None
|
128
|
+
else general_config.get_default_wait_retries()
|
129
|
+
)
|
122
130
|
leader_only = (
|
123
131
|
general_config.get_leader_only()
|
124
132
|
if general_config.check_studio_based_rpc()
|
@@ -137,14 +145,24 @@ class ContractFactory:
|
|
137
145
|
tx_receipt = client.wait_for_transaction_receipt(
|
138
146
|
transaction_hash=tx_hash,
|
139
147
|
status=wait_transaction_status,
|
140
|
-
interval=
|
141
|
-
retries=
|
148
|
+
interval=actual_wait_interval,
|
149
|
+
retries=actual_wait_retries,
|
142
150
|
)
|
143
151
|
if tx_execution_failed(tx_receipt):
|
144
152
|
raise ValueError(
|
145
153
|
f"Deployment transaction finalized with error: {tx_receipt}"
|
146
154
|
)
|
147
155
|
|
156
|
+
if wait_triggered_transactions:
|
157
|
+
triggered_transactions = tx_receipt["triggered_transactions"]
|
158
|
+
for triggered_transaction in triggered_transactions:
|
159
|
+
client.wait_for_transaction_receipt(
|
160
|
+
transaction_hash=triggered_transaction,
|
161
|
+
status=wait_triggered_transactions_status,
|
162
|
+
interval=actual_wait_interval,
|
163
|
+
retries=actual_wait_retries,
|
164
|
+
)
|
165
|
+
|
148
166
|
if (
|
149
167
|
"tx_data_decoded" in tx_receipt
|
150
168
|
and "contract_address" in tx_receipt["tx_data_decoded"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
2
|
from typing import Callable, Optional, Dict, Any
|
3
|
-
from gltest.types import TransactionStatus
|
3
|
+
from gltest.types import TransactionStatus, TransactionHashVariant
|
4
4
|
|
5
5
|
|
6
6
|
@dataclass
|
@@ -11,20 +11,23 @@ class ContractFunction:
|
|
11
11
|
analyze_method: Optional[Callable] = None
|
12
12
|
transact_method: Optional[Callable] = None
|
13
13
|
|
14
|
-
def call(
|
14
|
+
def call(
|
15
|
+
self,
|
16
|
+
transaction_hash_variant: TransactionHashVariant = TransactionHashVariant.LATEST_NONFINAL,
|
17
|
+
):
|
15
18
|
if not self.read_only:
|
16
19
|
raise ValueError("call() not implemented for non-readonly method")
|
17
|
-
return self.call_method()
|
20
|
+
return self.call_method(transaction_hash_variant=transaction_hash_variant)
|
18
21
|
|
19
22
|
def transact(
|
20
23
|
self,
|
21
24
|
value: int = 0,
|
22
25
|
consensus_max_rotations: Optional[int] = None,
|
23
|
-
wait_transaction_status: TransactionStatus = TransactionStatus.
|
26
|
+
wait_transaction_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
24
27
|
wait_interval: Optional[int] = None,
|
25
28
|
wait_retries: Optional[int] = None,
|
26
|
-
wait_triggered_transactions: bool =
|
27
|
-
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.
|
29
|
+
wait_triggered_transactions: bool = False,
|
30
|
+
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
28
31
|
):
|
29
32
|
if self.read_only:
|
30
33
|
raise ValueError("Cannot transact read-only method")
|
gltest/types.py
CHANGED
gltest_cli/config/plugin.py
CHANGED
@@ -32,14 +32,14 @@ def pytest_addoption(parser):
|
|
32
32
|
group.addoption(
|
33
33
|
"--default-wait-interval",
|
34
34
|
action="store",
|
35
|
-
default=
|
35
|
+
default=3000,
|
36
36
|
help="Default interval (ms) between transaction receipt checks",
|
37
37
|
)
|
38
38
|
|
39
39
|
group.addoption(
|
40
40
|
"--default-wait-retries",
|
41
41
|
action="store",
|
42
|
-
default=
|
42
|
+
default=50,
|
43
43
|
help="Default number of retries for transaction receipt checks",
|
44
44
|
)
|
45
45
|
|
@@ -1,24 +1,10 @@
|
|
1
|
-
import time
|
2
1
|
import json
|
2
|
+
from gltest.types import TransactionStatus
|
3
3
|
|
4
4
|
from gltest import get_contract_factory
|
5
5
|
from gltest.assertions import tx_execution_succeeded
|
6
6
|
|
7
7
|
|
8
|
-
def wait_for_contract_deployment(intelligent_oracle_contract, max_retries=10, delay=5):
|
9
|
-
"""
|
10
|
-
Wait for intelligent oracle contract to be fully deployed by attempting to call a method.
|
11
|
-
This is used to check if the triggered deployment did deploy the contract.
|
12
|
-
"""
|
13
|
-
for _ in range(max_retries):
|
14
|
-
try:
|
15
|
-
intelligent_oracle_contract.get_dict(args=[]).call()
|
16
|
-
return True # If successful, contract is deployed
|
17
|
-
except Exception:
|
18
|
-
time.sleep(delay)
|
19
|
-
return False
|
20
|
-
|
21
|
-
|
22
8
|
def create_mock_response(markets_data):
|
23
9
|
reasoning_single_source_marathon = "The HTML content contains the results of the Madrid Marathon 2024, which occurred on April 28, 2024. Mitku Tafa won and matches the name 'Tafa Mitku' in the list of potential outcomes."
|
24
10
|
reasoning_all_sources_marathon = "The URL indicates that the Madrid Marathon 2024 has occurred on April 28, 2024, and Mitku Tafa was the winner. The name matches one of the potential outcomes. There are no conflicting sources."
|
@@ -124,7 +110,10 @@ def test_intelligent_oracle_factory_pattern(setup_validators):
|
|
124
110
|
market_data["resolution_urls"],
|
125
111
|
market_data["earliest_resolution_date"],
|
126
112
|
],
|
127
|
-
).transact(
|
113
|
+
).transact(
|
114
|
+
wait_triggered_transactions=True,
|
115
|
+
wait_triggered_transactions_status=TransactionStatus.ACCEPTED,
|
116
|
+
)
|
128
117
|
assert tx_execution_succeeded(create_result)
|
129
118
|
|
130
119
|
# Get the latest contract address from factory
|
@@ -135,11 +124,6 @@ def test_intelligent_oracle_factory_pattern(setup_validators):
|
|
135
124
|
market_contract = intelligent_oracle_factory.build_contract(new_market_address)
|
136
125
|
created_market_contracts.append(market_contract)
|
137
126
|
|
138
|
-
# Wait for the new market contract to be deployed
|
139
|
-
assert wait_for_contract_deployment(
|
140
|
-
market_contract
|
141
|
-
), f"Market contract deployment timeout for {market_data['prediction_market_id']}"
|
142
|
-
|
143
127
|
# Verify all markets were registered
|
144
128
|
assert len(registered_addresses) == len(markets_data)
|
145
129
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|