-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from OpenZeppelin/fix-incorrect-address-payable…
…-in-function-returns-part-parsing Incorrect `address payable` in `function definition` `returns` part parsing
- Loading branch information
Showing
8 changed files
with
824 additions
and
771 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
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 |
---|---|---|
|
@@ -4,10 +4,8 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "solidity-grammar-parser" | ||
version = "0.0.2" | ||
authors = [ | ||
{ name="Georgii Plotnikov", email="[email protected]" }, | ||
] | ||
version = "0.0.3" | ||
authors = [{ name = "Georgii Plotnikov", email = "[email protected]" }] | ||
description = "Solidity ANTLR4 grammar Python parser" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
|
@@ -21,7 +19,7 @@ dependencies = [ | |
"coverage == 7.3.1", | ||
"simplejson == 3.19.1", | ||
"typing == 3.7.4.3", | ||
"typing_extensions == 4.8.0" | ||
"typing_extensions == 4.8.0", | ||
] | ||
|
||
[project.urls] | ||
|
@@ -30,9 +28,7 @@ dependencies = [ | |
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
include = [ | ||
"sgp*", | ||
] | ||
include = ["sgp*"] | ||
|
||
[tool.black] | ||
line-length = 88 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,45 @@ | ||
import unittest | ||
|
||
from sgp.sgp_parser import parse | ||
|
||
|
||
class TestFunctionReturnsAddressPayable(unittest.TestCase): | ||
def test_function_returns_address_payable(self) -> None: | ||
input = """function test() public returns(address payable) {}""" | ||
ast = parse(input) | ||
self.assertIsNotNone(ast) | ||
self.assertEqual(1, len(ast.children)) | ||
self.assertEqual("FunctionDefinition", ast.children[0].type) | ||
self.assertEqual(1, len(ast.children[0].return_parameters)) | ||
self.assertEqual( | ||
"VariableDeclaration", ast.children[0].return_parameters[0].type | ||
) | ||
self.assertIsNone(ast.children[0].return_parameters[0].name) | ||
self.assertIsNotNone(ast.children[0].return_parameters[0].type_name) | ||
self.assertEqual( | ||
"ElementaryTypeName", ast.children[0].return_parameters[0].type_name.type | ||
) | ||
self.assertEqual("address", ast.children[0].return_parameters[0].type_name.name) | ||
self.assertEqual( | ||
"payable", ast.children[0].return_parameters[0].type_name.state_mutability | ||
) | ||
|
||
def test_function_returns_address(self) -> None: | ||
input = """function test() public returns(address) {}""" | ||
ast = parse(input) | ||
self.assertIsNotNone(ast) | ||
self.assertEqual(1, len(ast.children)) | ||
self.assertEqual("FunctionDefinition", ast.children[0].type) | ||
self.assertEqual(1, len(ast.children[0].return_parameters)) | ||
self.assertEqual( | ||
"VariableDeclaration", ast.children[0].return_parameters[0].type | ||
) | ||
self.assertIsNone(ast.children[0].return_parameters[0].name) | ||
self.assertIsNotNone(ast.children[0].return_parameters[0].type_name) | ||
self.assertEqual( | ||
"ElementaryTypeName", ast.children[0].return_parameters[0].type_name.type | ||
) | ||
self.assertEqual("address", ast.children[0].return_parameters[0].type_name.name) | ||
self.assertIsNone( | ||
ast.children[0].return_parameters[0].type_name.state_mutability | ||
) |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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