-
Notifications
You must be signed in to change notification settings - Fork 122
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
PoC: CLI parsing for itest tapd harness queries #1311
Conversation
Export a new function `NewApp` to handle app construction. This change simplifies the transition when `commands.go` is moved to a new package by reducing the number of exported symbols, resulting in a cleaner refactor.
Preemptively address lint errors in preparation for refactoring. The code will be moved to a new file, which would trigger linter complaints. Fixing these issues now ensures a clean copy and allows the refactor commit to pass linting.
This change prepares for a future commit that will consolidate all command-line functionality into a new package.
Export `Fatal` to ensure it remains accessible in `tapcli` after migrating it to a new package.
I think one nice side effect of this is that the command action function ( |
Pull Request Test Coverage Report for Build 12893807284Details
💛 - Coveralls |
780d1ba
to
f264abd
Compare
Just a drive-by comment: Would be nice if we could structure things the same as in
|
Relocate command-line parsing functionality to a new package called `commands`. This change will eventually enable integration tests to call into the parsing logic directly.
f264abd
to
bcb4cd5
Compare
bcb4cd5
to
7c06a51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Super useful to get more test coverage 💯
@@ -68,6 +68,21 @@ func getClient(ctx *cli.Context) (taprpc.TaprootAssetsClient, func()) { | |||
return taprpc.NewTaprootAssetsClient(conn), cleanUp | |||
} | |||
|
|||
// RpcBundle is an interface that bundles all the client interfaces | |||
// that are used by the tapcli. | |||
type RpcBundle interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move TapdClient
here instead, so we only have one place to update:
taproot-assets/itest/interface.go
Line 13 in a0ffe86
type TapdClient interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I hadn't realised before now that we only had that sort of interface in itest. There's a far bit of code to move around and simplify on that front. I'll spin it into a new PR when I've got a bit more time.
Let me know if you think I should work differently etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move TapdClient here instead, so we only have one place to update:
that seems to be the RPC client interface, how could it reside in the commands
package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move TapdClient here instead, so we only have one place to update:
that seems to be the RPC client interface, how could it reside in the
commands
package?
hmm will require some thought
Introduce functionality to wrap command actions, enabling them to target a specific RPC client (e.g., the `itest` tapd harness) directly. This eliminates the need to parse command-line arguments to determine the target tapd instance.
Apply the new RPC client targeting functionality to the `getinfo` command, allowing it to directly target (call into) a specific RPC client.
Introduce the `ExecTapCLI` function to execute arbitrary CLI commands against a specific tapd integration test instance. This enables running CLI commands on itest harnesses and retrieving their responses.
Update the existing `getinfo` integration test to ensure the same results can be reproduced using the new command-line functionality.
7c06a51
to
2a3ca21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -118,4 +118,14 @@ func testGetInfo(t *harnessTest) { | |||
// Ensure network field is set correctly. | |||
expectedNetwork := t.tapd.cfg.NetParams.Name | |||
require.Equal(t.t, expectedNetwork, resp.Network) | |||
|
|||
// Attempt to get the info using the CLI. | |||
respGeneric, err := ExecTapCLI(ctxt, t.tapd, "getinfo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 could also (as part of the PoC) assert a path where the command fails and returns an err, non-blocking
would also be nice to add some basic coverage on all commands in a future PR
@@ -68,6 +68,21 @@ func getClient(ctx *cli.Context) (taprpc.TaprootAssetsClient, func()) { | |||
return taprpc.NewTaprootAssetsClient(conn), cleanUp | |||
} | |||
|
|||
// RpcBundle is an interface that bundles all the client interfaces | |||
// that are used by the tapcli. | |||
type RpcBundle interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move TapdClient here instead, so we only have one place to update:
that seems to be the RPC client interface, how could it reside in the commands
package?
This PR is a preliminary step toward reproducing the commands detailed in external-group-key.md within our integration tests.
This PR introduces a new package,
cmd/commands
, to encapsulate command-line parsing functionality, enabling direct interaction with itest tapd harnesses via CLI functionality. The goal is to integrate command-line parsing into our integration tests to ensure CLI functionality is thoroughly tested.Summary of Changes
cmd/commands
, laying the groundwork for modular testing.ExecTapCLI
to execute commands directly against itest tapd harnesses, facilitating CLI-driven tests.getinfo
integration test to validate results via CLI commands, demonstrating proof-of-concept functionality.