Skip to content
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

Move test_impersonate_account test to tests_on_networks #1481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ jobs:
run: |
poetry install

# ====================== SETUP DEVNET ====================== #

- name: Install devnet
run: ./starknet_py/tests/install_devnet.sh

# ====================== RUN TESTS ====================== #

- name: Check circular imports
Expand Down
5 changes: 1 addition & 4 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ To install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-
Environment variables
^^^^^^^^^^^^^^^^^^^^^

In order to be able to run devnet client tests (``starknet_py/tests/e2e/client_devnet``) you must set environmental variable:
In order to be able to run tests on testnet network (``starknet_py/tests/e2e/tests_on_networks/``), you must set some environmental variables:

- ``SEPOLIA_RPC_URL``

To run tests on testnet network (``starknet_py/tests/e2e/tests_on_networks/``) additionally you must set:

- ``SEPOLIA_ACCOUNT_PRIVATE_KEY``
- ``SEPOLIA_ACCOUNT_ADDRESS``

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test_ci = ["test_ci_v1", "test_ci_v2"]
test_ci_v1 = "coverage run -a -m pytest --contract_dir=v1 starknet_py --ignore=starknet_py/tests/e2e/docs --ignore=starknet_py/tests/e2e/tests_on_networks"
test_ci_v2 = "coverage run -a -m pytest --contract_dir=v2 starknet_py --ignore=starknet_py/tests/e2e/docs --ignore=starknet_py/tests/e2e/tests_on_networks"

test_ci_on_networks = "coverage run -a -m pytest starknet_py/tests/e2e/tests_on_networks"
test_ci_on_networks = "coverage run -a -m pytest --contract_dir=v2 starknet_py/tests/e2e/tests_on_networks"

