genlayer-test 0.4.1__py3-none-any.whl → 0.5.1__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 (50) hide show
  1. {genlayer_test-0.4.1.dist-info → genlayer_test-0.5.1.dist-info}/METADATA +257 -24
  2. genlayer_test-0.5.1.dist-info/RECORD +74 -0
  3. gltest/__init__.py +7 -6
  4. gltest/{glchain/client.py → clients.py} +1 -1
  5. gltest/contracts/__init__.py +4 -0
  6. gltest/contracts/contract.py +205 -0
  7. gltest/{glchain/contract.py → contracts/contract_factory.py} +47 -144
  8. gltest/contracts/contract_functions.py +62 -0
  9. gltest/contracts/method_stats.py +163 -0
  10. gltest/contracts/stats_collector.py +259 -0
  11. gltest/contracts/utils.py +12 -0
  12. gltest/fixtures.py +2 -6
  13. gltest/helpers/take_snapshot.py +1 -1
  14. gltest/types.py +1 -0
  15. gltest_cli/config/constants.py +2 -0
  16. gltest_cli/config/plugin.py +121 -49
  17. gltest_cli/config/pytest_context.py +9 -0
  18. gltest_cli/config/types.py +73 -8
  19. gltest_cli/config/user.py +71 -28
  20. gltest_cli/logging.py +3 -2
  21. tests/examples/contracts/football_prediction_market.py +1 -1
  22. tests/examples/contracts/intelligent_oracle_factory.py +1 -0
  23. tests/examples/contracts/multi_file_contract/__init__.py +1 -0
  24. tests/examples/contracts/multi_tenant_storage.py +3 -1
  25. tests/examples/tests/test_football_prediction_market.py +2 -2
  26. tests/examples/tests/test_intelligent_oracle_factory.py +6 -24
  27. tests/examples/tests/test_llm_erc20.py +5 -5
  28. tests/examples/tests/test_llm_erc20_analyze.py +50 -0
  29. tests/examples/tests/test_log_indexer.py +23 -11
  30. tests/examples/tests/test_multi_file_contract.py +5 -6
  31. tests/examples/tests/test_multi_read_erc20.py +14 -12
  32. tests/examples/tests/test_multi_tenant_storage.py +15 -7
  33. tests/examples/tests/test_read_erc20.py +1 -1
  34. tests/examples/tests/test_storage.py +4 -4
  35. tests/examples/tests/test_user_storage.py +20 -10
  36. tests/examples/tests/test_wizard_of_coin.py +1 -1
  37. tests/gltest/artifact/test_contract_definition.py +0 -36
  38. tests/gltest_cli/config/test_config_integration.py +432 -0
  39. tests/gltest_cli/config/test_general_config.py +406 -0
  40. tests/gltest_cli/config/test_plugin.py +164 -1
  41. tests/gltest_cli/config/test_user.py +61 -1
  42. genlayer_test-0.4.1.dist-info/RECORD +0 -67
  43. gltest/glchain/__init__.py +0 -16
  44. tests/examples/tests/test_multi_file_contract_legacy.py +0 -16
  45. tests/examples/tests/test_storage_legacy.py +0 -24
  46. {genlayer_test-0.4.1.dist-info → genlayer_test-0.5.1.dist-info}/WHEEL +0 -0
  47. {genlayer_test-0.4.1.dist-info → genlayer_test-0.5.1.dist-info}/entry_points.txt +0 -0
  48. {genlayer_test-0.4.1.dist-info → genlayer_test-0.5.1.dist-info}/licenses/LICENSE +0 -0
  49. {genlayer_test-0.4.1.dist-info → genlayer_test-0.5.1.dist-info}/top_level.txt +0 -0
  50. /gltest/{glchain/account.py → accounts.py} +0 -0
gltest_cli/config/user.py CHANGED
@@ -4,20 +4,21 @@ import re
4
4
  from dotenv import load_dotenv
5
5
  from pathlib import Path
6
6
  from functools import lru_cache
