Skip to content

Commit

Permalink
Add DevnetClient implementation (#1393)
Browse files Browse the repository at this point in the history
* unknown=EXCLUDE ramoved

* devnet version bump to 0.1.2 and test fix

* fix tests with pending block

* delete print

* devnet client setup

* default values added

* time rpc calls

* time advancing tests

* add 'generate_block' for set_time

* mint tests

* add test_predeployd_accounts

* class description update

* block create and drop

* dump, load, restart

* add account impersonate

* abort blocks tests

* account impersonation test

* more account impersonation tests

* postman hooks

* constant rename

* account impersonation test fix

* Rename fixtures in client_devnet tests

* Change loading of MyString contract

* Skip test if contract_dir v1 marked

* Simplify __init__

* Update description for get_account_balance

* Rename dataclass Mint and IncreasedTimeResponse

* Rename advancing_time_test.py file

* Rename 'devnet_forking_mode_client' fixture

* Refactor 'get_start_devnet_command' function

* Rename 'account_impersonated' fixture

* Remove testnet address

* Remove unnecessary accunt fixture

* Add PriceUnit enum type for unit paremeter

* Add env variable in workflows

* Fix time advancing test

* Refactor RpcHttpClient

* Migrate allow_none -> load_default=None in specific MarshmallowSchema

* Migrate default -> dump_default in specific MarshmallowSchema

* Update unit types

* Fix 'Hash' type handling

* Fix names in 'time_test.py'

* Add comment to address in 'account_to_impersonate' fixture

* Rename directory devnet -> devnet_utils

* Add docs for DevnetClient

* Correct the description

* Improve readability 'test_impersonated_account_should_fail'

* Rename MintSchema -> MintResponseSchema

* Change dataclass types from Hash to int

* Remove unnecessary 'Optional' type wrapper

* Change default value in 'get_account_balance()' block_tag

* Add function that converts int to eth address '_to_eth_address'

* Fix payload datatype serialization in 'send_message_to_l2'

* Update docs after devnet client tests

* Add docstrings for postman methods
  • Loading branch information
kkawula authored Aug 1, 2024
1 parent 92ca763 commit 49fbb85
Show file tree
Hide file tree
Showing 24 changed files with 982 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ jobs:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
env:
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -291,6 +293,8 @@ jobs:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
env:
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ API

api/client
api/full_node_client
api/devnet_client
api/account
api/client_models
api/client_errors
Expand Down
8 changes: 8 additions & 0 deletions docs/api/devnet_client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DevnetClient
============

.. py:module:: starknet_py.devnet_utils.devnet_client
.. autoclass-with-examples:: DevnetClient
:members:
:member-order: groupwise
5 changes: 4 additions & 1 deletion docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ To install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-
Environment variables
^^^^^^^^^^^^^^^^^^^^^

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

- ``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 starknet_py/abi/v1/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FunctionBaseSchema(Schema):
outputs = fields.List(
fields.Nested(TypeSchema()), data_key="outputs", required=True
)
state_mutability = fields.String(data_key="state_mutability", default=None)
state_mutability = fields.String(data_key="state_mutability", dump_default=None)


class FunctionAbiEntrySchema(FunctionBaseSchema):
Expand Down
2 changes: 1 addition & 1 deletion starknet_py/abi/v2/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FunctionBaseSchema(Schema):
outputs = fields.List(
fields.Nested(TypeSchema()), data_key="outputs", required=True
)
state_mutability = fields.String(data_key="state_mutability", default=None)
state_mutability = fields.String(data_key="state_mutability", dump_default=None)


class FunctionAbiEntrySchema(FunctionBaseSchema):
Expand Down
3 changes: 3 additions & 0 deletions starknet_py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,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",
]
Empty file.
Loading

0 comments on commit 49fbb85

Please sign in to comment.