Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI unit-testing for all commands with at least one argument #2352

Merged
merged 32 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
51852ae
Updated CLI commands to take flags everywhere and updated e2e tests a…
ljoss17 Jun 7, 2022
21580d3
Updated gm to use flags when calling Hermes
ljoss17 Jun 7, 2022
09c157f
Added missing flags to e2e test for 'query client state' command
ljoss17 Jun 7, 2022
612a707
Fixed flag errors in e2e tests and removed conflicting short flag.
ljoss17 Jun 7, 2022
88474db
Removed all short flags and updated CLI commands comments
ljoss17 Jun 8, 2022
a76599f
Removed forgotten short flags.
ljoss17 Jun 8, 2022
bf60ca1
Updated Hermes guide with flags instead of positional arguments
ljoss17 Jun 8, 2022
b9983ef
Updated script and comment with new long flags for Hermes
ljoss17 Jun 8, 2022
eb13cd0
Completed 'tx raw upgrade-' commands guide page. Updated Testing clie…
ljoss17 Jun 10, 2022
7a25573
Added changelog entry
ljoss17 Jun 10, 2022
2e3fff3
Added example unit-tests to the 'keys add' command
ljoss17 Jun 15, 2022
ff84119
Added value names to parameters and removed cli parsing unit-tests
ljoss17 Jun 17, 2022
4d35800
Cargo fmt changes
ljoss17 Jun 17, 2022
c7e1b9a
Updated flags in order to reflect ADR 010
ljoss17 Jun 17, 2022
c363e04
Updated guide to reflect flag changes from ADR 010
ljoss17 Jun 17, 2022
9e6d309
Updated gm script and e2e tests to match flag changes from ADR 010
ljoss17 Jun 17, 2022
52f5542
Merge branch 'master' into luca_joss/replace_positional_args_with_flags
ljoss17 Jun 20, 2022
89bfbf6
Fixed ADR 010 typo
ljoss17 Jun 20, 2022
433621d
Added unit-testing CLI argument parsing
ljoss17 Jun 21, 2022
e56b90e
Merge branch 'master' into luca_joss/hermes_cli_unit_tests
ljoss17 Jun 29, 2022
26a46c9
Updated unit tests for CLI and improved help output
ljoss17 Jun 29, 2022
ddd9913
Improved 'override_usage' for commands with multiple usages
ljoss17 Jun 29, 2022
ea134e1
Updated Hermes guide. Removed changes for issue #2349, they will be a…
ljoss17 Jun 30, 2022
2f38712
Removed manual validation for 'keys add' and 'keys delete' flags.
ljoss17 Jun 30, 2022
3eb9484
Added changelog entry
ljoss17 Jun 30, 2022
435d12f
Merge branch 'master' into luca_joss/hermes_cli_unit_tests
ljoss17 Jun 30, 2022
af2f9f0
Updated unit tests for command 'clear packets' to include new optiona…
ljoss17 Jun 30, 2022
0e5d73d
Cargo fmt
ljoss17 Jun 30, 2022
1f29fbf
Fixed 'keys add' in ADR 010 and added shell completion unit test for …
ljoss17 Jul 1, 2022
42d76e5
Merge branch 'master' into luca_joss/hermes_cli_unit_tests
ljoss17 Jul 1, 2022
99b57bf
Fix clippy warnings introduced in Rust 1.62
romac Jul 1, 2022
62dcd55
Merge branch 'master' into luca_joss/hermes_cli_unit_tests
romac Jul 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add unit tests for all Hermes commands with at least one argument
([#2358](https://github.com/informalsystems/ibc-rs/issues/2358))
15 changes: 9 additions & 6 deletions docs/architecture/adr-010-unified-cli-arguments-hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ The following commands are implemented, with the binary name `hermes` often omit
### Create a channel

* `create channel --a-chain <A_CHAIN_ID> --a-connection <A_CONNECTION_ID> --a-port <A_PORT_ID> --b-port <B_PORT_ID>`
* Optional: `[--chan-version <VERSION>] [--order <ORDER>]`
* Optional: `[--channel-version <VERSION>] [--order <ORDER>]`

* `create channel --a-chain <A_CHAIN_ID> --b-chain <B_CHAIN_ID> --a-port <A_PORT_ID> --b-port <B_PORT_ID> --new-client-conn`
* Optional: `[--chan-version <VERSION>] [--order <ORDER>]`
* `create channel --a-chain <A_CHAIN_ID> --b-chain <B_CHAIN_ID> --a-port <A_PORT_ID> --b-port <B_PORT_ID> --new-client-connection`
* Optional: `[--channel-version <VERSION>] [--order <ORDER>] [--yes]`

### Commands for keys

* `keys add --chain <CHAIN_ID> --key-file <KEY_FILE> --mnemonic-file <MNEMONIC_FILE>`
* `keys add --chain <CHAIN_ID> --key-file <KEY_FILE>`
* Optional: `[--hd-path <HD_PATH>] [--key-name <KEY_NAME>]`

* `keys add --chain <CHAIN_ID> --mnemonic-file <MNEMONIC_FILE>`
* Optional: `[--hd-path <HD_PATH>] [--key-name <KEY_NAME>]`

* `keys balance --chain <CHAIN_ID>`
Expand Down Expand Up @@ -86,8 +89,8 @@ The following commands are implemented, with the binary name `hermes` often omit

### Clear packets

* `clear packets --chain <CHAIN_ID> --port <PORT_ID> --channel <CHANNEL_ID>
--key-name <KEY> --counterparty-key-name <KEY>`
* `clear packets [OPTIONS] --chain <CHAIN_ID> --port <PORT_ID> --channel <CHANNEL_ID>`
* Optional: `[--key-name <KEY>] [--counterparty-key-name <KEY>]`

### Queries

Expand Down
28 changes: 14 additions & 14 deletions guide/src/commands/keys/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ DESCRIPTION:

FLAGS:
--chain <CHAIN_ID>
identifier of the chain
Identifier of the chain

--key-file <KEY_FILE>
path to the key file
Path to the key file

--mnemonic-file <MNEMONIC_FILE>
path to file containing mnemonic to restore the key from
Path to file containing mnemonic to restore the key from

OPTIONS:
--key-name <KEY_NAME>
name of the key (defaults to the `key_name` defined in the config)
Name of the key (defaults to the `key_name` defined in the config)

--hd-path <HD_PATH>
derivation path for this key [default: m/44'/118'/0'/0/0]
Derivation path for this key [default: m/44'/118'/0'/0/0]
```

#### Add a private key to a chain from a key file
Expand All @@ -102,17 +102,17 @@ DESCRIPTION:

FLAGS:
--chain <CHAIN_ID>
identifier of the chain
Identifier of the chain

--key-file <KEY_FILE>
path to the key file
Path to the key file

OPTIONS:
--key-name <KEY_NAME>
name of the key (defaults to the `key_name` defined in the config)
Name of the key (defaults to the `key_name` defined in the config)

--hd-path <HD_PATH>
derivation path for this key [default: m/44'/118'/0'/0/0]
Derivation path for this key [default: m/44'/118'/0'/0/0]
```

To add a private key file to a chain:
Expand Down Expand Up @@ -157,17 +157,17 @@ DESCRIPTION:

FLAGS:
--chain <CHAIN_ID>
identifier of the chain
Identifier of the chain

--mnemonic-file <MNEMONIC_FILE>
path to file containing mnemonic to restore the key from
Path to file containing mnemonic to restore the key from

OPTIONS:
--key-name <KEY_NAME>
name of the key (defaults to the `key_name` defined in the config)
Name of the key (defaults to the `key_name` defined in the config)

--hd-path <HD_PATH>
derivation path for this key [default: m/44'/118'/0'/0/0]
Derivation path for this key [default: m/44'/118'/0'/0/0]
```

To restore a key from its mnemonic:
Expand Down Expand Up @@ -336,4 +336,4 @@ If the command is successful a message with the following format will be display
},
"status": "success"
}
```
```
11 changes: 6 additions & 5 deletions guide/src/commands/path-setup/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ USAGE:
hermes create channel [OPTIONS] --a-chain <A_CHAIN_ID> --a-port <A_PORT_ID> --b-port <B_PORT_ID>

DESCRIPTION:
Create a new channel between two chains using a pre-existing connection.
Create a new channel between two chains.

Alternatively, create a new client and a new connection underlying the new channel if a pre-existing
connection is not provided.
Can create a new channel using a pre-existing connection or alternatively, create a new client and a
new connection underlying the new channel if a pre-existing connection is not provided.

FLAGS:
--a-chain <A_CHAIN_ID> Identifier of the side `a` chain for the new channel
Expand All @@ -26,13 +26,14 @@ FLAGS:
OPTIONS:

--a-connection <A_CONNECTION_ID> Identifier of the connection on chain `a` to use in creating
the new channel.
the new channel
--b-chain <B_CHAIN_ID> Identifier of the side `b` chain for the new channel
--chan-version <VERSION> The version for the new channel
--new-client-connection Indicates that a new client and connection will be created
underlying the new channel
--order <ORDER> The channel ordering, valid options 'unordered' (default) and
'ordered' [default: ORDER_UNORDERED]
--yes Skip new_client_connection confirmation
```

## Examples
Expand Down Expand Up @@ -210,7 +211,7 @@ interactive prompt that pops up notifying you that a new client and a new
connection will be initialized as part of the process:

```shell
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --order unordered --new-client-conn
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --order unordered --new-client-connection
```

```json
Expand Down
6 changes: 3 additions & 3 deletions guide/src/commands/queries/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ DESCRIPTION:

FLAGS:
--chain <CHAIN_ID>
identifier of the chain to query
Identifier of the chain to query

OPTIONS:
--verbose
enable verbose output, displaying the client and connection ids for each channel in the
Enable verbose output, displaying the client and connection ids for each channel in the
response
```

Expand Down Expand Up @@ -410,4 +410,4 @@ If the command is successful a message with the following format will be display
},
"status":"success"
}
```
```
16 changes: 8 additions & 8 deletions guide/src/commands/queries/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ DESCRIPTION:

FLAGS:
--host-chain <HOST_CHAIN_ID>
identifier of the chain to query
Identifier of the chain to query

OPTIONS:
--omit-chain-ids
omit printing the reference (or target) chain for each client
Omit printing the reference (or target) chain for each client

--reference-chain <REFERENCE_CHAIN_ID>
filter for clients which target a specific chain id (implies '--omit-chain-ids')
Filter for clients which target a specific chain id (implies '--omit-chain-ids')
```

__Example__
Expand Down Expand Up @@ -160,20 +160,20 @@ DESCRIPTION:

FLAGS:
--chain <CHAIN_ID>
identifier of the chain to query
Identifier of the chain to query

--client <CLIENT_ID>
identifier of the client to query
Identifier of the client to query

OPTIONS:
--consensus-height <CONSENSUS_HEIGHT>
height of the client's consensus state to query
Height of the client's consensus state to query

--height <HEIGHT>
the chain height context to be used, applicable only to a specific height
The chain height context to be used, applicable only to a specific height

--heights-only
show only consensus heights
Show only consensus heights
```

__Example__
Expand Down
1 change: 1 addition & 0 deletions guide/src/commands/queries/packet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SUBCOMMANDS:
pending Output a summary of pending packets in both directions
unreceived-acks Query unreceived acknowledgments
unreceived-packets Query unreceived packets
help Print this message or the help of the given subcommand(s)
```

## Table of Contents
Expand Down
2 changes: 1 addition & 1 deletion guide/src/commands/queries/tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Success: [
},
),
]
```
```
22 changes: 11 additions & 11 deletions guide/src/commands/raw/packet.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ DESCRIPTION:

FLAGS:
--amount <AMOUNT>
amount of coins (samoleans, by default) to send (e.g. `100000`)
Amount of coins (samoleans, by default) to send (e.g. `100000`)

--dst-chain <DST_CHAIN_ID>
identifier of the destination chain
Identifier of the destination chain

--src-chain <SRC_CHAIN_ID>
identifier of the source chain
Identifier of the source chain

--src-chan <SRC_CHANNEL_ID>
identifier of the source channel
Identifier of the source channel

--src-port <SRC_PORT_ID>
identifier of the source port
Identifier of the source port

OPTIONS:
--denom <DENOM>
denomination of the coins to send [default: samoleans]
Denomination of the coins to send [default: samoleans]

--key-name <KEY_NAME>
use the given signing key name (default: `key_name` config)
Use the given signing key name (default: `key_name` config)

--number-msgs <NUMBER_MSGS>
number of messages to send
Number of messages to send

--receiver <RECEIVER>
receiving account address on the destination chain
Receiving account address on the destination chain

--timeout-height-offset <TIMEOUT_HEIGHT_OFFSET>
timeout in number of blocks since current [default: 0]
Timeout in number of blocks since current [default: 0]

--timeout-seconds <TIMEOUT_SECONDS>
timeout in seconds since current [default: 0]
Timeout in seconds since current [default: 0]
```

__Example__
Expand Down
2 changes: 1 addition & 1 deletion guide/src/commands/raw/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ hermes tx raw upgrade-chain --dst-chain ibc-0 --src-chain ibc-1 --src-client 07-

```
Success: transaction::Hash(779713508B6103E37FADE60483BEE964A90BD67E5F20037B2CC4AE0E90B707C3)
```
```
2 changes: 1 addition & 1 deletion guide/src/commands/upgrade/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ It might be due to the chain not being at the height defined for the upgrade. Th
INFO ThreadId(01) [ibc-0 -> ibc-1:07-tendermint-0] upgrade Height: 0-82
```

Where in this case the chain is at height 82.
Where in this case the chain is at height 82.
12 changes: 8 additions & 4 deletions guide/src/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,32 @@ This can provide further specific guidance if we add additional parameters, e.g.
hermes help create channel
```

```
```shell
USAGE:
hermes create channel [OPTIONS] --a-chain <A_CHAIN_ID> --a-port <A_PORT_ID> --b-port <B_PORT_ID>

DESCRIPTION:
Create a new channel between two chains using a pre-existing connection. Alternatively, create a new
client and a new connection underlying the new channel if a pre-existing connection is not provided
Create a new channel between two chains.

Can create a new channel using a pre-existing connection or alternatively, create a new client and a
new connection underlying the new channel if a pre-existing connection is not provided.

FLAGS:
--a-chain <A_CHAIN_ID> Identifier of the side `a` chain for the new channel
--a-port <A_PORT_ID> Identifier of the side `a` port for the new channel
--b-port <B_PORT_ID> Identifier of the side `b` port for the new channel

OPTIONS:

--a-connection <A_CONNECTION_ID> Identifier of the connection on chain `a` to use in creating
the new channel.
the new channel
--b-chain <B_CHAIN_ID> Identifier of the side `b` chain for the new channel
--chan-version <VERSION> The version for the new channel
--new-client-connection Indicates that a new client and connection will be created
underlying the new channel
--order <ORDER> The channel ordering, valid options 'unordered' (default) and
'ordered' [default: ORDER_UNORDERED]
--yes Skip new_client_connection confirmation
```

Additionally, the `-h`/`--help` flags typical for CLI applications work on
Expand Down
6 changes: 3 additions & 3 deletions guide/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ and any further necessary modifications to the shell's startup files.
### Bash

```sh
hermes completions bash > ~/.local/share/bash-completion/completions/hermes
hermes completions --shell bash > ~/.local/share/bash-completion/completions/hermes
```

On a MacOS installation with Homebrew `bash-completion` formula installed, use

```sh
hermes completions bash > $(brew --prefix)/etc/bash_completion.d/hermes.bash-completion
hermes completions --shell bash > $(brew --prefix)/etc/bash_completion.d/hermes.bash-completion
```

### Zsh

```sh
hermes completions zsh > ~/.zfunc/_hermes
hermes completions --shell zsh > ~/.zfunc/_hermes
```

To make the shell load the script on initialization, add the directory to `fpath`
Expand Down
2 changes: 1 addition & 1 deletion guide/src/tutorials/local-chains/raw/packet.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ Next we will test the packet timeouts.

```shell
hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Perform client creation, connection and channel handshake to establish a new path between the `transfer` ports on `ibc-0` and `ibc-1` chains.

```shell
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-connection
```

If all the handshakes are performed successfully you should see a message similar to the one below:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Follow the steps below to connect three chains together and relay packets betwee
making an exception. Execute the following command:

```shell
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn
hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-connection
```

Then respond 'yes' to the prompt that pops up. Once the command has run to
Expand Down Expand Up @@ -166,7 +166,7 @@ Follow the steps below to connect three chains together and relay packets betwee
previous invocation we used to create a channel between `ibc-0` and `ibc-1`:

```shell
hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-conn
hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-connection
```

```json
Expand Down
Loading