7
- from gltest.glchain.account import create_accounts
7
+ from gltest.accounts import create_accounts
8
8
  from gltest_cli.config.constants import (
9
9
  GLTEST_CONFIG_FILE,
10
10
  DEFAULT_NETWORK,
11
- DEFAULT_RPC_URL,
12
11
  DEFAULT_ENVIRONMENT,
13
12
  DEFAULT_CONTRACTS_DIR,
14
- DEFAULT_NETWORK_ID,
13
+ DEFAULT_ARTIFACTS_DIR,
14
+ PRECONFIGURED_NETWORKS,
15
15
  )
16
+ from genlayer_py.chains import localnet, studionet, testnet_asimov
16
17
  from gltest_cli.config.types import UserConfig, NetworkConfigData, PathConfig
17
18
 
18
19
  VALID_ROOT_KEYS = ["networks", "paths", "environment"]
19
- VALID_NETWORK_KEYS = ["id", "url", "accounts", "from"]
20
- VALID_PATHS_KEYS = ["contracts"]
20
+ VALID_NETWORK_KEYS = ["id", "url", "accounts", "from", "leader_only"]
21
+ VALID_PATHS_KEYS = ["contracts", "artifacts"]
21
22
 
22
23
 
23
24
  @lru_cache(maxsize=1)
@@ -25,16 +26,35 @@ def get_default_user_config() -> UserConfig:
25
26
  accounts = create_accounts(n_accounts=10)
26
27
  accounts_private_keys = [account.key.hex() for account in accounts]
27
28
 
29
+ networks = {
30
+ "localnet": NetworkConfigData(
31
+ id=localnet.id,
32
+ url=localnet.rpc_urls["default"]["http"][0],
33
+ accounts=accounts_private_keys,
34
+ from_account=accounts_private_keys[0],
35
+ leader_only=False,
36
+ ),
37
+ "studionet": NetworkConfigData(
38
+ id=studionet.id,
39
+ url=studionet.rpc_urls["default"]["http"][0],
40
+ accounts=accounts_private_keys,
41
+ from_account=accounts_private_keys[0],
42
+ leader_only=False,
43
+ ),
44
+ "testnet_asimov": NetworkConfigData(
45
+ id=testnet_asimov.id,
46
+ url=testnet_asimov.rpc_urls["default"]["http"][0],
47
+ accounts=None,
48
+ from_account=None,
49
+ leader_only=False,
50
+ ),
51
+ }
52
+
28
53
  return UserConfig(
29
- networks={
30
- DEFAULT_NETWORK: NetworkConfigData(
31
- id=DEFAULT_NETWORK_ID,
32
- url=DEFAULT_RPC_URL,
33
- accounts=accounts_private_keys,
34
- from_account=accounts_private_keys[0],
35
- ),
36
- },
37
- paths=PathConfig(contracts=DEFAULT_CONTRACTS_DIR),
54
+ networks=networks,
55
+ paths=PathConfig(
56
+ contracts=DEFAULT_CONTRACTS_DIR, artifacts=DEFAULT_ARTIFACTS_DIR
57
+ ),
38
58
  environment=DEFAULT_ENVIRONMENT,
39
59
  default_network=DEFAULT_NETWORK,
40
60
  )
@@ -42,11 +62,26 @@ def get_default_user_config() -> UserConfig:
42
62
 
43
63
  def resolve_env_vars(obj):
44
64
  if isinstance(obj, str):
45
- return re.sub(
46
- r"\${(\w+)}",
47
- lambda m: os.getenv(m.group(1), f"<UNSET:{m.group(1)}>"),
48
- obj,
49
- )
65
+
66
+ def replace_env_var(m):
67
+ try:
68
+ var_name = m.group(1)
69
+ if var_name is None:
70
+ raise ValueError(
71
+ f"Invalid environment variable pattern: {m.group(0)}"
72
+ )
73
+ var_value = os.getenv(var_name)
74
+ if var_value is None:
75
+ raise ValueError(
76
+ f"Environment variable {var_name} is not set, please check your environment file"
77
+ )
78
+ return var_value
79
+ except IndexError as e:
80
+ raise ValueError(
81
+ f"Invalid environment variable pattern: {m.group(0)}"
82
+ ) from e
83
+
84
+ return re.sub(r"\${(\w+)}", replace_env_var, obj)
50
85
  elif isinstance(obj, dict):
