[#7] Add contribution guideline with code style

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-10-05 13:14:51 +04:00 committed by Vladimir
parent 2112665844
commit d3f51ee398
23 changed files with 770 additions and 766 deletions

214
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,214 @@
# Contribution guide
First, thank you for contributing! We love and encourage pull requests from
everyone. Please follow the guidelines:
- Check the open [issues](https://github.com/nspcc-dev/neofs-testlib/issues) and
[pull requests](https://github.com/nspcc-dev/neofs-testlib/pulls) for existing
discussions.
- Open an issue first, to discuss a new feature or enhancement.
- Write tests, and make sure the test suite passes locally.
- Open a pull request, and reference the relevant issue(s).
- Make sure your commits are logically separated and have good comments
explaining the details of your change.
- After receiving feedback, amend your commits or add new ones as appropriate.
- **Have fun!**
## Development Workflow
Start by forking the `neofs-testlib` repository, make changes in a branch and then
send a pull request. We encourage pull requests to discuss code changes. Here
are the steps in details:
### Set up your GitHub Repository
Fork [NeoFS testlib upstream](https://github.com/nspcc-dev/neofs-testlib/fork) source
repository to your own personal repository. Copy the URL of your fork and clone it:
```shell
$ git clone <url of your fork>
```
### Set up git remote as ``upstream``
```shell
$ cd neofs-testlib
$ git remote add upstream https://github.com/nspcc-dev/neofs-testlib
$ git fetch upstream
```
### Set up development environment
To setup development environment for `neofs-testlib`, please, take the following steps:
1. Prepare virtualenv
```shell
$ virtualenv --python=python3.9 venv
$ source venv/bin/activate
```
2. Install all dependencies:
```shell
$ pip install -r requirements.txt
```
3. Setup pre-commit hooks to run code formatters on staged files before you run a `git commit` command:
```shell
$ pre-commit install
```
Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:
* isort is supported by [PyCharm](https://plugins.jetbrains.com/plugin/15434-isortconnect), [VS Code](https://cereblanco.medium.com/setup-black-and-isort-in-vscode-514804590bf9). Plugins exist for other IDEs/editors as well.
* black can be integrated with multiple editors, please, instructions are available [here](https://black.readthedocs.io/en/stable/integrations/editors.html).
### Create your feature branch
Before making code changes, make sure you create a separate branch for these
changes. Maybe you will find it convenient to name branch in
`<type>/<issue>-<changes_topic>` format.
```shell
$ git checkout -b feature/123-something_awesome
```
### Test your changes
Before submitting any changes to the library, please, make sure that all unit tests are passing. To run the tests, please, use the following command:
```shell
$ python -m unittest discover --start-directory tests
```
To enable tests that interact with SSH server, please, setup SSH server and set the following environment variables before running the tests:
```
SSH_SHELL_HOST = <address of the server>
SSH_SHELL_LOGIN = <login that has permissions to run python3 on the server>
SSH_SHELL_PRIVATE_KEY_PATH = <path to SSH private key on your machine>
SSH_SHELL_PRIVATE_KEY_PASSPHRASE = <passphrase for the SSH private key>
```
### Commit changes
After verification, commit your changes. There is a [great
post](https://chris.beams.io/posts/git-commit/) on how to write useful commit
messages. Try following this template:
```
[#Issue] Summary
Description
<Macros>
<Sign-Off>
```
```shell
$ git commit -am '[#123] Add some feature'
```
### Push to the branch
Push your locally committed changes to the remote origin (your fork):
```shell
$ git push origin feature/123-something_awesome
```
### Create a Pull Request
Pull requests can be created via GitHub. Refer to [this
document](https://help.github.com/articles/creating-a-pull-request/) for
detailed steps on how to create a pull request. After a Pull Request gets peer
reviewed and approved, it will be merged.
## DCO Sign off
All authors to the project retain copyright to their work. However, to ensure
that they are only submitting work that they have rights to, we are requiring
everyone to acknowledge this by signing their work.
Any copyright notices in this repository should specify the authors as "the
contributors".
To sign your work, just add a line like this at the end of your commit message:
```
Signed-off-by: Samii Sakisaka <samii@nspcc.ru>
```
This can easily be done with the `--signoff` option to `git commit`.
By doing this you state that you can certify the following (from [The Developer
Certificate of Origin](https://developercertificate.org/)):
```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
## Code Style
We use `black` and `isort` for code formatting. Please, refer to [Black code style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html) for details.
Type hints are mandatory for library's code:
- class attributes;
- function or method's parameters;
- function or method's return type.
The only exception is return type of test functions or methods - there's no much use in specifying `None` as return type for each test function.
Do not use relative imports. Even if the module is in the same package, use the full package name.
To format docstrings, please, use [Google Style Docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html). Type annotations should be specified in the code and not in docstrings (please, refer to [this sample](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html#type-annotations)).
## Editable installation
If you would like to modify code of the library in the integration with your test suite, you can use editable installation. For that, in virtual environment of your test suite (not in the virtual environment of the testlib itself!) run the following command (path to `neofs-testlib` directory might be different on your machine):
```shell
$ pip install -e ../neofs-testlib
```
## Building and publishing package
To build Python package of the library, please run the following command in the library root directory:
```shell
$ python -m build
```
This command will put wheel file and source archive under `dist` directory.
To check that package description will be correctly rendered at PyPI, please, use command:
```shell
$ twine check dist/*
```
To upload package to [test PyPI](https://test.pypi.org/project/neofs-testlib/), please, use command:
```shell
$ twine upload -r testpypi dist/*
```
It will prompt for your username and password. You would need to [create test PyPI account](https://test.pypi.org/account/register/) in order to execute it.
To upload package to actual PyPI, please, use command:
```shell
$ twine upload dist/*
```
It will prompt for your username and password. You would need to [create PyPI account](https://pypi.org/account/register/) in order to execute it.

View file

@ -14,74 +14,4 @@ The library provides the following primary components:
* `shell` - shells that can be used to execute commands. Currently library provides local shell (on machine that runs the code) or SSH shell that connects to a remote machine via SSH. * `shell` - shells that can be used to execute commands. Currently library provides local shell (on machine that runs the code) or SSH shell that connects to a remote machine via SSH.
## Contributing ## Contributing
Any contributions to the library should conform to the [contribution guideline](https://github.com/nspcc-dev/neofs-node/blob/master/CONTRIBUTING.md). Any contributions to the library should conform to the [contribution guideline](https://github.com/nspcc-dev/neofs-testlib/blob/master/CONTRIBUTING.md).
### Development Environment
To setup development environment for `neofs-testlib`, please, take the following steps:
1. Prepare virtualenv
```shell
$ virtualenv --python=python3.9 venv
$ source venv/bin/activate
```
2. Install all dependencies:
```shell
$ pip install -r requirements.txt
```
3. Setup pre-commit hooks to run code formatters on staged files before you run a `git commit` command:
```shell
$ pre-commit install
```
Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:
* isort is supported by [PyCharm](https://plugins.jetbrains.com/plugin/15434-isortconnect), [VS Code](https://cereblanco.medium.com/setup-black-and-isort-in-vscode-514804590bf9). Plugins exist for other IDEs/editors as well.
* black can be integrated with multiple editors, please, instructions are available [here](https://black.readthedocs.io/en/stable/integrations/editors.html).
### Unit Tests
Before submitting any changes to the library, please, make sure that all unit tests are passing. To run the tests, please, use the following command:
```shell
$ python -m unittest discover --start-directory tests
```
To enable tests that interact with SSH server, please, setup SSH server and set the following environment variables before running the tests:
```
SSH_SHELL_HOST = <address of the server>
SSH_SHELL_LOGIN = <login that has permissions to run python3 on the server>
SSH_SHELL_PRIVATE_KEY_PATH = <path to SSH private key on your machine>
SSH_SHELL_PRIVATE_KEY_PASSPHRASE = <passphrase for the SSH private key>
```
### Editable installation
If you would like to modify code of the library in the integration with your test suite, you can use editable installation. For that, in virtual environment of your test suite (not in the virtual environment of the testlib itself!) run the following command (path to `neofs-testlib` directory might be different on your machine):
```shell
$ pip install -e ../neofs-testlib
```
### Building and publishing package
To build Python package of the library, please run the following command in the library root directory:
```shell
$ python -m build
```
This command will put wheel file and source archive under `dist` directory.
To check that package description will be correctly rendered at PyPI, please, use command:
```shell
$ twine check dist/*
```
To upload package to [test PyPI](https://test.pypi.org/project/neofs-testlib/), please, use command:
```shell
$ twine upload -r testpypi dist/*
```
It will prompt for your username and password. You would need to [create test PyPI account](https://test.pypi.org/account/register/) in order to execute it.
To upload package to actual PyPI, please, use command:
```shell
$ twine upload dist/*
```
It will prompt for your username and password. You would need to [create PyPI account](https://pypi.org/account/register/) in order to execute it.

View file

@ -7,12 +7,10 @@ class NeofsAdmConfig(CliCommand):
"""Initialize basic neofs-adm configuration file. """Initialize basic neofs-adm configuration file.
Args: Args:
path (str): path to config (default ~/.neofs/adm/config.yml) path: Path to config (default ~/.neofs/adm/config.yml).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"config init", "config init",

View file

@ -16,16 +16,14 @@ class NeofsAdmMorph(CliCommand):
"""Deposit GAS for notary service. """Deposit GAS for notary service.
Args: Args:
account (str): wallet account address account: Wallet account address.
gas (str): amount of GAS to deposit gas: Amount of GAS to deposit.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
storage_wallet (str): path to storage node wallet storage_wallet: Path to storage node wallet.
till (str): notary deposit duration in blocks till: Notary deposit duration in blocks.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph deposit-notary", "morph deposit-notary",
@ -44,19 +42,17 @@ class NeofsAdmMorph(CliCommand):
script_hash: Optional[str] = None, script_hash: Optional[str] = None,
storage: Optional[str] = None, storage: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Dump GAS balances """Dump GAS balances.
Args: Args:
alphabet (str): dump balances of alphabet contracts alphabet: Dump balances of alphabet contracts.
proxy (str): dump balances of the proxy contract proxy: Dump balances of the proxy contract.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
script_hash (str): use script-hash format for addresses script_hash: Use script-hash format for addresses.
storage (str): dump balances of storage nodes from the current netmap storage: Dump balances of storage nodes from the current netmap.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph dump-balances", "morph dump-balances",
@ -71,12 +67,10 @@ class NeofsAdmMorph(CliCommand):
"""Section for morph network configuration commands. """Section for morph network configuration commands.
Args: Args:
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph dump-config", "morph dump-config",
@ -97,16 +91,13 @@ class NeofsAdmMorph(CliCommand):
"""Dump NeoFS containers to file. """Dump NeoFS containers to file.
Args: Args:
cid (str): containers to dump cid: Containers to dump.
container_contract (str): container contract hash (for networks without NNS) container_contract: Container contract hash (for networks without NNS).
dump (str): file where to save dumped containers dump: File where to save dumped containers (default: ./testlib_dump_container).
(default: ./testlib_dump_container) rpc_endpoint: N3 RPC node endpoint.
rpc_endpoint (str): N3 RPC node endpoint
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph dump-containers", "morph dump-containers",
@ -121,12 +112,10 @@ class NeofsAdmMorph(CliCommand):
"""Dump deployed contract hashes. """Dump deployed contract hashes.
Args: Args:
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph dump-hashes", "morph dump-hashes",
@ -140,16 +129,14 @@ class NeofsAdmMorph(CliCommand):
def force_new_epoch( def force_new_epoch(
self, rpc_endpoint: Optional[str] = None, alphabet: Optional[str] = None self, rpc_endpoint: Optional[str] = None, alphabet: Optional[str] = None
) -> CommandResult: ) -> CommandResult:
"""Create new NeoFS epoch event in the side chain """Create new NeoFS epoch event in the side chain.
Args: Args:
alphabet (str): path to alphabet wallets dir alphabet: Path to alphabet wallets dir.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph force-new-epoch", "morph force-new-epoch",
@ -166,17 +153,15 @@ class NeofsAdmMorph(CliCommand):
alphabet_wallets: str, alphabet_wallets: str,
size: int = 7, size: int = 7,
) -> CommandResult: ) -> CommandResult:
"""Generate alphabet wallets for consensus nodes of the morph network """Generate alphabet wallets for consensus nodes of the morph network.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
size (int): amount of alphabet wallets to generate (default 7) size: Amount of alphabet wallets to generate (default 7).
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph generate-alphabet", "morph generate-alphabet",
@ -194,18 +179,16 @@ class NeofsAdmMorph(CliCommand):
storage_wallet: str, storage_wallet: str,
initial_gas: Optional[str] = None, initial_gas: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Generate storage node wallet for the morph network """Generate storage node wallet for the morph network.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
initial_gas (str): initial amount of GAS to transfer initial_gas: Initial amount of GAS to transfer.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
storage_wallet (str): path to new storage node wallet storage_wallet: Path to new storage node wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph generate-storage-wallet", "morph generate-storage-wallet",
@ -232,23 +215,20 @@ class NeofsAdmMorph(CliCommand):
"""Section for morph network configuration commands. """Section for morph network configuration commands.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
container_alias_fee (int): container alias fee (default 500) container_alias_fee: Container alias fee (default 500).
container_fee (int): container registration fee (default 1000) container_fee: Container registration fee (default 1000).
contracts (str): path to archive with compiled NeoFS contracts contracts: Path to archive with compiled NeoFS contracts
(default fetched from latest github release) (default fetched from latest github release).
epoch_duration (int): amount of side chain blocks in one NeoFS epoch epoch_duration: Amount of side chain blocks in one NeoFS epoch (default 240).
(default 240) homomorphic_disabled: Disable object homomorphic hashing.
homomorphic_disabled: (bool): disable object homomorphic hashing local_dump: Path to the blocks dump file.
local_dump (str): path to the blocks dump file max_object_size: Max single object size in bytes (default 67108864).
max_object_size (int): max single object size in bytes (default 67108864) protocol: Path to the consensus node configuration.
protocol (str): path to the consensus node configuration rpc_endpoint: N3 RPC node endpoint.
rpc_endpoint (str): N3 RPC node endpoint
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph init", "morph init",
@ -269,15 +249,13 @@ class NeofsAdmMorph(CliCommand):
"""Refill GAS of storage node's wallet in the morph network """Refill GAS of storage node's wallet in the morph network
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
gas (str): additional amount of GAS to transfer gas: Additional amount of GAS to transfer.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
storage_wallet (str): path to new storage node wallet storage_wallet: Path to new storage node wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph refill-gas", "morph refill-gas",
@ -298,15 +276,13 @@ class NeofsAdmMorph(CliCommand):
"""Restore NeoFS containers from file. """Restore NeoFS containers from file.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
cid (str): containers to restore cid: Containers to restore.
dump (str): file to restore containers from dump: File to restore containers from.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph restore-containers", "morph restore-containers",
@ -325,19 +301,17 @@ class NeofsAdmMorph(CliCommand):
storage_price: Optional[int] = None, storage_price: Optional[int] = None,
fee_per_byte: Optional[int] = None, fee_per_byte: Optional[int] = None,
) -> CommandResult: ) -> CommandResult:
"""Set global policy values """Set global policy values.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
exec_fee_factor (int): ExecFeeFactor=<n1> exec_fee_factor: ExecFeeFactor=<n1>.
storage_price (int): StoragePrice=<n2> storage_price: StoragePrice=<n2>.
fee_per_byte (int): FeePerByte=<n3> fee_per_byte: FeePerByte=<n3>.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
non_param_attribute = "" non_param_attribute = ""
if exec_fee_factor: if exec_fee_factor:
@ -364,15 +338,13 @@ class NeofsAdmMorph(CliCommand):
"""Update NeoFS contracts. """Update NeoFS contracts.
Args: Args:
alphabet_wallets (str): path to alphabet wallets dir alphabet_wallets: Path to alphabet wallets dir.
contracts (str): path to archive with compiled NeoFS contracts contracts: Path to archive with compiled NeoFS contracts
(default fetched from latest github release) (default fetched from latest github release).
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph update-contracts", "morph update-contracts",

View file

@ -7,13 +7,11 @@ class NeofsAdmStorageConfig(CliCommand):
"""Initialize basic neofs-adm configuration file. """Initialize basic neofs-adm configuration file.
Args: Args:
account (str): wallet account account: Wallet account.
wallet (str): path to wallet wallet: Path to wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"storage-config", "storage-config",

View file

@ -11,15 +11,13 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Create NeoFS subnet. """Create NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
notary (bool): Flag to create subnet in notary environment notary: Flag to create subnet in notary environment.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet create", "morph subnet create",
@ -34,13 +32,11 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Read information about the NeoFS subnet. """Read information about the NeoFS subnet.
Args: Args:
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet get", "morph subnet get",
@ -57,15 +53,13 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Remove NeoFS subnet. """Remove NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet remove", "morph subnet remove",
@ -89,18 +83,16 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Add admin to the NeoFS subnet. """Add admin to the NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
admin (str): Hex-encoded public key of the admin admin: Hex-encoded public key of the admin.
client (str): Add client admin instead of node one client: Add client admin instead of node one.
group (str): Client group ID in text format (needed with --client only) group: Client group ID in text format (needed with --client only).
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet admin add", "morph subnet admin add",
@ -123,17 +115,15 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Remove admin of the NeoFS subnet. """Remove admin of the NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
admin (str): Hex-encoded public key of the admin admin: Hex-encoded public key of the admin.
client (str): Remove client admin instead of node one client: Remove client admin instead of node one.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet admin remove", "morph subnet admin remove",
@ -156,17 +146,15 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Add client to the NeoFS subnet. """Add client to the NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
client (str): Add client admin instead of node one client: Add client admin instead of node one.
group (str): Client group ID in text format (needed with --client only) group: Client group ID in text format (needed with --client only).
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet client add", "morph subnet client add",
@ -189,17 +177,15 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Remove client of the NeoFS subnet. """Remove client of the NeoFS subnet.
Args: Args:
address (str): Address in the wallet, optional address: Address in the wallet, optional.
client (str): Remove client admin instead of node one client: Remove client admin instead of node one.
group (str): ID of the client group to work with group: ID of the client group to work with.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet client remove", "morph subnet client remove",
@ -214,15 +200,13 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Add node to the NeoFS subnet. """Add node to the NeoFS subnet.
Args: Args:
node (str): Hex-encoded public key of the node node: Hex-encoded public key of the node.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet node add", "morph subnet node add",
@ -237,15 +221,13 @@ class NeofsAdmMorphSubnet(CliCommand):
"""Remove node from the NeoFS subnet. """Remove node from the NeoFS subnet.
Args: Args:
node (str): Hex-encoded public key of the node node: Hex-encoded public key of the node.
rpc_endpoint (str): N3 RPC node endpoint rpc_endpoint: N3 RPC node endpoint.
subnet (str): ID of the subnet to read subnet: ID of the subnet to read.
wallet (str): Path to file with wallet wallet: Path to file with wallet.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"morph subnet node remove", "morph subnet node remove",

View file

@ -7,7 +7,6 @@ class NeofsAdmVersion(CliCommand):
"""Application version """Application version
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute("", version=True) return self._execute("", version=True)

View file

@ -14,19 +14,18 @@ class NeofsAuthmateSecret(CliCommand):
address: Optional[str] = None, address: Optional[str] = None,
gate_address: Optional[str] = None, gate_address: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Obtain a secret from NeoFS network """Obtain a secret from NeoFS network.
Args: Args:
wallet (str): path to the wallet wallet: Path to the wallet.
address (str): address of wallet account address: Address of wallet account.
peer (str): address of neofs peer to connect to peer: Address of neofs peer to connect to.
gate_wallet (str): path to the wallet gate_wallet: Path to the wallet.
gate_address (str): address of wallet account gate_address: Address of wallet account.
access_key_id (str): access key id for s3 access_key_id: Access key id for s3.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"obtain-secret", "obtain-secret",
@ -55,32 +54,26 @@ class NeofsAuthmateSecret(CliCommand):
"""Obtain a secret from NeoFS network """Obtain a secret from NeoFS network
Args: Args:
wallet (str): path to the wallet wallet: Path to the wallet.
address (str): address of wallet account address: Address of wallet account.
peer (str): address of a neofs peer to connect to peer: Address of a neofs peer to connect to.
bearer_rules (str): rules for bearer token as plain json string bearer_rules: Rules for bearer token as plain json string.
gate_public_key (str): public 256r1 key of a gate (use flags repeatedly for gate_public_key: Public 256r1 key of a gate (use flags repeatedly for multiple gates).
multiple gates) container_id: Auth container id to put the secret into.
container_id (str): auth container id to put the secret into container_friendly_name: Friendly name of auth container to put the secret into.
container_friendly_name (str): friendly name of auth container to put the container_placement_policy: Placement policy of auth container to put the secret into
secret into (default: "REP 2 IN X CBF 3 SELECT 2 FROM * AS X").
container_placement_policy (str): placement policy of auth container to put the session_tokens: Create session tokens with rules, if the rules are set as 'none', no
secret into session tokens will be created.
(default: "REP 2 IN X CBF 3 SELECT 2 FROM * AS X") lifetime: Lifetime of tokens. For example 50h30m (note: max time unit is an hour so to
session_tokens (str): create session tokens with rules, if the rules are set a day you should use 24h). It will be ceil rounded to the nearest amount of
set as 'none', no session tokens will be created epoch. (default: 720h0m0s).
lifetime (str): Lifetime of tokens. For example 50h30m container_policy: Mapping AWS storage class to NeoFS storage policy as plain json string
(note: max time unit is an hour so to set a day you or path to json file.
should use 24h). It will be ceil rounded to the aws_cli_credentials: Path to the aws cli credential file.
nearest amount of epoch. (default: 720h0m0s)
container_policy (str): mapping AWS storage class to NeoFS storage policy as
plain json string or path to json file
aws_cli_credentials (str): path to the aws cli credential file
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"issue-secret", "issue-secret",

View file

@ -7,7 +7,6 @@ class NeofsAuthmateVersion(CliCommand):
"""Application version """Application version
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute("", version=True) return self._execute("", version=True)

View file

@ -14,22 +14,19 @@ class NeoGoCandidate(CliCommand):
gas: Optional[float] = None, gas: Optional[float] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Register as a new candidate """Register as a new candidate.
Args: Args:
address (str): Address to register address: Address to register.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. gas: Network fee to add to the transaction (prioritizing it).
gas (float): network fee to add to the transaction (prioritizing it) rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -51,22 +48,19 @@ class NeoGoCandidate(CliCommand):
gas: Optional[float] = None, gas: Optional[float] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Unregister self as a candidate """Unregister self as a candidate.
Args: Args:
address (str): Address to unregister address: Address to unregister.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. gas: Network fee to add to the transaction (prioritizing it).
gas (float): network fee to add to the transaction (prioritizing it) rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -88,23 +82,22 @@ class NeoGoCandidate(CliCommand):
gas: Optional[float] = None, gas: Optional[float] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Votes for a validator by calling "vote" method of a NEO native """Votes for a validator.
contract. Do not provide candidate argument to perform unvoting.
Voting happens by calling "vote" method of a NEO native contract. Do not provide
candidate argument to perform unvoting.
Args: Args:
candidate (str): Public key of candidate to vote for candidate: Public key of candidate to vote for.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. gas: Network fee to add to the transaction (prioritizing it).
gas (float): network fee to add to the transaction (prioritizing it) rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG

View file

@ -16,22 +16,21 @@ class NeoGoContract(CliCommand):
no_permissions: bool = False, no_permissions: bool = False,
bindings: Optional[str] = None, bindings: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Compile a smart contract to a .nef file """Compile a smart contract to a .nef file.
Args: Args:
input_file (str): Input file for the smart contract to be compiled input_file: Input file for the smart contract to be compiled.
out (str): Output of the compiled contract out: Output of the compiled contract.
manifest (str): Emit contract manifest (*.manifest.json) file into separate manifest: Emit contract manifest (*.manifest.json) file into separate file using
file using configuration input file (*.yml) configuration input file (*.yml).
config (str): Configuration input file (*.yml) config: Configuration input file (*.yml).
no_standards (bool): do not check compliance with supported standards no_standards: Do not check compliance with supported standards.
no_events (bool): do not check emitted events with the manifest no_events: Do not check emitted events with the manifest.
no_permissions (bool): do not check if invoked contracts are allowed in manifest no_permissions: Do not check if invoked contracts are allowed in manifest.
bindings (str): output file for smart-contract bindings configuration bindings: Output file for smart-contract bindings configuration.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract compile", "contract compile",
@ -59,24 +58,23 @@ class NeoGoContract(CliCommand):
"""Deploy a smart contract (.nef with description) """Deploy a smart contract (.nef with description)
Args: Args:
wallet (str): wallet to use to get the key for transaction signing; wallet: Wallet to use to get the key for transaction signing;
conflicts with wallet_config conflicts with wallet_config.
wallet_config (str): path to wallet config to use to get the key for transaction wallet_config: Path to wallet config to use to get the key for transaction signing;
signing; conflicts with wallet conflicts with wallet.
address (str): address to use as transaction signee (and gas source) address: Address to use as transaction signee (and gas source).
gas (float): network fee to add to the transaction (prioritizing it) gas: Network fee to add to the transaction (prioritizing it).
sysgas (float): system fee to add to transaction (compensating for execution) sysgas: System fee to add to transaction (compensating for execution).
out (str): file to put JSON transaction to out: File to put JSON transaction to.
force (bool): Do not ask for a confirmation force: Do not ask for a confirmation.
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
input_file (str): Input file for the smart contract (*.nef) input_file: Input file for the smart contract (*.nef).
manifest (str): Emit contract manifest (*.manifest.json) file into separate manifest: Emit contract manifest (*.manifest.json) file into separate file using
file using configuration input file (*.yml) configuration input file (*.yml).
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -96,17 +94,16 @@ class NeoGoContract(CliCommand):
config: Optional[str] = None, config: Optional[str] = None,
manifest: Optional[str] = None, manifest: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Generate wrapper to use in other contracts """Generate wrapper to use in other contracts.
Args: Args:
config (str): Configuration file to use config: Configuration file to use.
manifest (str): Read contract manifest (*.manifest.json) file manifest: Read contract manifest (*.manifest.json) file.
out (str): Output of the compiled contract out: Output of the compiled contract.
hash (str): Smart-contract hash hash: Smart-contract hash.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract generate-wrapper", "contract generate-wrapper",
@ -133,34 +130,33 @@ class NeoGoContract(CliCommand):
rpc_endpoint: Optional[str] = None, rpc_endpoint: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Executes given (as a script hash) deployed script with the given method, """Executes given (as a script hash) deployed script.
arguments and signers. Sender is included in the list of signers by default
with None witness scope. If you'd like to change default sender's scope, Script is executed with the given method, arguments and signers. Sender is included in
specify it via signers parameter. See testinvokefunction documentation for the list of signers by default with None witness scope. If you'd like to change default
the details about parameters. It differs from testinvokefunction in that this sender's scope, specify it via signers parameter. See testinvokefunction documentation
command sends an invocation transaction to the network. for the details about parameters. It differs from testinvokefunction in that this command
sends an invocation transaction to the network.
Args: Args:
scripthash (str): Function hash scripthash: Function hash.
method (str): Call method method: Call method.
arguments (str): Method arguments arguments: Method arguments.
multisig_hash (str): Multisig hash multisig_hash: Multisig hash.
wallet (str): wallet to use to get the key for transaction signing; wallet: Wallet to use to get the key for transaction signing;
conflicts with wallet_config conflicts with wallet_config.
wallet_config (str): path to wallet config to use to get the key for transaction wallet_config: Path to wallet config to use to get the key for transaction signing;
signing; conflicts with wallet conflicts with wallet.
address (str): address to use as transaction signee (and gas source) address: Address to use as transaction signee (and gas source).
gas (float): network fee to add to the transaction (prioritizing it) gas: Network fee to add to the transaction (prioritizing it).
sysgas (float): system fee to add to transaction (compensating for execution) sysgas: System fee to add to transaction (compensating for execution).
out (str): file to put JSON transaction to out: File to put JSON transaction to.
force (bool): force-push the transaction in case of bad VM state after force: Force-push the transaction in case of bad VM state after test script invocation.
test script invocation rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
multisig_hash = f"-- {multisig_hash}" or "" multisig_hash = f"-- {multisig_hash}" or ""
return self._execute( return self._execute(
@ -183,28 +179,27 @@ class NeoGoContract(CliCommand):
rpc_endpoint: Optional[str] = None, rpc_endpoint: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Executes given (as a script hash) deployed script with the given method, """Executes given (as a script hash) deployed script.
arguments and signers (sender is not included by default). If no method is given
"" is passed to the script, if no arguments are given, an empty array is
passed, if no signers are given no array is passed. If signers are specified,
the first one of them is treated as a sender. All of the given arguments are
encapsulated into array before invoking the script. The script thus should
follow the regular convention of smart contract arguments (method string and
an array of other arguments).
See more information and samples in `neo-go contract testinvokefunction --help` Script is executed with the given method, arguments and signers (sender is not included
by default). If no method is given "" is passed to the script, if no arguments are given,
an empty array is passed, if no signers are given no array is passed. If signers are
specified, the first one of them is treated as a sender. All of the given arguments are
encapsulated into array before invoking the script. The script thus should follow the
regular convention of smart contract arguments (method string and an array of other
arguments).
See more information and samples in `neo-go contract testinvokefunction --help`.
Args: Args:
scripthash (str): Function hash scripthash: Function hash.
method (str): Call method method: Call method.
arguments (str): Method arguments arguments: Method arguments.
multisig_hash (str): Multisig hash multisig_hash: Multisig hash.
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
multisig_hash = f"-- {multisig_hash}" or "" multisig_hash = f"-- {multisig_hash}" or ""
return self._execute( return self._execute(
@ -223,20 +218,18 @@ class NeoGoContract(CliCommand):
rpc_endpoint: Optional[str] = None, rpc_endpoint: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Executes given compiled AVM instructions in NEF format with the given set of """Executes given compiled AVM instructions in NEF format.
signers not included sender by default. See testinvokefunction documentation
for the details about parameters.
Instructions are executed with the given set of signers not including sender by default.
See testinvokefunction documentation for the details about parameters.
Args: Args:
input_file (str): Input location of the .nef file that needs to be invoked input_file: Input location of the .nef file that needs to be invoked.
conflicts with wallet_config rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
f"contract testinvokescript", f"contract testinvokescript",
@ -247,20 +240,15 @@ class NeoGoContract(CliCommand):
}, },
) )
def init( def init(self, name: str, skip_details: bool = False) -> CommandResult:
self, """Initialize a new smart-contract in a directory with boiler plate code.
name: str,
skip_details: bool = False,
) -> CommandResult:
"""Initialize a new smart-contract in a directory with boiler plate code
Args: Args:
name (str): name of the smart-contract to be initialized name: Name of the smart-contract to be initialized.
skip_details (bool): skip filling in the projects and contract details skip_details: Skip filling in the projects and contract details.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract init", "contract init",
@ -276,15 +264,14 @@ class NeoGoContract(CliCommand):
input_file: Optional[str] = None, input_file: Optional[str] = None,
compile: Optional[str] = None, compile: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Creates a user readable dump of the program instructions """Creates a user readable dump of the program instructions.
Args: Args:
input_file (str): input file of the program (either .go or .nef) input_file: Input file of the program (either .go or .nef).
compile (str): compile input file (it should be go code then) compile: Compile input file (it should be go code then).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract inspect", "contract inspect",
@ -301,16 +288,15 @@ class NeoGoContract(CliCommand):
manifest: str, manifest: str,
sender: Optional[str] = None, sender: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Calculates hash of a contract after deployment """Calculates hash of a contract after deployment.
Args: Args:
input_file (str): path to NEF file input_file: Path to NEF file.
sender (str): sender script hash or address sender: Sender script hash or address.
manifest (str): path to manifest file manifest: Path to manifest file.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract calc-hash", "contract calc-hash",
@ -330,22 +316,18 @@ class NeoGoContract(CliCommand):
sender: Optional[str] = None, sender: Optional[str] = None,
nef: Optional[str] = None, nef: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""Adds group to the manifest """Adds group to the manifest.
Args: Args:
wallet (str): wallet to use to get the key for transaction signing; wallet: Wallet to use to get the key for transaction signing; conflicts with wallet_config.
conflicts with wallet_config wallet_config: Path to wallet config to use to get the key for transaction signing; conflicts with wallet.
wallet_config (str): path to wallet config to use to get the key for transaction sender: Deploy transaction sender.
signing; conflicts with wallet address: Account to sign group with.
sender (str): deploy transaction sender nef: Path to the NEF file.
address (str): account to sign group with manifest: Path to the manifest.
nef (str): path to the NEF file
manifest (str): path to the manifest
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"contract manifest add-group", "contract manifest add-group",

View file

@ -14,19 +14,17 @@ class NeoGoDb(CliCommand):
count: int = 0, count: int = 0,
start: int = 0, start: int = 0,
) -> CommandResult: ) -> CommandResult:
"""Dump blocks (starting with block #1) to the file """Dump blocks (starting with block #1) to the file.
Args: Args:
config_path (str): path to config config_path: Path to config.
network (NetworkType): Select network type (default: private) network: Select network type (default: private).
count (int): number of blocks to be processed (default or 0: all chain) count: Number of blocks to be processed (default or 0: all chain) (default: 0).
(default: 0) start: Block number to start from (default: 0) (default: 0).
start (int): block number to start from (default: 0) (default: 0) out: Output file (stdout if not given).
out (srt): Output file (stdout if not given)
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"db dump", "db dump",
@ -47,20 +45,18 @@ class NeoGoDb(CliCommand):
dump: Optional[str] = None, dump: Optional[str] = None,
incremental: bool = False, incremental: bool = False,
) -> CommandResult: ) -> CommandResult:
"""Dump blocks (starting with block #1) to the file """Dump blocks (starting with block #1) to the file.
Args: Args:
config_path (str): path to config config_path: Path to config.
network (NetworkType): Select network type (default: private) network: Select network type (default: private).
count (int): number of blocks to be processed (default or 0: all chain) count: Number of blocks to be processed (default or 0: all chain) (default: 0).
(default: 0) input_file: Input file (stdin if not given).
input_file (str): Input file (stdin if not given) dump: Directory for storing JSON dumps.
dump (str): directory for storing JSON dumps incremental: Use if dump is incremental.
incremental (bool): use if dump is incremental
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"db restore", "db restore",

View file

@ -14,21 +14,19 @@ class NeoGoNep17(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Get address balance """Get address balance.
Args: Args:
address (str): Address to use address: Address to use.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens)) rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -50,21 +48,19 @@ class NeoGoNep17(CliCommand):
rpc_endpoint: Optional[str] = None, rpc_endpoint: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""import NEP-17 token to a wallet """Import NEP-17 token to a wallet.
Args: Args:
address (str): Token contract address or hash in LE address: Token contract address or hash in LE.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens)) rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -83,18 +79,16 @@ class NeoGoNep17(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""print imported NEP-17 token info """Print imported NEP-17 token info.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens))
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -114,19 +108,17 @@ class NeoGoNep17(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
force: bool = False, force: bool = False,
) -> CommandResult: ) -> CommandResult:
"""remove NEP-17 token from the wallet """Remove NEP-17 token from the wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens)) force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"wallet nep17 remove", "wallet nep17 remove",
@ -152,33 +144,32 @@ class NeoGoNep17(CliCommand):
amount: float = 0, amount: float = 0,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""Transfers specified NEP-17 token amount with optional 'data' parameter and cosigners """Transfers specified NEP-17 token amount.
list attached to the transfer. See 'contract testinvokefunction' documentation
for the details about 'data' parameter and cosigners syntax. If no 'data' is Transfer is executed with optional 'data' parameter and cosigners list attached to the
given then default nil value will be used. If no cosigners are given then the transfer. See 'contract testinvokefunction' documentation for the details about 'data'
sender with CalledByEntry scope will be used as the only signer. parameter and cosigners syntax. If no 'data' is given then default nil value will be used.
If no cosigners are given then the sender with CalledByEntry scope will be used as the only
signer.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. out: File to put JSON transaction to.
out (str): file to put JSON transaction to from_address: Address to send an asset from.
from_address (str): Address to send an asset from to_address: Address to send an asset to.
to_address (str): Address to send an asset to token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens)) force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation gas: Network fee to add to the transaction (prioritizing it).
gas (float): network fee to add to the transaction (prioritizing it) sysgas: System fee to add to transaction (compensating for execution).
sysgas (float): system fee to add to transaction (compensating for execution) force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation amount: Amount of asset to send.
amount (float) Amount of asset to send rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -206,29 +197,26 @@ class NeoGoNep17(CliCommand):
amount: float = 0, amount: float = 0,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""transfer NEP-17 tokens to multiple recipients """Transfer NEP-17 tokens to multiple recipients.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. out: File to put JSON transaction to.
out (str): file to put JSON transaction to from_address: Address to send an asset from.
from_address (str): Address to send an asset from to_address: Address to send an asset to.
to_address (str): Address to send an asset to token: Token to use (hash or name (for NEO/GAS or imported tokens)).
token (str): Token to use (hash or name (for NEO/GAS or imported tokens)) force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation gas: Network fee to add to the transaction (prioritizing it).
gas (float): network fee to add to the transaction (prioritizing it) sysgas: System fee to add to transaction (compensating for execution).
sysgas (float): system fee to add to transaction (compensating for execution) force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation amount: Amount of asset to send.
amount (float) Amount of asset to send rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG

View file

@ -5,13 +5,12 @@ from neofs_testlib.shell import CommandResult
class NeoGoNode(CliCommand): class NeoGoNode(CliCommand):
def start(self, network: NetworkType = NetworkType.PRIVATE) -> CommandResult: def start(self, network: NetworkType = NetworkType.PRIVATE) -> CommandResult:
"""Start a NEO node """Start a NEO node.
Args: Args:
network (NetworkType): Select network type (default: private) network: Select network type (default: private).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute("start", **{network.value: True}) return self._execute("start", **{network.value: True})

View file

@ -3,20 +3,15 @@ from neofs_testlib.shell import CommandResult
class NeoGoQuery(CliCommand): class NeoGoQuery(CliCommand):
def candidates( def candidates(self, rpc_endpoint: str, timeout: int = 10) -> CommandResult:
self, """Get candidates and votes.
rpc_endpoint: str,
timeout: int = 10,
) -> CommandResult:
"""Get candidates and votes
Args: Args:
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"query candidates", "query candidates",
@ -27,20 +22,15 @@ class NeoGoQuery(CliCommand):
}, },
) )
def committee( def committee(self, rpc_endpoint: str, timeout: int = 10) -> CommandResult:
self, """Get committee list.
rpc_endpoint: str,
timeout: int = 10,
) -> CommandResult:
"""Get committee list
Args: Args:
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"query committee", "query committee",
@ -51,20 +41,15 @@ class NeoGoQuery(CliCommand):
}, },
) )
def height( def height(self, rpc_endpoint: str, timeout: int = 10) -> CommandResult:
self, """Get node height.
rpc_endpoint: str,
timeout: int = 10,
) -> CommandResult:
"""Get node height
Args: Args:
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"query height", "query height",
@ -75,22 +60,16 @@ class NeoGoQuery(CliCommand):
}, },
) )
def tx( def tx(self, tx_hash: str, rpc_endpoint: str, timeout: int = 10) -> CommandResult:
self, """Query transaction status.
tx_hash: str,
rpc_endpoint: str,
timeout: int = 10,
) -> CommandResult:
"""Query transaction status
Args: Args:
tx_hash (str): Hash of transaction tx_hash: Hash of transaction.
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
f"query tx {tx_hash}", f"query tx {tx_hash}",
@ -101,20 +80,15 @@ class NeoGoQuery(CliCommand):
}, },
) )
def voter( def voter(self, rpc_endpoint: str, timeout: int = 10) -> CommandResult:
self, """Print NEO holder account state.
rpc_endpoint: str,
timeout: int = 10,
) -> CommandResult:
"""Print NEO holder account state
Args: Args:
rpc_endpoint (str): RPC node address rpc_endpoint: RPC node address.
timeout (int): Timeout for the operation (default: 10s) timeout: Timeout for the operation (default: 10s).
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute( return self._execute(
"query voter", "query voter",

View file

@ -4,10 +4,9 @@ from neofs_testlib.shell import CommandResult
class NeoGoVersion(CliCommand): class NeoGoVersion(CliCommand):
def get(self) -> CommandResult: def get(self) -> CommandResult:
"""Application version """Application version.
Returns: Returns:
str: Command string Command's result.
""" """
return self._execute("", version=True) return self._execute("", version=True)

View file

@ -13,20 +13,18 @@ class NeoGoWallet(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""claim GAS """Claim GAS.
Args: Args:
address (str): Address to claim GAS for address: Address to claim GAS for.
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -45,18 +43,16 @@ class NeoGoWallet(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
account: bool = False, account: bool = False,
) -> CommandResult: ) -> CommandResult:
"""create a new wallet """Create a new wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. account: Create a new account.
account (bool): Create a new account
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -75,18 +71,16 @@ class NeoGoWallet(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""convert addresses from existing NEO2 NEP6-wallet to NEO3 format """Convert addresses from existing NEO2 NEP6-wallet to NEO3 format.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. out: Where to write converted wallet.
out (str): where to write converted wallet
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -104,17 +98,15 @@ class NeoGoWallet(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""add an account to the existing wallet """Add an account to the existing wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag.
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -133,18 +125,16 @@ class NeoGoWallet(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
decrypt: bool = False, decrypt: bool = False,
) -> CommandResult: ) -> CommandResult:
"""check and dump an existing NEO wallet """Check and dump an existing NEO wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. decrypt: Decrypt encrypted keys.
decrypt (bool): Decrypt encrypted keys.
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -163,18 +153,16 @@ class NeoGoWallet(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""check and dump an existing NEO wallet """Check and dump an existing NEO wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. address: Address to print public keys for.
address (str): address to print public keys for
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -193,18 +181,16 @@ class NeoGoWallet(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
decrypt: bool = False, decrypt: bool = False,
) -> CommandResult: ) -> CommandResult:
"""export keys for address """Export keys for address.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. decrypt: Decrypt encrypted keys.
decrypt (bool): Decrypt encrypted keys.
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -225,20 +211,18 @@ class NeoGoWallet(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""import WIF of a standard signature contract """Import WIF of a standard signature contract.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. wif: WIF to import.
wif (str): WIF to import name: Optional account name.
name (str): Optional account name contract: Verification script for custom contracts.
contract (str): Verification script for custom contracts
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -259,20 +243,18 @@ class NeoGoWallet(CliCommand):
wallet: Optional[str] = None, wallet: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
) -> CommandResult: ) -> CommandResult:
"""import multisig contract """Import multisig contract.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. wif: WIF to import.
wif (str): WIF to import name: Optional account name.
name (str): Optional account name min_number: Minimal number of signatures (default: 0).
min_number (int): Minimal number of signatures (default: 0)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -295,22 +277,20 @@ class NeoGoWallet(CliCommand):
contract: Optional[str] = None, contract: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""import multisig contract """Import deployed contract.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. wif: WIF to import.
wif (str): WIF to import name: Optional account name.
name (str): Optional account name contract: Contract hash or address.
contract (str): Contract hash or address rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -330,19 +310,17 @@ class NeoGoWallet(CliCommand):
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
force: bool = False, force: bool = False,
) -> CommandResult: ) -> CommandResult:
"""check and dump an existing NEO wallet """Remove an account from the wallet.
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. address: Account address or hash in LE form to be removed.
address (str): Account address or hash in LE form to be removed force: Do not ask for a confirmation.
force (bool): Do not ask for a confirmation
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG
@ -365,22 +343,27 @@ class NeoGoWallet(CliCommand):
out: Optional[str] = None, out: Optional[str] = None,
timeout: int = 10, timeout: int = 10,
) -> CommandResult: ) -> CommandResult:
"""import multisig contract """Cosign transaction with multisig/contract/additional account.
Signs the given (in the input file) context (which must be a transaction signing context)
for the given address using the given wallet. This command can output the resulting JSON
(with additional signature added) right to the console (if no output file and no RPC
endpoint specified) or into a file (which can be the same as input one). If an RPC endpoint
is given it'll also try to construct a complete transaction and send it via RPC (printing
its hash if everything is OK).
Args: Args:
wallet (str): Target location of the wallet file ('-' to read from stdin); wallet: Target location of the wallet file ('-' to read from stdin);
conflicts with --wallet-config flag. conflicts with --wallet-config flag.
wallet_config (str): Target location of the wallet config file; wallet_config: Target location of the wallet config file; conflicts with --wallet flag.
conflicts with --wallet flag. out: File to put JSON transaction to.
out (str): file to put JSON transaction to input_file: File with JSON transaction.
input_file (str): file with JSON transaction address: Address to use.
address (str): Address to use rpc_endpoint: RPC node address.
rpc_endpoint (str): RPC node address timeout: Timeout for the operation (default: 10s).
timeout (int): Timeout for the operation (default: 10s)
Returns: Returns:
str: Command string Command's result.
""" """
assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG assert bool(wallet) ^ bool(wallet_config), self.WALLET_SOURCE_ERROR_MSG

View file

@ -10,9 +10,7 @@ def _dummy_step():
class DummyReporter(Reporter): class DummyReporter(Reporter):
""" """Dummy implementation of reporter, does not store artifacts anywhere."""
Dummy implementation of reporter, does not store artifacts anywhere.
"""
def step(self, name: str) -> AbstractContextManager: def step(self, name: str) -> AbstractContextManager:
return _dummy_step() return _dummy_step()

View file

@ -4,25 +4,25 @@ from typing import Any
class Reporter(ABC): class Reporter(ABC):
""" """Interface that supports storage of test artifacts in some reporting tool."""
Interface that supports storage of test artifacts in some reporting tool.
"""
@abstractmethod @abstractmethod
def step(self, name: str) -> AbstractContextManager: def step(self, name: str) -> AbstractContextManager:
""" """Register a new step in test execution.
Register a new step in test execution.
:param str name: Name of the step Args:
:return: step context name: Name of the step.
Returns:
Step context.
""" """
@abstractmethod @abstractmethod
def attach(self, content: Any, file_name: str) -> None: def attach(self, content: Any, file_name: str) -> None:
""" """Attach specified content with given file name to the test report.
Attach specified content with given file name to the test report.
:param any content: content to attach. If content value is not a string, it will be Args:
converted to a string. content: Content to attach. If content value is not a string, it will be
:param str file_name: file name of attachment. converted to a string.
file_name: File name of attachment.
""" """

View file

@ -5,11 +5,11 @@ from typing import Optional
@dataclass @dataclass
class InteractiveInput: class InteractiveInput:
""" """Interactive input for a shell command.
Interactive input for a shell command.
:attr str prompt_pattern: regular expression that defines expected prompt from the command. Attributes:
:attr str input: user input that should be supplied to the command in response to the prompt. prompt_pattern: regular expression that defines expected prompt from the command.
input: user input that should be supplied to the command in response to the prompt.
""" """
prompt_pattern: str prompt_pattern: str
@ -18,14 +18,14 @@ class InteractiveInput:
@dataclass @dataclass
class CommandOptions: class CommandOptions:
""" """Options that control command execution.
Options that control command execution.
:attr list interactive_inputs: user inputs that should be interactively supplied to Attributes:
the command during execution. interactive_inputs: user inputs that should be interactively supplied to
:attr int timeout: timeout for command execution (in seconds). the command during execution.
:attr bool check: controls whether to check return code of the command. Set to False to timeout: timeout for command execution (in seconds).
ignore non-zero return codes. check: controls whether to check return code of the command. Set to False to
ignore non-zero return codes.
""" """
interactive_inputs: Optional[list[InteractiveInput]] = None interactive_inputs: Optional[list[InteractiveInput]] = None
@ -35,8 +35,12 @@ class CommandOptions:
@dataclass @dataclass
class CommandResult: class CommandResult:
""" """Represents a result of a command executed via shell.
Represents a result of a command executed via shell.
Attributes:
stdout: complete content of stdout stream.
stderr: complete content of stderr stream.
return_code: return code (or exit code) of the command's process.
""" """
stdout: str stdout: str
@ -45,17 +49,18 @@ class CommandResult:
class Shell(ABC): class Shell(ABC):
""" """Interface of a command shell on some system (local or remote)."""
Interface of a command shell on some system (local or remote).
"""
@abstractmethod @abstractmethod
def exec(self, command: str, options: Optional[CommandOptions] = None) -> CommandResult: def exec(self, command: str, options: Optional[CommandOptions] = None) -> CommandResult:
""" """Executes specified command on this shell.
Executes specified command on this shell. To execute interactive command, user inputs
should be specified in *options*.
:param str command: command to execute on the shell. To execute interactive command, user inputs should be specified in *options*.
:param CommandOptions options: options that control command execution.
:return command result. Args:
command: Command to execute on the shell.
options: Options that control command execution.
Returns:
Command's result.
""" """

View file

@ -14,9 +14,7 @@ reporter = get_reporter()
class LocalShell(Shell): class LocalShell(Shell):
""" """Implements command shell on a local machine."""
Implements command shell on a local machine.
"""
def exec(self, command: str, options: Optional[CommandOptions] = None) -> CommandResult: def exec(self, command: str, options: Optional[CommandOptions] = None) -> CommandResult:
# If no options were provided, use default options # If no options were provided, use default options
@ -122,7 +120,8 @@ class LocalShell(Shell):
def _get_pexpect_process_result( def _get_pexpect_process_result(
self, command_process: Optional[pexpect.spawn], command: str self, command_process: Optional[pexpect.spawn], command: str
) -> CommandResult: ) -> CommandResult:
""" """Captures output of the process.
If command process is not None, captures output of this process. If command process is not None, captures output of this process.
If command process is None, then command fails when we attempt to start it, in this case If command process is None, then command fails when we attempt to start it, in this case
we use regular non-interactive process to get it's output. we use regular non-interactive process to get it's output.

View file

@ -26,7 +26,7 @@ reporter = get_reporter()
class HostIsNotAvailable(Exception): class HostIsNotAvailable(Exception):
"""Raised when host is not reachable via SSH connection""" """Raised when host is not reachable via SSH connection."""
def __init__(self, host: str = None): def __init__(self, host: str = None):
msg = f"Host {host} is not available" msg = f"Host {host} is not available"
@ -63,8 +63,7 @@ def log_command(func):
@lru_cache @lru_cache
def _load_private_key(file_path: str, password: Optional[str]) -> PKey: def _load_private_key(file_path: str, password: Optional[str]) -> PKey:
""" """Loads private key from specified file.
Loads private key from specified file.
We support several type formats, however paramiko doesn't provide functionality to determine We support several type formats, however paramiko doesn't provide functionality to determine
key type in advance. So we attempt to load file with each of the supported formats and then key type in advance. So we attempt to load file with each of the supported formats and then
@ -81,9 +80,7 @@ def _load_private_key(file_path: str, password: Optional[str]) -> PKey:
class SSHShell(Shell): class SSHShell(Shell):
""" """Implements command shell on a remote machine via SSH connection."""
Implements command shell on a remote machine via SSH connection.
"""
# Time in seconds to delay after remote command has completed. The delay is required # Time in seconds to delay after remote command has completed. The delay is required
# to allow remote command to flush its output buffer # to allow remote command to flush its output buffer

View file

@ -4,12 +4,15 @@ from neofs_testlib.shell.interfaces import CommandResult
def format_error_details(error: Exception) -> str: def format_error_details(error: Exception) -> str:
""" """Converts specified exception instance into a string.
Converts specified exception instance into a string that includes error message
and full stack trace.
:param Exception error: exception to convert. The resulting string includes error message and the full stack trace.
:return: string containing exception details.
Args:
error: Exception to convert.
Returns:
String containing exception details.
""" """
detail_lines = traceback.format_exception( detail_lines = traceback.format_exception(
etype=type(error), etype=type(error),
@ -20,11 +23,14 @@ def format_error_details(error: Exception) -> str:
def get_output_lines(result: CommandResult) -> list[str]: def get_output_lines(result: CommandResult) -> list[str]:
""" """Converts output of specified command result into separate lines.
Converts output of specified command result into separate lines trimmed from whitespaces.
Empty lines are excluded.
:param CommandResult result: result which output should be converted. Whitespaces are trimmed, empty lines are excluded.
:return: list of lines extracted from the output.
Args:
result: Command result which output should be converted.
Returns:
List of lines extracted from the output.
""" """
return [line.strip() for line in result.stdout.split("\n") if line.strip()] return [line.strip() for line in result.stdout.split("\n") if line.strip()]