generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
8 changed files
with
154 additions
and
69 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
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
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,34 @@ | ||
import pytest | ||
from ape_ethereum.transactions import TransactionType | ||
from ethpm_types import MethodABI | ||
|
||
|
||
def test_gas_limit(polygon_zkevm, eth_tester_provider): | ||
assert polygon_zkevm.config.local.gas_limit == "max" | ||
|
||
|
||
# NOTE: None because we want to show the default is STATIC | ||
@pytest.mark.parametrize("tx_type", (None, 0, "0x0")) | ||
def test_create_transaction(polygon_zkevm, tx_type, eth_tester_provider): | ||
tx = polygon_zkevm.create_transaction(type=tx_type) | ||
assert tx.type == TransactionType.STATIC.value | ||
assert tx.gas_limit == eth_tester_provider.max_gas | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"tx_type", | ||
(TransactionType.STATIC.value, TransactionType.DYNAMIC.value), | ||
) | ||
def test_encode_transaction(tx_type, polygon_zkevm, eth_tester_provider): | ||
abi = MethodABI.parse_obj( | ||
{ | ||
"type": "function", | ||
"name": "fooAndBar", | ||
"stateMutability": "nonpayable", | ||
"inputs": [], | ||
"outputs": [], | ||
} | ||
) | ||
address = "0x274b028b03A250cA03644E6c578D81f019eE1323" | ||
actual = polygon_zkevm.encode_transaction(address, abi, sender=address, type=tx_type) | ||
assert actual.gas_limit == eth_tester_provider.max_gas |
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,53 @@ | ||
import pytest | ||
from ape._cli import cli as ape_cli | ||
from click.testing import CliRunner | ||
|
||
EXPECTED_OUTPUT = """ | ||
polygon-zkevm | ||
├── mainnet | ||
│ └── geth (default) | ||
├── goerli | ||
│ └── geth (default) | ||
└── local (default) | ||
└── test (default) | ||
""".strip() | ||
|
||
|
||
@pytest.fixture | ||
def runner(): | ||
return CliRunner() | ||
|
||
|
||
@pytest.fixture | ||
def cli(): | ||
return ape_cli | ||
|
||
|
||
def assert_rich_text(actual: str, expected: str): | ||
""" | ||
The output from `rich` causes a bunch of extra spaces to | ||
appear at the end of each line. For easier testing, we remove those here. | ||
Also, we ignore whether the expected line is at the end or in the middle | ||
of the output to handle cases when the test-runner has additional plugins | ||
installed. | ||
""" | ||
expected_lines = [ | ||
x.replace("└", "").replace("├", "").replace("│", "").strip() | ||
for x in expected.strip().split("\n") | ||
] | ||
actual_lines = [ | ||
x.replace("└", "").replace("├", "").replace("│", "").strip() | ||
for x in actual.strip().split("\n") | ||
] | ||
|
||
for expected_line in expected_lines: | ||
assert expected_line in actual_lines | ||
|
||
|
||
def test_networks(runner, cli, polygon_zkevm): | ||
# Do this in case local env changed it. | ||
polygon_zkevm.mainnet.set_default_provider("geth") | ||
polygon_zkevm.goerli.set_default_provider("geth") | ||
|
||
result = runner.invoke(cli, ["networks", "list"]) | ||
assert_rich_text(result.output, EXPECTED_OUTPUT) |
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