51
86
  return {k: resolve_env_vars(v) for k, v in obj.items()}
52
87
  elif isinstance(obj, list):
@@ -81,9 +116,13 @@ def validate_network_config(network_name: str, network_config: dict):
81
116
 
82
117
  if "from" in network_config and not isinstance(network_config["from"], str):
83
118
  raise ValueError(f"network {network_name} from must be a string")
119
+ if "leader_only" in network_config and not isinstance(
120
+ network_config["leader_only"], bool
121
+ ):
122
+ raise ValueError(f"network {network_name} leader_only must be a boolean")
84
123
 
85
- # For non-default networks, url and accounts are required
86
- if network_name != DEFAULT_NETWORK:
124
+ # For non-preconfigured networks, url and accounts are required
125
+ if network_name not in PRECONFIGURED_NETWORKS:
87
126
  if "id" not in network_config:
88
127
  raise ValueError(f"network {network_name} must have an id")
89
128
  if "url" not in network_config:
@@ -131,7 +170,6 @@ def validate_raw_user_config(config: dict):
131
170
  def load_user_config(path: str) -> UserConfig:
132
171
  with open(path, "r") as f:
133
172
  raw_config = yaml.safe_load(f) or {}
134
-
135
173
  validate_raw_user_config(raw_config)
136
174
  load_dotenv(
137
175
  dotenv_path=raw_config.get("environment", DEFAULT_ENVIRONMENT), override=True
@@ -168,8 +206,8 @@ def _get_overridden_networks(raw_config: dict) -> tuple[dict, str]:
168
206
 
169
207
  networks_config = {}
170
208
  for network_name, network_config in networks.items():
171
- if network_name == DEFAULT_NETWORK:
172
- networks_config[network_name] = default_config.networks[DEFAULT_NETWORK]
209
+ if network_name in PRECONFIGURED_NETWORKS:
210
+ networks_config[network_name] = default_config.networks[network_name]
173
211
  if network_config is None:
174
212
  continue
175
213
 
@@ -182,18 +220,23 @@ def _get_overridden_networks(raw_config: dict) -> tuple[dict, str]:
182
220
  ]
183
221
  if "from" in network_config:
184
222
  networks_config[network_name].from_account = network_config["from"]
223
+ if "leader_only" in network_config:
224
+ networks_config[network_name].leader_only = network_config[
225
+ "leader_only"
226
+ ]
185
227
  continue
186
228
 
187
229
  url = network_config["url"]
188
230
  accounts = network_config["accounts"]
189
231
  from_account = network_config.get("from", accounts[0])
190
232
  network_id = network_config.get("id")
191
-
233
+ leader_only = network_config.get("leader_only", False)
192
234
  networks_config[network_name] = NetworkConfigData(
193
235
  id=network_id,
194
236
  url=url,
195
237
  accounts=accounts,
196
238
  from_account=from_account,
239
+ leader_only=leader_only,
197
240
  )
198
241
  return networks_config, user_default_network
199
242
 
@@ -208,10 +251,10 @@ def _get_overridden_environment(raw_config: dict) -> str:
208
251
  def _get_overridden_paths(raw_config: dict) -> PathConfig:
209
252
  default_config = get_default_user_config()
210
253
  if "paths" in raw_config:
254
+ paths_config = raw_config.get("paths", {})
211
255
  return PathConfig(
212
- contracts=Path(
213
- raw_config.get("paths", {}).get("contracts", DEFAULT_CONTRACTS_DIR)
214
- )
256
+ contracts=Path(paths_config.get("contracts", DEFAULT_CONTRACTS_DIR)),
257
+ artifacts=Path(paths_config.get("artifacts", DEFAULT_ARTIFACTS_DIR)),
215
258
  )
216
259
  return default_config.paths
217
260
 
gltest_cli/logging.py CHANGED
@@ -31,13 +31,14 @@ class ColoredFormatter(logging.Formatter):
31
31
 
32
32
  def setup_logger():
33
33
  logger = logging.getLogger("gltest_cli")
34
- logger.setLevel(logging.DEBUG)
34
+ log_level = logging.INFO
35
+ logger.setLevel(log_level)
35
36
 
36
37
  if logger.handlers:
