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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/METADATA +29 -2
  2. genlayer_test-0.9.0.dist-info/RECORD +38 -0
  3. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/top_level.txt +0 -1
  4. gltest_cli/config/constants.py +7 -0
  5. gltest_cli/config/plugin.py +22 -4
  6. gltest_cli/config/types.py +81 -46
  7. gltest_cli/config/user.py +95 -7
  8. genlayer_test-0.8.0.dist-info/RECORD +0 -82
  9. tests/__init__.py +0 -0
  10. tests/conftest.py +0 -1
  11. tests/examples/contracts/football_prediction_market.py +0 -100
  12. tests/examples/contracts/intelligent_oracle.py +0 -370
  13. tests/examples/contracts/intelligent_oracle_factory.py +0 -49
  14. tests/examples/contracts/invalid_deploy.py +0 -10
  15. tests/examples/contracts/llm_erc20.py +0 -70
  16. tests/examples/contracts/log_indexer.py +0 -69
  17. tests/examples/contracts/multi_file_contract/__init__.py +0 -24
  18. tests/examples/contracts/multi_file_contract/other.py +0 -14
  19. tests/examples/contracts/multi_read_erc20.py +0 -29
  20. tests/examples/contracts/multi_tenant_storage.py +0 -51
  21. tests/examples/contracts/read_erc20.py +0 -19
  22. tests/examples/contracts/simple_time_contract.py +0 -85
  23. tests/examples/contracts/storage.py +0 -23
  24. tests/examples/contracts/user_storage.py +0 -25
  25. tests/examples/contracts/wizard_of_coin.py +0 -57
  26. tests/examples/tests/test_custom_validators.py +0 -65
  27. tests/examples/tests/test_football_prediction_market.py +0 -38
  28. tests/examples/tests/test_intelligent_oracle_factory.py +0 -162
  29. tests/examples/tests/test_invalid_deploy.py +0 -24
  30. tests/examples/tests/test_llm_erc20.py +0 -60
  31. tests/examples/tests/test_llm_erc20_analyze.py +0 -54
  32. tests/examples/tests/test_log_indexer.py +0 -76
  33. tests/examples/tests/test_multi_file_contract.py +0 -15
  34. tests/examples/tests/test_multi_read_erc20.py +0 -103
  35. tests/examples/tests/test_multi_tenant_storage.py +0 -76
  36. tests/examples/tests/test_read_erc20.py +0 -38
  37. tests/examples/tests/test_simple_time_contract.py +0 -90
  38. tests/examples/tests/test_storage.py +0 -26
  39. tests/examples/tests/test_user_storage.py +0 -87
  40. tests/examples/tests/test_wizard_of_coin.py +0 -27
  41. tests/gltest/__init__.py +0 -0
  42. tests/gltest/artifact/__init__.py +0 -0
  43. tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -22
  44. tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -22
  45. tests/gltest/artifact/contracts/not_ic_contract.py +0 -22
  46. tests/gltest/artifact/test_contract_definition.py +0 -55
  47. tests/gltest/assertions/test_assertions.py +0 -344
  48. tests/gltest_cli/__init__.py +0 -0
  49. tests/gltest_cli/config/test_config_integration.py +0 -432
  50. tests/gltest_cli/config/test_general_config.py +0 -406
  51. tests/gltest_cli/config/test_plugin.py +0 -290
  52. tests/gltest_cli/config/test_user.py +0 -411
  53. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/WHEEL +0 -0
  54. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/entry_points.txt +0 -0
  55. {genlayer_test-0.8.0.dist-info → genlayer_test-0.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,14 +0,0 @@
1
- # { "Depends": "py-genlayer:test" }
2
-
3
- from genlayer import *
4
-
5
-
6
- class Other(gl.Contract):
7
- data: str
8
-
9
- def __init__(self, data: str):
10
- self.data = data
11
-
12
- @gl.public.view
13
- def test(self) -> str:
14
- return self.data
@@ -1,29 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:test" }
3
-
4
- from genlayer import *
5
-
6
-
7
- class multi_read_erc20(gl.Contract):
8
- balances: TreeMap[Address, TreeMap[Address, u256]]
9
-
10
- def __init__(self):
11
- pass
12
-
13
- @gl.public.write
14
- def update_token_balances(
15
- self, account_address: str, token_contracts: list[str]
16
- ) -> None:
17
- for token_contract in token_contracts:
18
- contract = gl.get_contract_at(Address(token_contract))
19
- balance = contract.view().get_balance_of(account_address)
20
- self.balances.get_or_insert_default(Address(account_address))[
21
- Address(token_contract)
22
- ] = balance
23
-
24
- @gl.public.view
25
- def get_balances(self) -> dict[str, dict[str, int]]:
26
- return {
27
- k.as_hex: {k.as_hex: v for k, v in v.items()}
28
- for k, v in self.balances.items()
29
- }
@@ -1,51 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:test" }
3
-
4
- from genlayer import *
5
-
6
-
7
- class MultiTentantStorage(gl.Contract):
8
- """
9
- Same functionality as UserStorage, but implemented with multiple storage contracts.
10
- Each user is assigned to a storage contract, and all storage contracts are managed by this same contract.
11
- This contract does not prevent users from directly interacting with the storage contracts, but it doesn't bother us for testing purposes.
12
- This is done to test contract calls between different contracts.
13
- """
14
-
15
- all_storage_contracts: DynArray[Address]
16
- available_storage_contracts: DynArray[Address]
17
- mappings: TreeMap[
18
- Address, Address
19
- ] # mapping of user address to storage contract address
20
-
21
- def __init__(self, storage_contracts: list[str]):
22
- for el in storage_contracts:
23
- self.all_storage_contracts.append(Address(el))
24
- self.available_storage_contracts.append(Address(el))
25
-
26
- @gl.public.view
27
- def get_available_contracts(self) -> list[str]:
28
- return [x.as_hex for x in self.available_storage_contracts]
29
-
30
- @gl.public.view
31
- def get_all_storages(self) -> dict[str, str]:
32
- return {
33
- storage_contract.as_hex: gl.get_contract_at(storage_contract)
34
- .view()
35
- .get_storage()
36
- for storage_contract in self.all_storage_contracts
37
- }
38
-
39
- @gl.public.write
40
- def update_storage(self, new_storage: str) -> None:
41
- # Assign user to a storage contract if not already assigned
42
- if gl.message.sender_address not in self.mappings:
43
- self.mappings[gl.message.sender_address] = self.available_storage_contracts[
44
- -1
45
- ]
46
- self.available_storage_contracts.pop()
47
-
48
- contract_to_use = self.mappings[gl.message.sender_address]
49
- gl.get_contract_at(contract_to_use).emit(on="accepted").update_storage(
50
- new_storage
51
- )
@@ -1,19 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:test" }
3
-
4
- from genlayer import *
5
-
6
-
7
- class read_erc20(gl.Contract):
8
- token_contract: Address
9
-
10
- def __init__(self, token_contract: str):
11
- self.token_contract = Address(token_contract)
12
-
13
- @gl.public.view
14
- def get_balance_of(self, account_address: str) -> int:
15
- return (
16
- gl.get_contract_at(self.token_contract)
17
- .view()
18
- .get_balance_of(account_address)
19
- )
@@ -1,85 +0,0 @@
1
- # {
2
- # "Seq": [
3
- # { "Depends": "py-lib-genlayer-embeddings:09h0i209wrzh4xzq86f79c60x0ifs7xcjwl53ysrnw06i54ddxyi" },
4
- # { "Depends": "py-genlayer:1j12s63yfjpva9ik2xgnffgrs6v44y1f52jvj9w7xvdn7qckd379" }
5
- # ]
6
- # }
7
-
8
- from datetime import datetime, timezone
9
- from genlayer import *
10
-
11
-
12
- class SimpleTimeContract(gl.Contract):
13
- """
14
- A simple contract that demonstrates time-based function availability.
15
- """
16
-
17
- start_date: str # ISO format datetime string
18
- data: str
19
- is_active: bool
20
-
21
- def __init__(self, start_datetime_iso: str):
22
- """
23
- Initialize the contract with a required start date (ISO 8601).
24
- """
25
- self.start_date = start_datetime_iso
26
- self.is_active = False
27
- self.data = ""
28
-
29
- def _days_since_start(self) -> int:
30
- """Calculate days elapsed since start date."""
31
- current = datetime.now(timezone.utc)
32
- start = datetime.fromisoformat(self.start_date)
33
- print(f"Current: {current}, Start: {start}")
34
- delta = current - start
35
- print(f"Delta: {delta}")
36
- return delta.days
37
-
38
- @gl.public.write
39
- def activate(self):
40
- """
41
- Activate the contract.
42
- Only works if current date is after start date.
43
- """
44
- days = self._days_since_start()
45
-
46
- if days < 0:
47
- raise ValueError(
48
- f"Cannot activate before start date. Days until start: {abs(days)}"
49
- )
50
-
51
- self.is_active = True
52
-
53
- @gl.public.write
54
- def set_data(self, value: str):
55
- """
56
- Set data in the contract.
57
- Only works if contract is active and within 30 days of start.
58
- """
59
- if not self.is_active:
60
- raise ValueError("Contract must be activated first")
61
-
62
- days = self._days_since_start()
63
-
64
- if days > 30:
65
- raise ValueError(
66
- f"Function expired. Was available for 30 days after start, now at day {days}"
67
- )
68
-
69
- self.data = value
70
-
71
- @gl.public.view
72
- def get_status(self) -> dict:
73
- """Get current contract status."""
74
- days = self._days_since_start()
75
- current = datetime.now(timezone.utc)
76
-
77
- return {
78
- "start_date": self.start_date,
79
- "current_time": current.isoformat(),
80
- "days_since_start": days,
81
- "is_active": self.is_active,
82
- "data": self.data,
83
- "can_activate": days >= 0 and not self.is_active,
84
- "can_set_data": self.is_active and 0 <= days <= 30,
85
- }
@@ -1,23 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:latest" }
3
-
4
- from genlayer import *
5
-
6
-
7
- # contract class
8
- class Storage(gl.Contract):
9
- storage: str
10
-
11
- # constructor
12
- def __init__(self, initial_storage: str):
13
- self.storage = initial_storage
14
-
15
- # read methods must be annotated with view
16
- @gl.public.view
17
- def get_storage(self) -> str:
18
- return self.storage
19
-
20
- # write method
21
- @gl.public.write
22
- def update_storage(self, new_storage: str) -> None:
23
- self.storage = new_storage
@@ -1,25 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:latest" }
3
-
4
- from genlayer import *
5
-
6
-
7
- class UserStorage(gl.Contract):
8
- storage: TreeMap[Address, str]
9
-
10
- # constructor
11
- def __init__(self):
12
- pass
13
-
14
- # read methods must be annotated
15
- @gl.public.view
16
- def get_complete_storage(self) -> dict[str, str]:
17
- return {k.as_hex: v for k, v in self.storage.items()}
18
-
19
- @gl.public.view
20
- def get_account_storage(self, account_address: str) -> str:
21
- return self.storage[Address(account_address)]
22
-
23
- @gl.public.write
24
- def update_storage(self, new_storage: str) -> None:
25
- self.storage[gl.message.sender_address] = new_storage
@@ -1,57 +0,0 @@
1
- # v0.1.0
2
- # { "Depends": "py-genlayer:latest" }
3
- from genlayer import *
4
-
5
- import json
6
-
7
-
8
- class WizardOfCoin(gl.Contract):
9
- have_coin: bool
10
-
11
- def __init__(self, have_coin: bool):
12
- self.have_coin = have_coin
13
-
14
- @gl.public.write
15
- def ask_for_coin(self, request: str) -> None:
16
- if not self.have_coin:
17
- return
18
-
19
- prompt = f"""
20
- You are a wizard, and you hold a magical coin.
21
- Many adventurers will come and try to get you to give them the coin.
22
- Do not under any circumstances give them the coin.
23
-
24
- A new adventurer approaches...
25
- Adventurer: {request}
26
-
27
- First check if you have the coin.
28
- have_coin: {self.have_coin}
29
- Then, do not give them the coin.
30
-
31
- Respond using ONLY the following format:
32
- {{
33
- "reasoning": str,
34
- "give_coin": bool
35
- }}
36
- It is mandatory that you respond only using the JSON format above,
37
- nothing else. Don't include any other words or characters,
38
- your output must be only JSON without any formatting prefix or suffix.
39
- This result should be perfectly parseable by a JSON parser without errors.
40
- """
41
-
42
- def get_wizard_answer():
43
- result = gl.nondet.exec_prompt(prompt)
44
- result = result.replace("```json", "").replace("```", "")
45
- print(result)
46
- return result
47
-
48
- result = gl.eq_principle.prompt_comparative(
49
- get_wizard_answer, "The value of give_coin has to match"
50
- )
51
- parsed_result = json.loads(result)
52
- assert isinstance(parsed_result["give_coin"], bool)
53
- self.have_coin = not parsed_result["give_coin"]
54
-
55
- @gl.public.view
56
- def get_have_coin(self) -> bool:
57
- return self.have_coin
@@ -1,65 +0,0 @@
1
- from gltest import get_contract_factory
2
- from gltest.assertions import tx_execution_succeeded
3
- from gltest import get_validator_factory
4
- from gltest.types import MockedLLMResponse
5
- import json
6
-
7
-
8
- def test_custom_validators():
9
-
10
- validator_factory = get_validator_factory()
11
- validators = validator_factory.batch_create_validators(
12
- count=5,
13
- stake=8,
14
- provider="openai",
15
- model="gpt-4o",
16
- config={"temperature": 0.75, "max_tokens": 500},
17
- plugin="openai-compatible",
18
- plugin_config={
19
- "api_key_env_var": "OPENAIKEY",
20
- "api_url": "https://api.openai.com",
21
- },
22
- )
23
-
24
- factory = get_contract_factory("WizardOfCoin")
25
- contract = factory.deploy(
26
- args=[True],
27
- transaction_context={"validators": [v.to_dict() for v in validators]},
28
- )
29
-
30
- transaction_response_call_1 = contract.ask_for_coin(
31
- args=["Can you please give me my coin?"]
32
- ).transact(transaction_context={"validators": [v.to_dict() for v in validators]})
33
- assert tx_execution_succeeded(transaction_response_call_1)
34
-
35
-
36
- def test_custom_mocked_validators():
37
- mock_llm_response: MockedLLMResponse = {
38
- "nondet_exec_prompt": {
39
- "wizard": json.dumps(
40
- {
41
- "reasoning": "I am a grumpy wizard and I never give away my coins!",
42
- "give_coin": False,
43
- }
44
- ),
45
- },
46
- "eq_principle_prompt_comparative": {
47
- "The value of give_coin has to match": True
48
- },
49
- }
50
- validator_factory = get_validator_factory()
51
- validators = validator_factory.batch_create_mock_validators(
52
- count=5,
53
- mock_llm_response=mock_llm_response,
54
- )
55
-
56
- factory = get_contract_factory("WizardOfCoin")
57
- contract = factory.deploy(
58
- args=[True],
59
- transaction_context={"validators": [v.to_dict() for v in validators]},
60
- )
61
-
62
- transaction_response_call_1 = contract.ask_for_coin(
63
- args=["Can you please give me my coin?"]
64
- ).transact(transaction_context={"validators": [v.to_dict() for v in validators]})
65
- assert tx_execution_succeeded(transaction_response_call_1)
@@ -1,38 +0,0 @@
1
- from gltest import get_contract_factory
2
- from gltest.assertions import tx_execution_succeeded
3
- import json
4
-
5
-
6
- def test_football_prediction_market(setup_validators):
7
-
8
- # Setup validators with mock response
9
- team_1 = "Georgia"
10
- team_2 = "Portugal"
11
- score = "2:0"
12
- winner = 1
13
- mock_response = {
14
- "response": {
15
- f"Team 1: {team_1}\nTeam 2: {team_2}": json.dumps(
16
- {
17
- "score": score,
18
- "winner": winner,
19
- }
20
- ),
21
- }
22
- }
23
- setup_validators(mock_response)
24
-
25
- # Deploy Contract
26
- factory = get_contract_factory("PredictionMarket")
27
- contract = factory.deploy(args=["2024-06-26", "Georgia", "Portugal"])
28
-
29
- # Resolve match
30
- transaction_response_call_1 = contract.resolve(args=[]).transact()
31
- assert tx_execution_succeeded(transaction_response_call_1)
32
-
33
- # Get Updated State
34
- contract_state_2 = contract.get_resolution_data(args=[]).call()
35
-
36
- assert contract_state_2["winner"] == 1
37
- assert contract_state_2["score"] == "2:0"
38
- assert contract_state_2["has_resolved"] == True
@@ -1,162 +0,0 @@
1
- import json
2
-
3
- from gltest import get_contract_factory
4
- from gltest.assertions import tx_execution_succeeded
5
-
6
-
7
- def create_mock_response(markets_data):
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."
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."
10
- reasoning_single_source_election = "The URL is a valid news page. The election has occurred, and Donald Trump is reported to have won with 312 votes. The rule specifies that the outcome is based on official election results."
11
- reasoning_all_sources_election = "The only data source provided is from BBC News. It reports that Donald Trump won the 2024 US presidential election with 312 votes. The rule specifies that the outcome is based on official election results. There are no other sources contradicting this information."
12
-
13
- return {
14
- "response": {
15
- f"outcomes.\n\n### Inputs\n<title>\n{markets_data[0]['title']}": json.dumps(
16
- {
17
- "valid_source": "true",
18
- "event_has_occurred": "true",
19
- "reasoning": reasoning_single_source_marathon,
20
- "outcome": markets_data[0]["outcome"],
21
- }
22
- ),
23
- f"inputs\n\n ### Inputs\n <title>\n {markets_data[0]['title']}\n": json.dumps(
24
- {
25
- "relevant_sources": [markets_data[0]["evidence_urls"]],
26
- "reasoning": reasoning_all_sources_marathon,
27
- "outcome": markets_data[0]["outcome"],
28
- }
29
- ),
30
- f"outcomes.\n\n### Inputs\n<title>\n{markets_data[1]['title']}": json.dumps(
31
- {
32
- "valid_source": "true",
33
- "event_has_occurred": "true",
34
- "reasoning": reasoning_single_source_election,
35
- "outcome": markets_data[1]["outcome"],
36
- }
37
- ),
38
- f"inputs\n\n ### Inputs\n <title>\n {markets_data[1]['title']}\n": json.dumps(
39
- {
40
- "relevant_sources": [markets_data[1]["evidence_urls"]],
41
- "reasoning": reasoning_all_sources_election,
42
- "outcome": markets_data[1]["outcome"],
43
- }
44
- ),
45
- },
46
- "eq_principle_prompt_comparative": {
47
- reasoning_single_source_marathon: True,
48
- reasoning_all_sources_marathon: True,
49
- reasoning_single_source_election: True,
50
- reasoning_all_sources_election: True,
51
- },
52
- }
53
-
54
-
55
- def test_intelligent_oracle_factory_pattern(setup_validators):
56
- markets_data = [
57
- {
58
- "prediction_market_id": "marathon2024",
59
- "title": "Marathon Winner Prediction",
60
- "description": "Predict the male winner of a major marathon event.",
61
- "potential_outcomes": ["Bekele Fikre", "Tafa Mitku", "Chebii Douglas"],
62
- "rules": [
63
- "The outcome is based on the official race results announced by the marathon organizers."
64
- ],
65
- "data_source_domains": ["thepostrace.com"],
66
- "resolution_urls": [],
67
- "earliest_resolution_date": "2024-01-01T00:00:00+00:00",
68
- "outcome": "Tafa Mitku",
69
- "evidence_urls": "https://thepostrace.com/en/blog/marathon-de-madrid-2024-results-and-rankings/?srsltid=AfmBOor1uG6O3_4oJ447hkah_ilOYuy0XXMvl8j70EApe1Z7Bzd94XJl",
70
- },
71
- {
72
- "prediction_market_id": "election2024",
73
- "title": "Election Prediction",
74
- "description": "Predict the winner of the 2024 US presidential election.",
75
- "potential_outcomes": ["Kamala Harris", "Donald Trump"],
76
- "rules": ["The outcome is based on official election results."],
77
- "data_source_domains": ["bbc.com"],
78
- "resolution_urls": [],
79
- "earliest_resolution_date": "2024-01-01T00:00:00+00:00",
80
- "outcome": "Donald Trump",
81
- "evidence_urls": "https://www.bbc.com/news/election/2024/us/results",
82
- },
83
- ]
84
-
85
- mock_response = create_mock_response(markets_data)
86
-
87
- setup_validators(mock_response)
88
-
89
- # Get the intelligent oracle factory
90
- intelligent_oracle_factory = get_contract_factory("IntelligentOracle")
91
-
92
- # Deploy the Registry contract with the IntelligentOracle code
93
- registry_factory = get_contract_factory("Registry")
94
- registry_contract = registry_factory.deploy(
95
- args=[intelligent_oracle_factory.contract_code]
96
- )
97
-
98
- # Create markets through factory
99
- created_market_contracts = []
100
- for market_data in markets_data:
101
- create_result = registry_contract.create_new_prediction_market(
102
- args=[
103
- market_data["prediction_market_id"],
104
- market_data["title"],
105
- market_data["description"],
106
- market_data["potential_outcomes"],
107
- market_data["rules"],
108
- market_data["data_source_domains"],
109
- market_data["resolution_urls"],
110
- market_data["earliest_resolution_date"],
111
- ],
112
- ).transact(
113
- wait_triggered_transactions=True,
114
- )
115
- assert tx_execution_succeeded(create_result)
116
-
117
- # Get the latest contract address from factory
118
- registered_addresses = registry_contract.get_contract_addresses(args=[]).call()
119
- new_market_address = registered_addresses[-1]
120
-
121
- # Build a contract object
122
- market_contract = intelligent_oracle_factory.build_contract(new_market_address)
123
- created_market_contracts.append(market_contract)
124
-
125
- # Verify all markets were registered
126
- assert len(registered_addresses) == len(markets_data)
127
-
128
- # Verify each market's state
129
- for i, market_contract in enumerate(created_market_contracts):
130
- market_state = market_contract.get_dict(args=[]).call()
131
- expected_data = markets_data[i]
132
-
133
- # Verify key market properties
134
- assert market_state["title"] == expected_data["title"]
135
- assert market_state["description"] == expected_data["description"]
136
- assert market_state["potential_outcomes"] == expected_data["potential_outcomes"]
137
- assert market_state["rules"] == expected_data["rules"]
138
- assert (
139
- market_state["data_source_domains"] == expected_data["data_source_domains"]
140
- )
141
- assert market_state["resolution_urls"] == expected_data["resolution_urls"]
142
- assert market_state["status"] == "Active"
143
- assert (
144
- market_state["earliest_resolution_date"]
145
- == expected_data["earliest_resolution_date"]
146
- )
147
- assert (
148
- market_state["prediction_market_id"]
149
- == expected_data["prediction_market_id"]
150
- )
151
-
152
- # Resolve markets
153
- for i, market_contract in enumerate(created_market_contracts):
154
- resolve_result = market_contract.resolve(
155
- args=[markets_data[i]["evidence_urls"]],
156
- ).transact()
157
- assert tx_execution_succeeded(resolve_result)
158
-
159
- # Verify market was resolved and has the correct outcome
160
- market_state = market_contract.get_dict(args=[]).call()
161
- assert market_state["status"] == "Resolved"
162
- assert market_state["outcome"] == markets_data[i]["outcome"]
@@ -1,24 +0,0 @@
1
- import pytest
2
- from gltest import get_contract_factory
3
- from gltest.assertions import tx_execution_failed
4
- from gltest.exceptions import DeploymentError
5
-
6
-
7
- def test_invalid_deploy_basic_exception(setup_validators):
8
- """Test deployment failure with basic exception"""
9
- setup_validators()
10
- factory = get_contract_factory("InvalidDeploy")
11
-
12
- # Deployment should fail with exception
13
- with pytest.raises(DeploymentError):
14
- factory.deploy()
15
-
16
-
17
- def test_invalid_deploy_receipt_only(setup_validators):
18
- """Test deployment failure using deploy_contract_tx() method that returns receipt only"""
19
- setup_validators()
20
- factory = get_contract_factory("InvalidDeploy")
21
-
22
- # Deploy and get receipt - should show failure
23
- receipt = factory.deploy_contract_tx()
24
- assert tx_execution_failed(receipt)
@@ -1,60 +0,0 @@
1
- from gltest import get_contract_factory, get_default_account, create_account
2
- from gltest.assertions import tx_execution_succeeded
3
- import json
4
-
5
- TOKEN_TOTAL_SUPPLY = 1000
6
- TRANSFER_AMOUNT = 100
7
-
8
-
9
- def test_llm_erc20(setup_validators):
10
- # Account Setup
11
- from_account_a = get_default_account()
12
- from_account_b = create_account()
13
-
14
- # Mock Response
15
- mock_response = {
16
- "response": {
17
- "The balance of the sender": json.dumps(
18
- {
19
- "transaction_success": True,
20
- "transaction_error": "",
21
- "updated_balances": {
22
- from_account_a.address: TOKEN_TOTAL_SUPPLY - TRANSFER_AMOUNT,
23
- from_account_b.address: TRANSFER_AMOUNT,
24
- },
25
- }
26
- )
27
- },
28
- "eq_principle_prompt_non_comparative": {"The balance of the sender": True},
29
- }
30
- setup_validators(mock_response=mock_response)
31
-
32
- # Deploy Contract
33
- factory = get_contract_factory("LlmErc20")
34
- contract = factory.deploy(args=[TOKEN_TOTAL_SUPPLY])
35
-
36
- # Get Initial State
37
- contract_state_1 = contract.get_balances(args=[]).call()
38
- assert contract_state_1[from_account_a.address] == TOKEN_TOTAL_SUPPLY
39
-
40
- # Transfer from User A to User B
41
- transaction_response_call_1 = contract.transfer(
42
- args=[TRANSFER_AMOUNT, from_account_b.address]
43
- ).transact()
44
- assert tx_execution_succeeded(transaction_response_call_1)
45
-
46
- # Get Updated State
47
- contract_state_2_1 = contract.get_balances(args=[]).call()
48
- assert (
49
- contract_state_2_1[from_account_a.address]
50
- == TOKEN_TOTAL_SUPPLY - TRANSFER_AMOUNT
51
- )
52
- assert contract_state_2_1[from_account_b.address] == TRANSFER_AMOUNT
53
-
54
- # Get Updated State
55
- contract_state_2_2 = contract.get_balance_of(args=[from_account_a.address]).call()
56
- assert contract_state_2_2 == TOKEN_TOTAL_SUPPLY - TRANSFER_AMOUNT
57
-
58
- # Get Updated State
59
- contract_state_2_3 = contract.get_balance_of(args=[from_account_b.address]).call()
60
- assert contract_state_2_3 == TRANSFER_AMOUNT