forked from cowdao-grants/cow-py
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21fbd4e
commit 7e56f1c
Showing
7 changed files
with
205 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .abi_handler import ABIHandler | ||
|
||
__all__ = [ | ||
"ABIHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# tests/codegen/components/test_base_contract.py | ||
|
||
|
||
def test_base_contract_singleton(): | ||
# Test that BaseContract follows the singleton pattern | ||
pass | ||
|
||
|
||
def test_base_contract_function_exists_in_abi(): | ||
# Test that BaseContract._function_exists_in_abi correctly checks function existence | ||
pass | ||
|
||
|
||
def test_base_contract_event_exists_in_abi(): | ||
# Test that BaseContract._event_exists_in_abi correctly checks event existence | ||
pass | ||
|
||
|
||
def test_base_contract_getattr(): | ||
# Test that BaseContract.__getattr__ correctly handles attribute access | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# tests/codegen/components/test_contract_factory.py | ||
|
||
|
||
def test_contract_factory_get_contract_class(): | ||
# Test that ContractFactory.get_contract_class correctly retrieves or creates contract class | ||
pass | ||
|
||
|
||
def test_contract_factory_create(): | ||
# Test that ContractFactory.create correctly creates an instance of the contract class | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import pytest | ||
from cow_py.codegen.solidity_converter import SolidityConverter, SolidityConverterError | ||
|
||
|
||
def test_solidity_converter_get_struct_name(): | ||
internal_type = "struct MyStruct" | ||
expected_result = "MyStruct" | ||
result = SolidityConverter._get_struct_name(internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_get_struct_name_invalid_internal_type(): | ||
internal_type = "uint256" | ||
with pytest.raises(SolidityConverterError): | ||
SolidityConverter._get_struct_name(internal_type) | ||
|
||
|
||
def test_solidity_converter_convert_type_enum(): | ||
solidity_type = "enum MyEnum" | ||
internal_type = "" | ||
expected_result = "MyEnum" | ||
result = SolidityConverter.convert_type(solidity_type, internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_type_array(): | ||
solidity_type = "uint256[]" | ||
internal_type = "" | ||
expected_result = "List[int]" | ||
result = SolidityConverter.convert_type(solidity_type, internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_type_tuple(): | ||
solidity_type = "tuple" | ||
internal_type = "struct MyStruct" | ||
expected_result = "MyStruct" | ||
result = SolidityConverter.convert_type(solidity_type, internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_type_fixed_size_array(): | ||
solidity_type = "uint256[3]" | ||
internal_type = "" | ||
expected_result = "Tuple[int, int, int]" | ||
result = SolidityConverter.convert_type(solidity_type, internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_type_unknown_type(): | ||
solidity_type = "unknown_type" | ||
internal_type = "" | ||
expected_result = "Any" | ||
result = SolidityConverter.convert_type(solidity_type, internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_extract_enum_name(): | ||
internal_type = "enum MyEnum.Option" | ||
expected_result = "MyEnum_Option" | ||
result = SolidityConverter._extract_enum_name(internal_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_array_or_basic_type_dynamic_array(): | ||
solidity_type = "address[]" | ||
expected_result = "List[str]" | ||
result = SolidityConverter._convert_array_or_basic_type(solidity_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_array_or_basic_type_fixed_size_array(): | ||
solidity_type = "bool[5]" | ||
expected_result = "Tuple[bool, bool, bool, bool, bool]" | ||
result = SolidityConverter._convert_array_or_basic_type(solidity_type) | ||
assert result == expected_result | ||
|
||
|
||
def test_solidity_converter_convert_array_or_basic_type_basic_type(): | ||
solidity_type = "bytes32" | ||
expected_result = "HexBytes" | ||
result = SolidityConverter._convert_array_or_basic_type(solidity_type) | ||
assert result == expected_result |