37
38
  return logger
38
39
 
39
40
  console_handler = logging.StreamHandler()
40
- console_handler.setLevel(logging.DEBUG)
41
+ console_handler.setLevel(log_level)
41
42
 
42
43
  formatter = ColoredFormatter("%(levelname)s: %(message)s")
43
44
  console_handler.setFormatter(formatter)
@@ -97,4 +97,4 @@ This result should be perfectly parsable by a JSON parser without errors.
97
97
  "winner": self.winner,
98
98
  "score": self.score,
99
99
  "has_resolved": self.has_resolved,
100
- }
100
+ }
@@ -38,6 +38,7 @@ class Registry(gl.Contract):
38
38
  earliest_resolution_date,
39
39
  ],
40
40
  salt_nonce=registered_contracts + 1,
41
+ on="accepted",
41
42
  )
42
43
  print("contract_address", contract_address)
43
44
  print("contract_address type", type(contract_address))
@@ -12,6 +12,7 @@ class MultiFileContract(gl.Contract):
12
12
  args=["123"],
13
13
  salt_nonce=u256(1),
14
14
  value=u256(0),
15
+ on="accepted",
15
16
  )
16
17
 
17
18
  @gl.public.write
@@ -46,4 +46,6 @@ class MultiTentantStorage(gl.Contract):
46
46
  self.available_storage_contracts.pop()
47
47
 
48
48
  contract_to_use = self.mappings[gl.message.sender_address]
49
- gl.get_contract_at(contract_to_use).emit().update_storage(new_storage)
49
+ gl.get_contract_at(contract_to_use).emit(on="accepted").update_storage(
50
+ new_storage
51
+ )
@@ -27,11 +27,11 @@ def test_football_prediction_market(setup_validators):
27
27
  contract = factory.deploy(args=["2024-06-26", "Georgia", "Portugal"])
28
28
 
29
29
  # Resolve match
30
- transaction_response_call_1 = contract.resolve(args=[])
30
+ transaction_response_call_1 = contract.resolve(args=[]).transact()
31
31
  assert tx_execution_succeeded(transaction_response_call_1)
32
32
 
33
33
  # Get Updated State
34
- contract_state_2 = contract.get_resolution_data(args=[])
34
+ contract_state_2 = contract.get_resolution_data(args=[]).call()
35
35
 
36
36
  assert contract_state_2["winner"] == 1
37
37
  assert contract_state_2["score"] == "2:0"
@@ -1,24 +1,9 @@
1
- import time
2
1
  import json
3
2
 
4
3
  from gltest import get_contract_factory
5
4
  from gltest.assertions import tx_execution_succeeded
6
5
 
7
6
 
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=[])
16
- return True # If successful, contract is deployed
17
- except Exception:
18
- time.sleep(delay)
19
- return False
20
-
21
-
22
7
  def create_mock_response(markets_data):
23
8
  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
9
  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,28 +109,25 @@ def test_intelligent_oracle_factory_pattern(setup_validators):
124
109
  market_data["resolution_urls"],
125
110
  market_data["earliest_resolution_date"],
126
111
  ],
112
+ ).transact(
113
+ wait_triggered_transactions=True,
127
114
  )
128
115
  assert tx_execution_succeeded(create_result)
129
116
 
130
117
  # Get the latest contract address from factory
131
- registered_addresses = registry_contract.get_contract_addresses(args=[])
118
+ registered_addresses = registry_contract.get_contract_addresses(args=[]).call()
132
119
  new_market_address = registered_addresses[-1]
133
120
 
134
121
  # Build a contract object
135
122
  market_contract = intelligent_oracle_factory.build_contract(new_market_address)
136
123
  created_market_contracts.append(market_contract)
137
124
 
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
125
  # Verify all markets were registered
144
126
  assert len(registered_addresses) == len(markets_data)
145
127
 
146
128
  # Verify each market's state
147
129
  for i, market_contract in enumerate(created_market_contracts):
148
- market_state = market_contract.get_dict(args=[])
130
+ market_state = market_contract.get_dict(args=[]).call()
149
131
  expected_data = markets_data[i]
150
132
 
151
133
  # Verify key market properties
