generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: all network related fixes [APE-1436] #4
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,36 @@ | ||
import pytest | ||
from ape_ethereum.transactions import TransactionType | ||
from ethpm_types import MethodABI | ||
|
||
from ape_base.ecosystem import _SECOND_STATIC_TYPE | ||
|
||
|
||
def test_gas_limit(base, eth_tester_provider): | ||
assert base.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(base, tx_type, eth_tester_provider): | ||
tx = base.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, _SECOND_STATIC_TYPE), | ||
) | ||
def test_encode_transaction(tx_type, base, eth_tester_provider): | ||
abi = MethodABI.parse_obj( | ||
{ | ||
"type": "function", | ||
"name": "fooAndBar", | ||
"stateMutability": "nonpayable", | ||
"inputs": [], | ||
"outputs": [], | ||
} | ||
) | ||
address = "0x274b028b03A250cA03644E6c578D81f019eE1323" | ||
actual = base.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 = """ | ||
base | ||
├── 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, base): | ||
# Do this in case local env changed it. | ||
base.mainnet.set_default_provider("geth") | ||
base.goerli.set_default_provider("geth") | ||
|
||
result = runner.invoke(cli, ["networks", "list"]) | ||
assert_rich_text(result.output, EXPECTED_OUTPUT) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bilbeyt What is this? Im trying to find more info