test_ci_docs = ["test_ci_docs_v1", "test_ci_docs_v2"]
test_ci_docs_v1 = "coverage run -a -m pytest --contract_dir=v1 starknet_py/tests/e2e/docs"
Expand Down
6 changes: 3 additions & 3 deletions starknet_py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"starknet_py.tests.e2e.client.fixtures.transactions",
"starknet_py.tests.e2e.client.fixtures.prepare_network",
"starknet_py.tests.e2e.tests_on_networks.fixtures",
"starknet_py.tests.e2e.client_devnet.fixtures.accounts",
"starknet_py.tests.e2e.client_devnet.fixtures.clients",
"starknet_py.tests.e2e.client_devnet.fixtures.contracts",
"starknet_py.tests.e2e.tests_on_networks.client_devnet.fixtures.accounts",
"starknet_py.tests.e2e.tests_on_networks.client_devnet.fixtures.clients",
"starknet_py.tests.e2e.tests_on_networks.client_devnet.fixtures.contracts",
]
6 changes: 4 additions & 2 deletions starknet_py/tests/e2e/tests_on_networks/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ async def test_transaction_not_received_max_fee_too_small(account_sepolia_testne

with pytest.raises(
ClientError,
match=r"Client failed with code 55. Message: Account validation failed. Data: Max fee \(\d+\) is too low. Minimum fee: \d+.",
match=r"Client failed with code 55. "
r"Message: Account validation failed. Data: Max fee \(\d+\) is too low. Minimum fee: \d+.",
):
await account.client.send_transaction(sign_invoke)

Expand All @@ -116,7 +117,8 @@ async def test_transaction_not_received_max_fee_too_big(account_sepolia_testnet)

with pytest.raises(
ClientError,
match=r"Client failed with code 55. Message: Account validation failed. Data: Max fee \(\d+\) exceeds balance \(\d+\).",
match=r"Client failed with code 55. "
r"Message: Account validation failed. Data: Max fee \(\d+\) exceeds balance \(\d+\).",
):
await account.client.send_transaction(sign_invoke)

Expand Down
5 changes: 4 additions & 1 deletion starknet_py/tests/e2e/tests_on_networks/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def client_sepolia_testnet() -> FullNodeClient:
return FullNodeClient(node_url=SEPOLIA_RPC_URL())


# pylint: disable=redefined-outer-name
@pytest.fixture(scope="package")
def account_sepolia_testnet(client_sepolia_testnet) -> Account:
def account_sepolia_testnet(
client_sepolia_testnet: FullNodeClient,
) -> Account:
return Account(
address=SEPOLIA_ACCOUNT_ADDRESS(),
client=client_sepolia_testnet,
Expand Down
40 changes: 20 additions & 20 deletions starknet_py/tests/e2e/tests_on_networks/trace_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ async def test_trace_transaction_invoke_v1(client_sepolia_testnet):
invoke_tx_hash = 0x6D1938DC27FF335BA1D585B2FD78C12C30EF12A25E0DD64461ECD2089F5F839
trace = await client_sepolia_testnet.trace_transaction(tx_hash=invoke_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=invoke_tx_hash)
assert type(tx) is InvokeTransactionV1
assert type(trace) is InvokeTransactionTrace

assert isinstance(tx, InvokeTransactionV1)
assert isinstance(trace, InvokeTransactionTrace)
assert trace.execute_invocation is not None
assert trace.execution_resources is not None

Expand All @@ -33,8 +34,9 @@ async def test_trace_transaction_invoke_v3(client_sepolia_testnet):
invoke_tx_hash = 0x26476DA48E56E5E7025543AD0BB9105DF00EE08571C6D17C4207462FF7717C4
trace = await client_sepolia_testnet.trace_transaction(tx_hash=invoke_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=invoke_tx_hash)
assert type(tx) is InvokeTransactionV3
assert type(trace) is InvokeTransactionTrace

assert isinstance(tx, InvokeTransactionV3)
assert isinstance(trace, InvokeTransactionTrace)
assert trace.execute_invocation is not None
assert trace.execution_resources is not None

Expand All @@ -45,8 +47,8 @@ async def test_trace_transaction_declare_v1(client_sepolia_testnet):
trace = await client_sepolia_testnet.trace_transaction(tx_hash=declare_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=declare_tx_hash)

assert (type(tx)) is DeclareTransactionV1
assert type(trace) is DeclareTransactionTrace
assert isinstance(tx, DeclareTransactionV1)
assert isinstance(trace, DeclareTransactionTrace)
assert trace.execution_resources is not None


Expand All @@ -56,8 +58,8 @@ async def test_trace_transaction_declare_v2(client_sepolia_testnet):
trace = await client_sepolia_testnet.trace_transaction(tx_hash=declare_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=declare_tx_hash)

assert (type(tx)) is DeclareTransactionV2
assert type(trace) is DeclareTransactionTrace
assert isinstance(tx, DeclareTransactionV2)
assert isinstance(trace, DeclareTransactionTrace)
assert trace.execution_resources is not None


Expand All @@ -67,8 +69,8 @@ async def test_trace_transaction_declare_v3(client_sepolia_testnet):
trace = await client_sepolia_testnet.trace_transaction(tx_hash=declare_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=declare_tx_hash)

assert (type(tx)) is DeclareTransactionV3
assert type(trace) is DeclareTransactionTrace
assert isinstance(tx, DeclareTransactionV3)
assert isinstance(trace, DeclareTransactionTrace)
assert trace.execution_resources is not None


Expand All @@ -82,8 +84,8 @@ async def test_trace_transaction_deploy_account_v1(client_sepolia_testnet):
)
tx = await client_sepolia_testnet.get_transaction(tx_hash=deploy_account_tx_hash)

assert (type(tx)) is DeployAccountTransactionV1
assert type(trace) is DeployAccountTransactionTrace
assert isinstance(tx, DeployAccountTransactionV1)
assert isinstance(trace, DeployAccountTransactionTrace)
assert trace.constructor_invocation is not None
assert trace.execution_resources is not None

Expand All @@ -98,8 +100,8 @@ async def test_trace_transaction_deploy_account_v3(client_sepolia_testnet):
)
tx = await client_sepolia_testnet.get_transaction(tx_hash=deploy_account_tx_hash)

assert (type(tx)) is DeployAccountTransactionV3
assert type(trace) is DeployAccountTransactionTrace
assert isinstance(tx, DeployAccountTransactionV3)
assert isinstance(trace, DeployAccountTransactionTrace)
assert trace.constructor_invocation is not None
assert trace.execution_resources is not None

Expand All @@ -112,8 +114,8 @@ async def test_trace_transaction_l1_handler(client_sepolia_testnet):
trace = await client_sepolia_testnet.trace_transaction(tx_hash=l1_handler_tx_hash)
tx = await client_sepolia_testnet.get_transaction(tx_hash=l1_handler_tx_hash)

assert (type(tx)) is L1HandlerTransaction
assert type(trace) is L1HandlerTransactionTrace
assert isinstance(tx, L1HandlerTransaction)
assert isinstance(trace, L1HandlerTransactionTrace)
assert trace.function_invocation is not None
assert trace.execution_resources is not None

Expand All @@ -135,7 +137,5 @@ async def test_get_block_traces(client_sepolia_testnet):
block = await client_sepolia_testnet.get_block(block_number=block_number)

assert len(block_transaction_traces) == len(block.transactions)
for i in range(len(block_transaction_traces)):
assert (
block_transaction_traces[i].transaction_hash == block.transactions[i].hash
)
for i, block_transaction_trace in enumerate(block_transaction_traces):
assert block_transaction_trace.transaction_hash == block.transactions[i].hash
Loading