@@ -171,10 +153,10 @@ def test_intelligent_oracle_factory_pattern(setup_validators):
171
153
  for i, market_contract in enumerate(created_market_contracts):
172
154
  resolve_result = market_contract.resolve(
173
155
  args=[markets_data[i]["evidence_urls"]],
174
- )
156
+ ).transact()
175
157
  assert tx_execution_succeeded(resolve_result)
176
158
 
177
159
  # Verify market was resolved and has the correct outcome
178
- market_state = market_contract.get_dict(args=[])
160
+ market_state = market_contract.get_dict(args=[]).call()
179
161
  assert market_state["status"] == "Resolved"
180
162
  assert market_state["outcome"] == markets_data[i]["outcome"]
@@ -34,17 +34,17 @@ def test_llm_erc20(setup_validators):
34
34
  contract = factory.deploy(args=[TOKEN_TOTAL_SUPPLY])
35
35
 
36
36
  # Get Initial State
37
- contract_state_1 = contract.get_balances(args=[])
37
+ contract_state_1 = contract.get_balances(args=[]).call()
38
38
  assert contract_state_1[from_account_a.address] == TOKEN_TOTAL_SUPPLY
39
39
 
40
40
  # Transfer from User A to User B
41
41
  transaction_response_call_1 = contract.transfer(
42
42
  args=[TRANSFER_AMOUNT, from_account_b.address]
43
- )
43
+ ).transact()
44
44
  assert tx_execution_succeeded(transaction_response_call_1)
45
45
 
46
46
  # Get Updated State
