genlayer-test 0.0.1__tar.gz → 0.1.0b2__tar.gz

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 (30) hide show
  1. genlayer_test-0.1.0b2/PKG-INFO +97 -0
  2. genlayer_test-0.1.0b2/README.md +78 -0
  3. genlayer_test-0.1.0b2/genlayer_test.egg-info/PKG-INFO +97 -0
  4. genlayer_test-0.1.0b2/genlayer_test.egg-info/SOURCES.txt +21 -0
  5. genlayer_test-0.1.0b2/genlayer_test.egg-info/entry_points.txt +5 -0
  6. genlayer_test-0.1.0b2/genlayer_test.egg-info/requires.txt +2 -0
  7. genlayer_test-0.1.0b2/genlayer_test.egg-info/top_level.txt +5 -0
  8. genlayer_test-0.1.0b2/gltest/__init__.py +18 -0
  9. genlayer_test-0.1.0b2/gltest/artifacts/__init__.py +3 -0
  10. genlayer_test-0.1.0b2/gltest/artifacts/contract.py +49 -0
  11. genlayer_test-0.1.0b2/gltest/assertions.py +17 -0
  12. genlayer_test-0.1.0b2/gltest/exceptions.py +4 -0
  13. genlayer_test-0.1.0b2/gltest/glchain/__init__.py +16 -0
  14. genlayer_test-0.1.0b2/gltest/glchain/account.py +17 -0
  15. genlayer_test-0.1.0b2/gltest/glchain/client.py +15 -0
  16. genlayer_test-0.1.0b2/gltest/glchain/contract.py +216 -0
  17. genlayer_test-0.1.0b2/gltest/plugin_config.py +12 -0
  18. genlayer_test-0.1.0b2/gltest/plugin_hooks.py +16 -0
  19. genlayer_test-0.1.0b2/gltest/types.py +7 -0
  20. genlayer_test-0.1.0b2/gltest_cli/main.py +5 -0
  21. genlayer_test-0.1.0b2/pyproject.toml +37 -0
  22. genlayer_test-0.0.1/MANIFEST.in +0 -2
  23. genlayer_test-0.0.1/PKG-INFO +0 -17
  24. genlayer_test-0.0.1/README.md +0 -8
  25. genlayer_test-0.0.1/genlayer_test.egg-info/PKG-INFO +0 -17
  26. genlayer_test-0.0.1/genlayer_test.egg-info/SOURCES.txt +0 -7
  27. genlayer_test-0.0.1/genlayer_test.egg-info/top_level.txt +0 -1
  28. genlayer_test-0.0.1/pyproject.toml +0 -14
  29. {genlayer_test-0.0.1 → genlayer_test-0.1.0b2}/genlayer_test.egg-info/dependency_links.txt +0 -0
  30. {genlayer_test-0.0.1 → genlayer_test-0.1.0b2}/setup.cfg +0 -0
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: genlayer-test
3
+ Version: 0.1.0b2
4
+ Summary: GenLayer Testing Suite
5
+ Author: GenLayer
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Topic :: Software Development :: Testing
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: pytest
18
+ Requires-Dist: genlayer-py==0.1.0b1
19
+
20
+ # GenLayer Testing Suite
21
+
22
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
23
+ [![Discord](https://dcbadge.vercel.app/api/server/8Jm4v89VAu?compact=true&style=flat)](https://discord.gg/VpfmXEMN66)
24
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/yeagerai.svg?style=social&label=Follow%20%40GenLayer)](https://x.com/GenLayer)
25
+
26
+
27
+ ## About
28
+
29
+ The GenLayer Testing Suite is a powerful testing framework designed to streamline the development and validation of intelligent contracts within the GenLayer ecosystem. Built on top of [pytest](https://docs.pytest.org/en/stable/), this suite provides developers with a comprehensive set of tools for deploying, interacting with, and testing intelligent contracts efficiently in a simulated GenLayer environment.
30
+
31
+
32
+ ## Prerequisites
33
+
34
+ Before installing GenLayer Testing Suite, ensure you have the following prerequisites installed:
35
+
36
+ - Python (>=3.8)
37
+ - GenLayer Studio (Docker deployment)
38
+ - pip (Python package installer)
39
+
40
+ ## 🛠️ Installation and Usage
41
+
42
+ ### Installation Options
43
+
44
+ 1. Install from PyPI (recommended):
45
+ ```bash
46
+ $ pip install genlayer-test
47
+ ```
48
+
49
+ 2. Install from source:
50
+ ```bash
51
+ $ git clone https://github.com/yeagerai/genlayer-testing-suite
52
+ $ cd genlayer-testing-suite
53
+ $ pip install -e .
54
+ ```
55
+
56
+
57
+ ### Running Tests
58
+
59
+ 1. Run all tests:
60
+ ```bash
61
+ $ gltest
62
+ ```
63
+
64
+ 2. Run specific test file:
65
+ ```bash
66
+ $ gltest tests/test_mycontract.py
67
+ ```
68
+
69
+ 3. Run tests with specific markers:
70
+ ```bash
71
+ $ gltest -m "integration"
72
+ ```
73
+
74
+ 4. Run tests with verbose output:
75
+ ```bash
76
+ $ gltest -v
77
+ ```
78
+
79
+ For more detailed information and advanced usage, please refer to our [documentation](https://docs.genlayer.com/api-references/genlayer-testing-suite).
80
+
81
+ ## 🚀 Key Features
82
+ - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
83
+
84
+ - **Account & Transaction Management** – Create, fund, and track accounts and transactions within the GenLayer Simulator.
85
+
86
+ - **Contract Deployment & Interaction** – Deploy contracts, call methods, and monitor events seamlessly.
87
+
88
+ - **CLI Compatibility** – Run tests directly from the command line, ensuring smooth integration with the GenLayer CLI.
89
+
90
+ - **State Injection & Consensus Simulation** – Modify contract states dynamically and simulate consensus scenarios for advanced testing.
91
+
92
+ - **Prompt Testing & Statistical Analysis** – Evaluate and statistically test prompts for AI-driven contract execution.
93
+
94
+ - **Scalability to Security & Audit Tools** – Designed to extend into security testing and smart contract auditing.
95
+
96
+
97
+ By leveraging the GenLayer Testing Suite, developers can ensure their contracts perform reliably and securely before deployment on the live network.
@@ -0,0 +1,78 @@
1
+ # GenLayer Testing Suite
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
4
+ [![Discord](https://dcbadge.vercel.app/api/server/8Jm4v89VAu?compact=true&style=flat)](https://discord.gg/VpfmXEMN66)
5
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/yeagerai.svg?style=social&label=Follow%20%40GenLayer)](https://x.com/GenLayer)
6
+
7
+
8
+ ## About
9
+
10
+ The GenLayer Testing Suite is a powerful testing framework designed to streamline the development and validation of intelligent contracts within the GenLayer ecosystem. Built on top of [pytest](https://docs.pytest.org/en/stable/), this suite provides developers with a comprehensive set of tools for deploying, interacting with, and testing intelligent contracts efficiently in a simulated GenLayer environment.
11
+
12
+
13
+ ## Prerequisites
14
+
15
+ Before installing GenLayer Testing Suite, ensure you have the following prerequisites installed:
16
+
17
+ - Python (>=3.8)
18
+ - GenLayer Studio (Docker deployment)
19
+ - pip (Python package installer)
20
+
21
+ ## 🛠️ Installation and Usage
22
+
23
+ ### Installation Options
24
+
25
+ 1. Install from PyPI (recommended):
26
+ ```bash
27
+ $ pip install genlayer-test
28
+ ```
29
+
30
+ 2. Install from source:
31
+ ```bash
32
+ $ git clone https://github.com/yeagerai/genlayer-testing-suite
33
+ $ cd genlayer-testing-suite
34
+ $ pip install -e .
35
+ ```
36
+
37
+
38
+ ### Running Tests
39
+
40
+ 1. Run all tests:
41
+ ```bash
42
+ $ gltest
43
+ ```
44
+
45
+ 2. Run specific test file:
46
+ ```bash
47
+ $ gltest tests/test_mycontract.py
48
+ ```
49
+
50
+ 3. Run tests with specific markers:
51
+ ```bash
52
+ $ gltest -m "integration"
53
+ ```
54
+
55
+ 4. Run tests with verbose output:
56
+ ```bash
57
+ $ gltest -v
58
+ ```
59
+
60
+ For more detailed information and advanced usage, please refer to our [documentation](https://docs.genlayer.com/api-references/genlayer-testing-suite).
61
+
62
+ ## 🚀 Key Features
63
+ - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
64
+
65
+ - **Account & Transaction Management** – Create, fund, and track accounts and transactions within the GenLayer Simulator.
66
+
67
+ - **Contract Deployment & Interaction** – Deploy contracts, call methods, and monitor events seamlessly.
68
+
69
+ - **CLI Compatibility** – Run tests directly from the command line, ensuring smooth integration with the GenLayer CLI.
70
+
71
+ - **State Injection & Consensus Simulation** – Modify contract states dynamically and simulate consensus scenarios for advanced testing.
72
+
73
+ - **Prompt Testing & Statistical Analysis** – Evaluate and statistically test prompts for AI-driven contract execution.
74
+
75
+ - **Scalability to Security & Audit Tools** – Designed to extend into security testing and smart contract auditing.
76
+
77
+
78
+ By leveraging the GenLayer Testing Suite, developers can ensure their contracts perform reliably and securely before deployment on the live network.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: genlayer-test
3
+ Version: 0.1.0b2
4
+ Summary: GenLayer Testing Suite
5
+ Author: GenLayer
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Topic :: Software Development :: Testing
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: pytest
18
+ Requires-Dist: genlayer-py==0.1.0b1
19
+
20
+ # GenLayer Testing Suite
21
+
22
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
23
+ [![Discord](https://dcbadge.vercel.app/api/server/8Jm4v89VAu?compact=true&style=flat)](https://discord.gg/VpfmXEMN66)
24
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/yeagerai.svg?style=social&label=Follow%20%40GenLayer)](https://x.com/GenLayer)
25
+
26
+
27
+ ## About
28
+
29
+ The GenLayer Testing Suite is a powerful testing framework designed to streamline the development and validation of intelligent contracts within the GenLayer ecosystem. Built on top of [pytest](https://docs.pytest.org/en/stable/), this suite provides developers with a comprehensive set of tools for deploying, interacting with, and testing intelligent contracts efficiently in a simulated GenLayer environment.
30
+
31
+
32
+ ## Prerequisites
33
+
34
+ Before installing GenLayer Testing Suite, ensure you have the following prerequisites installed:
35
+
36
+ - Python (>=3.8)
37
+ - GenLayer Studio (Docker deployment)
38
+ - pip (Python package installer)
39
+
40
+ ## 🛠️ Installation and Usage
41
+
42
+ ### Installation Options
43
+
44
+ 1. Install from PyPI (recommended):
45
+ ```bash
46
+ $ pip install genlayer-test
47
+ ```
48
+
49
+ 2. Install from source:
50
+ ```bash
51
+ $ git clone https://github.com/yeagerai/genlayer-testing-suite
52
+ $ cd genlayer-testing-suite
53
+ $ pip install -e .
54
+ ```
55
+
56
+
57
+ ### Running Tests
58
+
59
+ 1. Run all tests:
60
+ ```bash
61
+ $ gltest
62
+ ```
63
+
64
+ 2. Run specific test file:
65
+ ```bash
66
+ $ gltest tests/test_mycontract.py
67
+ ```
68
+
69
+ 3. Run tests with specific markers:
70
+ ```bash
71
+ $ gltest -m "integration"
72
+ ```
73
+
74
+ 4. Run tests with verbose output:
75
+ ```bash
76
+ $ gltest -v
77
+ ```
78
+
79
+ For more detailed information and advanced usage, please refer to our [documentation](https://docs.genlayer.com/api-references/genlayer-testing-suite).
80
+
81
+ ## 🚀 Key Features
82
+ - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
83
+
84
+ - **Account & Transaction Management** – Create, fund, and track accounts and transactions within the GenLayer Simulator.
85
+
86
+ - **Contract Deployment & Interaction** – Deploy contracts, call methods, and monitor events seamlessly.
87
+
88
+ - **CLI Compatibility** – Run tests directly from the command line, ensuring smooth integration with the GenLayer CLI.
89
+
90
+ - **State Injection & Consensus Simulation** – Modify contract states dynamically and simulate consensus scenarios for advanced testing.
91
+
92
+ - **Prompt Testing & Statistical Analysis** – Evaluate and statistically test prompts for AI-driven contract execution.
93
+
94
+ - **Scalability to Security & Audit Tools** – Designed to extend into security testing and smart contract auditing.
95
+
96
+
97
+ By leveraging the GenLayer Testing Suite, developers can ensure their contracts perform reliably and securely before deployment on the live network.
@@ -0,0 +1,21 @@
1
+ README.md
2
+ pyproject.toml
3
+ genlayer_test.egg-info/PKG-INFO
4
+ genlayer_test.egg-info/SOURCES.txt
5
+ genlayer_test.egg-info/dependency_links.txt
6
+ genlayer_test.egg-info/entry_points.txt
7
+ genlayer_test.egg-info/requires.txt
8
+ genlayer_test.egg-info/top_level.txt
9
+ gltest/__init__.py
10
+ gltest/assertions.py
11
+ gltest/exceptions.py
12
+ gltest/plugin_config.py
13
+ gltest/plugin_hooks.py
14
+ gltest/types.py
15
+ gltest/artifacts/__init__.py
16
+ gltest/artifacts/contract.py
17
+ gltest/glchain/__init__.py
18
+ gltest/glchain/account.py
19
+ gltest/glchain/client.py
20
+ gltest/glchain/contract.py
21
+ gltest_cli/main.py
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ gltest = gltest_cli.main:main
3
+
4
+ [pytest11]
5
+ gltest = gltest.plugin_hooks
@@ -0,0 +1,2 @@
1
+ pytest
2
+ genlayer-py==0.1.0b1
@@ -0,0 +1,5 @@
1
+ build
2
+ dist
3
+ gltest
4
+ gltest_cli
5
+ tests
@@ -0,0 +1,18 @@
1
+ from gltest.glchain import (
2
+ create_account,
3
+ create_accounts,
4
+ get_contract_factory,
5
+ get_gl_client,
6
+ default_account,
7
+ accounts,
8
+ )
9
+
10
+ __all__ = [
11
+ "find_contract_definition",
12
+ "create_account",
13
+ "create_accounts",
14
+ "get_contract_factory",
15
+ "get_gl_client",
16
+ "default_account",
17
+ "accounts",
18
+ ]
@@ -0,0 +1,3 @@
1
+ from .contract import find_contract_definition
2
+
3
+ __all__ = ["find_contract_definition"]
@@ -0,0 +1,49 @@
1
+ import ast
2
+ from typing import Optional
3
+ from dataclasses import dataclass
4
+ from gltest.plugin_config import get_contracts_dir
5
+
6
+
7
+ @dataclass
8
+ class ContractDefinition:
9
+ """Class that represents a contract definition from a .gpy file."""
10
+
11
+ contract_name: str
12
+ contract_code: str
13
+ source_file: str
14
+ ast_node: ast.ClassDef
15
+
16
+
17
+ def find_contract_definition(contract_name: str) -> Optional[ContractDefinition]:
18
+ """
19
+ Search in the contracts directory for a contract definition.
20
+ TODO: Make this more robust to handle imports and other files.
21
+ """
22
+ contracts_dir = get_contracts_dir()
23
+
24
+ if not contracts_dir.exists():
25
+ raise FileNotFoundError(f"Contracts directory not found at: {contracts_dir}")
26
+
27
+ # Search through all .gpy files in the contracts directory
28
+ for file_path in contracts_dir.rglob("*.gpy"):
29
+ try:
30
+ # Read the file content
31
+ with open(file_path, "r") as f:
32
+ content = f.read()
33
+
34
+ # Parse the content into an AST
35
+ tree = ast.parse(content)
36
+
37
+ # Search for class definitions
38
+ for node in ast.walk(tree):
39
+ if isinstance(node, ast.ClassDef) and node.name == contract_name:
40
+ # Found the contract class
41
+ return ContractDefinition(
42
+ contract_name=contract_name,
43
+ source_file=str(file_path),
44
+ contract_code=content,
45
+ ast_node=node,
46
+ )
47
+ except Exception as e:
48
+ raise ValueError(f"Error reading file {file_path}: {e}")
49
+ return None
@@ -0,0 +1,17 @@
1
+ from genlayer_py.types import GenLayerTransaction
2
+
3
+
4
+ def tx_execution_succeeded(result: GenLayerTransaction) -> bool:
5
+ if "consensus_data" not in result:
6
+ return False
7
+ if "leader_receipt" not in result["consensus_data"]:
8
+ return False
9
+ if "execution_result" not in result["consensus_data"]["leader_receipt"]:
10
+ return False
11
+ execution_result = result["consensus_data"]["leader_receipt"]["execution_result"]
12
+ return execution_result == "SUCCESS"
13
+
14
+
15
+ def tx_execution_failed(result: GenLayerTransaction) -> bool:
16
+ return not tx_execution_succeeded(result)
17
+
@@ -0,0 +1,4 @@
1
+ class DeploymentError(Exception):
2
+ """Raised when a contract deployment fails."""
3
+
4
+ pass
@@ -0,0 +1,16 @@
1
+ from .contract import Contract, ContractFactory, get_contract_factory
2
+ from .client import gl_client, get_gl_client
3
+ from .account import create_accounts, create_account, accounts, default_account
4
+
5
+
6
+ __all__ = [
7
+ "Contract",
8
+ "ContractFactory",
9
+ "get_contract_factory",
10
+ "gl_client",
11
+ "create_account",
12
+ "default_account",
13
+ "accounts",
14
+ "create_accounts",
15
+ "get_gl_client",
16
+ ]
@@ -0,0 +1,17 @@
1
+ from genlayer_py import create_account
2
+
3
+
4
+ def create_accounts(n_accounts: int):
5
+ """
6
+ Create a list of accounts
7
+ """
8
+ accounts = []
9
+ for _ in range(n_accounts):
10
+ accounts.append(create_account())
11
+ return accounts
12
+
13
+ # Accounts for testing
14
+ accounts = create_accounts(n_accounts=10)
15
+
16
+ # Default account to use for transaction handling, if not specified
17
+ default_account = accounts[0]
@@ -0,0 +1,15 @@
1
+ from genlayer_py.chains import localnet
2
+ from genlayer_py import create_client
3
+ from .account import default_account
4
+ from functools import lru_cache
5
+
6
+ # Create the client
7
+ gl_client = create_client(chain=localnet, account=default_account)
8
+
9
+
10
+ @lru_cache(maxsize=1)
11
+ def get_gl_client():
12
+ """
13
+ Get the GenLayer client instance.
14
+ """
15
+ return gl_client
@@ -0,0 +1,216 @@
1
+ from dataclasses import dataclass
2
+ from gltest.artifacts import find_contract_definition
3
+ from gltest.assertions import tx_execution_failed
4
+ from gltest.exceptions import DeploymentError
5
+ from .client import get_gl_client
6
+ from gltest.types import CalldataEncodable, GenLayerTransaction, TransactionStatus
7
+ from eth_account.signers.local import LocalAccount
8
+ from typing import List, Any, Type, Optional, Dict, Callable
9
+ import types
10
+
11
+
12
+ @dataclass
13
+ class Contract:
14
+ """
15
+ Class to interact with a contract, its methods
16
+ are implemented dynamically at build time.
17
+ """
18
+
19
+ address: str
20
+ account: Optional[LocalAccount] = None
21
+ _schema: Optional[Dict[str, Any]] = None
22
+
23
+ @classmethod
24
+ def new(
25
+ cls,
26
+ address: str,
27
+ schema: Dict[str, Any],
28
+ account: Optional[LocalAccount] = None,
29
+ ) -> "Contract":
30
+ """
31
+ Build the methods from the schema.
32
+ """
33
+ if not isinstance(schema, dict) or "methods" not in schema:
34
+ raise ValueError("Invalid schema: must contain 'methods' field")
35
+ instance = cls(address=address, _schema=schema, account=account)
36
+ instance._build_methods_from_schema()
37
+ return instance
38
+
39
+ def _build_methods_from_schema(self):
40
+ if self._schema is None:
41
+ raise ValueError("No schema provided")
42
+ for method_name, method_info in self._schema["methods"].items():
43
+ if not isinstance(method_info, dict) or "readonly" not in method_info:
44
+ raise ValueError(
45
+ f"Invalid method info for '{method_name}': must contain 'readonly' field"
46
+ )
47
+ method_func = self.contract_method_factory(
48
+ method_name, method_info["readonly"]
49
+ )
50
+ bound_method = types.MethodType(method_func, self)
51
+ setattr(self, method_name, bound_method)
52
+
53
+ def connect(self, account: LocalAccount) -> "Contract":
54
+ """
55
+ Create a new instance of the contract with the same methods and a different account.
56
+ """
57
+ new_contract = self.__class__(
58
+ address=self.address, account=account, _schema=self._schema
59
+ )
60
+ new_contract._build_methods_from_schema()
61
+ return new_contract
62
+
63
+ @staticmethod
64
+ def contract_method_factory(method_name: str, read_only: bool) -> Callable:
65
+ """
66
+ Create a function that interacts with a specific contract method.
67
+ """
68
+
69
+ def read_contract_wrapper(
70
+ self,
71
+ args: Optional[List[CalldataEncodable]] = None,
72
+ ) -> Any:
73
+ """
74
+ Wrapper to the contract read method.
75
+ """
76
+ client = get_gl_client()
77
+ return client.read_contract(
78
+ address=self.address,
79
+ function_name=method_name,
80
+ account=self.account,
81
+ args=args,
82
+ )
83
+
84
+ def write_contract_wrapper(
85
+ self,
86
+ args: Optional[List[CalldataEncodable]] = None,
87
+ value: int = 0,
88
+ consensus_max_rotations: Optional[int] = None,
89
+ leader_only: bool = False,
90
+ wait_interval: Optional[int] = None,
91
+ wait_retries: Optional[int] = None,
92
+ wait_transaction_status: TransactionStatus = TransactionStatus.FINALIZED,
93
+ wait_triggered_transactions: bool = True,
94
+ wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
95
+ ) -> GenLayerTransaction:
96
+ """
97
+ Wrapper to the contract write method.
98
+ """
99
+ client = get_gl_client()
100
+ tx_hash = client.write_contract(
101
+ address=self.address,
102
+ function_name=method_name,
103
+ account=self.account,
104
+ value=value,
105
+ consensus_max_rotations=consensus_max_rotations,
106
+ leader_only=leader_only,
107
+ args=args,
108
+ )
109
+ extra_args = {}
110
+ if wait_interval is not None:
111
+ extra_args["interval"] = wait_interval
112
+ if wait_retries is not None:
113
+ extra_args["retries"] = wait_retries
114
+ receipt = client.wait_for_transaction_receipt(
115
+ transaction_hash=tx_hash,
116
+ status=wait_transaction_status,
117
+ **extra_args,
118
+ )
119
+ if wait_triggered_transactions:
120
+ triggered_transactions = receipt["triggered_transactions"]
121
+ for triggered_transaction in triggered_transactions:
122
+ client.wait_for_transaction_receipt(
123
+ transaction_hash=triggered_transaction,
124
+ status=wait_triggered_transactions_status,
125
+ **extra_args,
126
+ )
127
+ return receipt
128
+
129
+ return read_contract_wrapper if read_only else write_contract_wrapper
130
+
131
+
132
+ @dataclass
133
+ class ContractFactory:
134
+ """
135
+ A factory for deploying contracts.
136
+ """
137
+
138
+ contract_name: str
139
+ contract_code: str
140
+
141
+ @classmethod
142
+ def from_artifact(
143
+ cls: Type["ContractFactory"], contract_name: str
144
+ ) -> "ContractFactory":
145
+ """
146
+ Create a ContractFactory instance given the contract name.
147
+ """
148
+ contract_info = find_contract_definition(contract_name)
149
+ if contract_info is None:
150
+ raise ValueError(
151
+ f"Contract {contract_name} not found in the contracts directory"
152
+ )
153
+ return cls(
154
+ contract_name=contract_name, contract_code=contract_info.contract_code
155
+ )
156
+
157
+ def deploy(
158
+ self,
159
+ args: List[Any] = [],
160
+ account: Optional[LocalAccount] = None,
161
+ consensus_max_rotations: Optional[int] = None,
162
+ leader_only: bool = False,
163
+ wait_interval: Optional[int] = None,
164
+ wait_retries: Optional[int] = None,
165
+ wait_transaction_status: TransactionStatus = TransactionStatus.FINALIZED,
166
+ ) -> Contract:
167
+ """
168
+ Deploy the contract
169
+ """
170
+ client = get_gl_client()
171
+ try:
172
+ tx_hash = client.deploy_contract(
173
+ code=self.contract_code,
174
+ args=args,
175
+ account=account,
176
+ consensus_max_rotations=consensus_max_rotations,
177
+ leader_only=leader_only,
178
+ )
179
+ extra_args = {}
180
+ if wait_interval is not None:
181
+ extra_args["interval"] = wait_interval
182
+ if wait_retries is not None:
183
+ extra_args["retries"] = wait_retries
184
+ tx_receipt = client.wait_for_transaction_receipt(
185
+ transaction_hash=tx_hash, status=wait_transaction_status, **extra_args
186
+ )
187
+ if (
188
+ not tx_receipt
189
+ or "data" not in tx_receipt
190
+ or "contract_address" not in tx_receipt["data"]
191
+ ):
192
+ raise ValueError(
193
+ "Invalid transaction receipt: missing contract address"
194
+ )
195
+
196
+ if tx_execution_failed(tx_receipt):
197
+ raise ValueError(
198
+ f"Deployment transaction finalized with error: {tx_receipt}"
199
+ )
200
+
201
+ contract_address = tx_receipt["data"]["contract_address"]
202
+ schema = client.get_contract_schema(address=contract_address)
203
+ return Contract.new(
204
+ address=contract_address, schema=schema, account=account
205
+ )
206
+ except Exception as e:
207
+ raise DeploymentError(
208
+ f"Failed to deploy contract {self.contract_name}: {str(e)}"
209
+ ) from e
210
+
211
+
212
+ def get_contract_factory(contract_name: str) -> ContractFactory:
213
+ """
214
+ Get a ContractFactory instance for a contract.
215
+ """
216
+ return ContractFactory.from_artifact(contract_name)
@@ -0,0 +1,12 @@
1
+ from pathlib import Path
2
+
3
+ _contracts_dir = None
4
+
5
+
6
+ def set_contracts_dir(path: Path):
7
+ global _contracts_dir
8
+ _contracts_dir = path
9
+
10
+
11
+ def get_contracts_dir() -> Path:
12
+ return Path(_contracts_dir)
@@ -0,0 +1,16 @@
1
+ from gltest.plugin_config import set_contracts_dir
2
+ from pathlib import Path
3
+
4
+
5
+ def pytest_addoption(parser):
6
+ parser.addoption(
7
+ "--contracts-dir",
8
+ action="store",
9
+ default="contracts",
10
+ help="Directory containing contract files",
11
+ )
12
+
13
+
14
+ def pytest_configure(config):
15
+ contracts_dir = config.getoption("--contracts-dir")
16
+ set_contracts_dir(Path(contracts_dir))
@@ -0,0 +1,7 @@
1
+ # Re-export genlayer-py types
2
+ from genlayer_py.types import (
3
+ CalldataAddress,
4
+ GenLayerTransaction,
5
+ TransactionStatus,
6
+ CalldataEncodable,
7
+ )
@@ -0,0 +1,5 @@
1
+ import pytest
2
+
3
+
4
+ def main():
5
+ return pytest.main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "genlayer-test"
7
+ version = "0.1.0b2"
8
+ description = "GenLayer Testing Suite"
9
+ authors = [
10
+ { name = "GenLayer" }
11
+ ]
12
+ license = "MIT"
13
+ readme = "README.md"
14
+ requires-python = ">=3.8"
15
+ dependencies = [
16
+ "pytest",
17
+ "genlayer-py==0.1.0b1",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Topic :: Software Development :: Testing",
28
+ ]
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["."]
32
+
33
+ [project.entry-points.pytest11]
34
+ gltest = "gltest.plugin_hooks"
35
+
36
+ [project.scripts]
37
+ gltest = "gltest_cli.main:main"
@@ -1,2 +0,0 @@
1
- include LICENSE
2
- include README.md
@@ -1,17 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: genlayer-test
3
- Version: 0.0.1
4
- Summary: A minimal empty PyPI package for genlayer-test
5
- Author-email: GenLayer Labs Corp <tech@genlayer.com>
6
- License: MIT
7
- Requires-Python: >=3.6
8
- Description-Content-Type: text/markdown
9
-
10
- # GenLayer Test
11
-
12
- This is a minimal empty Python package for genlayer-test.
13
-
14
- ## Installation
15
- ```bash
16
- pip install genlayer-test
17
- ```
@@ -1,8 +0,0 @@
1
- # GenLayer Test
2
-
3
- This is a minimal empty Python package for genlayer-test.
4
-
5
- ## Installation
6
- ```bash
7
- pip install genlayer-test
8
- ```
@@ -1,17 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: genlayer-test
3
- Version: 0.0.1
4
- Summary: A minimal empty PyPI package for genlayer-test
5
- Author-email: GenLayer Labs Corp <tech@genlayer.com>
6
- License: MIT
7
- Requires-Python: >=3.6
8
- Description-Content-Type: text/markdown
9
-
10
- # GenLayer Test
11
-
12
- This is a minimal empty Python package for genlayer-test.
13
-
14
- ## Installation
15
- ```bash
16
- pip install genlayer-test
17
- ```
@@ -1,7 +0,0 @@
1
- MANIFEST.in
2
- README.md
3
- pyproject.toml
4
- genlayer_test.egg-info/PKG-INFO
5
- genlayer_test.egg-info/SOURCES.txt
6
- genlayer_test.egg-info/dependency_links.txt
7
- genlayer_test.egg-info/top_level.txt
@@ -1,14 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "genlayer-test"
7
- version = "0.0.1"
8
- authors = [
9
- { name = "GenLayer Labs Corp", email = "tech@genlayer.com" },
10
- ]
11
- description = "A minimal empty PyPI package for genlayer-test"
12
- readme = "README.md"
13
- requires-python = ">=3.6"
14
- license = {text = "MIT"}
File without changes