47
- contract_state_2_1 = contract.get_balances(args=[])
47
+ contract_state_2_1 = contract.get_balances(args=[]).call()
48
48
  assert (
49
49
  contract_state_2_1[from_account_a.address]
50
50
  == TOKEN_TOTAL_SUPPLY - TRANSFER_AMOUNT
@@ -52,9 +52,9 @@ def test_llm_erc20(setup_validators):
52
52
  assert contract_state_2_1[from_account_b.address] == TRANSFER_AMOUNT
53
53
 
54
54
  # Get Updated State
55
- contract_state_2_2 = contract.get_balance_of(args=[from_account_a.address])
55
+ contract_state_2_2 = contract.get_balance_of(args=[from_account_a.address]).call()
56
56
  assert contract_state_2_2 == TOKEN_TOTAL_SUPPLY - TRANSFER_AMOUNT
57
57
 
58
58
  # Get Updated State
59
- contract_state_2_3 = contract.get_balance_of(args=[from_account_b.address])
59
+ contract_state_2_3 = contract.get_balance_of(args=[from_account_b.address]).call()
60
60
  assert contract_state_2_3 == TRANSFER_AMOUNT
@@ -0,0 +1,50 @@
1
+ from gltest import get_contract_factory, get_default_account, create_account
2
+
3
+
4
+ TOKEN_TOTAL_SUPPLY = 1000
5
+ TRANSFER_AMOUNT = 100
6
+
7
+
8
+ def test_llm_erc20_analyze(setup_validators):
9
+ setup_validators()
10
+ # Account Setup
11
+ from_account_a = get_default_account()
12
+ from_account_b = create_account()
13
+
14
+ # Deploy Contract
15
+ factory = get_contract_factory("LlmErc20")
16
+ contract = factory.deploy(args=[TOKEN_TOTAL_SUPPLY])
17
+
18
+ # Get Initial State
19
+ contract_state_1 = contract.get_balances(args=[]).call()
20
+ assert contract_state_1[from_account_a.address] == TOKEN_TOTAL_SUPPLY
21
+
22
+ # Transfer from User A to User B
23
+ stats = contract.transfer(args=[TRANSFER_AMOUNT, from_account_b.address]).analyze(
24
+ provider="openai", model="gpt-4o", runs=3
25
+ )
26
+
27
+ # Verify it's a MethodStatsSummary object
28
+ assert hasattr(stats, "method")
29
+ assert hasattr(stats, "args")
30
+ assert hasattr(stats, "total_runs")
31
+ assert hasattr(stats, "execution_time")
32
+ assert hasattr(stats, "provider")
33
+ assert hasattr(stats, "model")
34
+
35
+ # Check basic properties
36
+ assert stats.method == "transfer"
37
+ assert stats.args == [TRANSFER_AMOUNT, from_account_b.address]
38
+ assert stats.total_runs == 3
39
+ assert stats.provider == "openai"
40
+ assert stats.model == "gpt-4o"
41
+ assert isinstance(stats.execution_time, float)
42
+
43
+ # Check string representation
44
+ stats_str = str(stats)
45
+ assert "Method analysis summary" in stats_str
46
+ assert "Method: transfer" in stats_str
47
+ assert f"Args: [{TRANSFER_AMOUNT}, '{from_account_b.address}']" in stats_str
48
+ assert f"Total runs: {stats.total_runs}" in stats_str
49
+ assert f"Provider: {stats.provider}" in stats_str
50
+ assert f"Model: {stats.model}" in stats_str
@@ -9,56 +9,68 @@ def test_log_indexer(setup_validators):
9
9
  contract = factory.deploy(args=[])
10
10
 
11
11
  # Get closest vector when empty
12
- closest_vector_log_0 = contract.get_closest_vector(args=["I like mango"])
12
+ closest_vector_log_0 = contract.get_closest_vector(args=["I like mango"]).call()
13
13
  assert closest_vector_log_0 is None
14
14
 
15
15
  # Add log 0
16
- transaction_response_add_log_0 = contract.add_log(args=["I like to eat mango", 0])
16
+ transaction_response_add_log_0 = contract.add_log(
17
+ args=["I like to eat mango", 0]
18
+ ).transact()
17
19
  assert tx_execution_succeeded(transaction_response_add_log_0)
18
20
 
19
21
  # Get closest vector to log 0
20
- closest_vector_log_0 = contract.get_closest_vector(args=["I like mango"])
22
+ closest_vector_log_0 = contract.get_closest_vector(args=["I like mango"]).call()
21
23
  closest_vector_log_0 = closest_vector_log_0
22
24
  assert float(closest_vector_log_0["similarity"]) > 0.94
23
25
  assert float(closest_vector_log_0["similarity"]) < 0.95
24
26
 
25
27
  # Add log 1
26
- transaction_response_add_log_1 = contract.add_log(args=["I like carrots", 1])
28
+ transaction_response_add_log_1 = contract.add_log(
29
+ args=["I like carrots", 1]
30
+ ).transact()
27
31
  assert tx_execution_succeeded(transaction_response_add_log_1)
28
32
 
29
33
  # Get closest vector to log 1
30
- closest_vector_log_1 = contract.get_closest_vector(args=["I like carrots"])
34
+ closest_vector_log_1 = contract.get_closest_vector(args=["I like carrots"]).call()
31
35
  closest_vector_log_1 = closest_vector_log_1
32
36
  assert float(closest_vector_log_1["similarity"]) == 1
33
37
 
34
38
  # Update log 0
35
39
  transaction_response_update_log_0 = contract.update_log(
36
40
  args=[0, "I like to eat a lot of mangoes"]
37
- )
41
+ ).transact()
38
42
  assert tx_execution_succeeded(transaction_response_update_log_0)
39
43
 
40
44
  # Get closest vector to log 0
41
- closest_vector_log_0_2 = contract.get_closest_vector(args=["I like mango a lot"])
45
+ closest_vector_log_0_2 = contract.get_closest_vector(
46
+ args=["I like mango a lot"]
47
+ ).call()
42
48
  closest_vector_log_0_2 = closest_vector_log_0_2
43
49
  assert float(closest_vector_log_0_2["similarity"]) > 0.94
44
50
  assert float(closest_vector_log_0_2["similarity"]) < 0.95
45
51
 
46
52
  # Remove log 0
47
- transaction_response_remove_log_0 = contract.remove_log(args=[0])
53
+ transaction_response_remove_log_0 = contract.remove_log(args=[0]).transact()
48
54
  assert tx_execution_succeeded(transaction_response_remove_log_0)
49
55
 
50
56
  # Get closest vector to log 0
51
- closest_vector_log_0_3 = contract.get_closest_vector(args=["I like to eat mango"])
57
+ closest_vector_log_0_3 = contract.get_closest_vector(
58
+ args=["I like to eat mango"]
59
+ ).call()
52
60
  closest_vector_log_0_3 = closest_vector_log_0_3
53
61
  assert float(closest_vector_log_0_3["similarity"]) > 0.67
54
62
  assert float(closest_vector_log_0_3["similarity"]) < 0.68
55
63
 
56
64
  # Add third log
57
- transaction_response_add_log_2 = contract.add_log(args=["This is the third log", 3])
65
+ transaction_response_add_log_2 = contract.add_log(
66
+ args=["This is the third log", 3]
67
+ ).transact()
58
68
  assert tx_execution_succeeded(transaction_response_add_log_2)
59
69
 
60
70
  # Check if new item got id 2
61
- closest_vector_log_2 = contract.get_closest_vector(args=["This is the third log"])
71
+ closest_vector_log_2 = contract.get_closest_vector(
72
+ args=["This is the third log"]
73
+ ).call()
62
74
  assert float(closest_vector_log_2["similarity"]) > 0.99
63
75
  assert closest_vector_log_2["id"] == 3
64
76
  assert closest_vector_log_2["text"] == "This is the third log"
@@ -1,5 +1,4 @@
1
1
  from gltest import get_contract_factory
2
- from gltest.assertions import tx_execution_succeeded
3
2
 
4
3
 
5
4
  def test_multi_file_contract(setup_validators):
@@ -7,10 +6,10 @@ def test_multi_file_contract(setup_validators):
7
6
  # Deploy Contract, it will deploy other.py as well
8
7
  setup_validators()
9
8
  factory = get_contract_factory("MultiFileContract")
10
- contract = factory.deploy(args=[])
9
+ contract = factory.deploy(
10
+ args=[],
11
+ wait_triggered_transactions=True,
12
+ )
11
13
 
12
- wait_response = contract.wait(args=[])
13
- assert tx_execution_succeeded(wait_response)
14
-
15
- res = contract.test(args=[])
14
+ res = contract.test(args=[]).call()
16
15
  assert res == "123"
@@ -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 = multi_read_contract.connect(
78
- from_account_shiba
79
- ).update_token_balances(
80
- args=[
81
- from_account_shiba.address,
82
- [doge_contract.address, shiba_contract.address],
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 = multi_read_contract.connect(
89
- from_account_shiba
90
- ).get_balances(args=[])
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,27 @@ def test_multi_tenant_storage(setup_validators):
48
48
  ]
49
49
  )
50
50
  # update storage for first contract
51
- transaction_response_call = multi_tenant_storage_contract.connect(
52
- account=user_account_a
53
- ).update_storage(args=["user_a_storage"])
51
+ transaction_response_call = (
52
+ multi_tenant_storage_contract.connect(account=user_account_a)
53
+ .update_storage(args=["user_a_storage"])
54
+ .transact(
55
+ wait_triggered_transactions=True,
56
+ )
57
+ )
54
58
  assert tx_execution_succeeded(transaction_response_call)
55
59
 
56
60
  # update storage for second contract
57
- transaction_response_call = multi_tenant_storage_contract.connect(
58
- account=user_account_b
59
- ).update_storage(args=["user_b_storage"])
61
+ transaction_response_call = (
62
+ multi_tenant_storage_contract.connect(account=user_account_b)
63
+ .update_storage(args=["user_b_storage"])
64
+ .transact(
65
+ wait_triggered_transactions=True,
66
+ )
67
+ )
60
68
  assert tx_execution_succeeded(transaction_response_call)
61
69
 
62
70
  # get all storages
63
- storages = multi_tenant_storage_contract.get_all_storages(args=[])
71
+ storages = multi_tenant_storage_contract.get_all_storages(args=[]).call()
64
72
 
65
73
  assert storages == {
66
74
  second_storage_contract.address: "user_a_storage",
@@ -34,5 +34,5 @@ def test_read_erc20(setup_validators):
34
34
  # check balance
35
35
  contract_state = read_erc20_contract.get_balance_of(
36
36
  args=[get_default_account().address]
37
- )
37
+ ).call()
38
38
  assert contract_state == TOKEN_TOTAL_SUPPLY
@@ -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], wait_retries=40
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