Skip to content

Implement help <method-name>#300

Open
liamgilligan wants to merge 1 commit intoConsensusJ:masterfrom
liamgilligan:walletd-help-implementation
Open

Implement help <method-name>#300
liamgilligan wants to merge 1 commit intoConsensusJ:masterfrom
liamgilligan:walletd-help-implementation

Conversation

@liamgilligan
Copy link
Contributor

PR for #260

Currently filler text is being used, tests have been written/modified to account for new help behavior.

Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a draft, but I have a couple suggestions

Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comment.

@msgilligan
Copy link
Member

@liamgilligan See PR #303

@msgilligan
Copy link
Member

msgilligan commented Jan 26, 2026

Please rebase now that PR #303 is merged. Also see WIP PR #309.

We should add a JsonRpcHelp (or similar name) class a new .help subpackage of o.c.jsonrpc. Because this module is currently JDK 11, we can't use record, but we can create a record-like class and convert to a record for 0.8.0.

@liamgilligan liamgilligan force-pushed the walletd-help-implementation branch from 4b0f436 to c6e6377 Compare January 30, 2026 01:24
@liamgilligan liamgilligan force-pushed the walletd-help-implementation branch from c6e6377 to d7729fa Compare February 5, 2026 22:43
Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few requested changes...

@liamgilligan liamgilligan force-pushed the walletd-help-implementation branch 4 times, most recently from 3f149c6 to f57f010 Compare February 27, 2026 02:03
@liamgilligan liamgilligan marked this pull request as ready for review February 27, 2026 02:05
Added short summary and detailed help text, added and updated tests, and
added javadoc and copyright headers when applicable.
@msgilligan msgilligan force-pushed the walletd-help-implementation branch from f57f010 to 65101e1 Compare March 5, 2026 03:31
Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have a few requests.

@Test
void helpForHelpMethod() throws IOException {
var expectedResultSubstring = "Displays detailed help text for the specified method.";
try (var client = new DefaultRpcClient(endpoint, "", "")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @BeforeEach to initialize client for each test. Use @AfterEach to call client.close(). This will make the individual tests more readable by eliminating the call to DefaultRpcClient and the try block.

var expectedResultSubstring = "Displays detailed help text for the specified method.";
try (var client = new DefaultRpcClient(endpoint, "", "")) {
String result = (String) client.send("help", "help");
assertTrue(result.contains(expectedResultSubstring));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now we don't need to match the entire text of the result, but we should verify that the result contains the method name and the correct argument name (and optional parens) So that's three asserts per test:

  1. contains method name
  2. contains parameter names and optionality info
  3. contains descriptive text

+ "Parameters:\n"
+ " None.\n")
);
private static final String helpString = createHelpString(EchoJsonRpcService::createHelpStringLine);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This member should probably be renamed something like allMethodsHelpString or similar and have a JavaDoc comment explaining what it is.


public CompletableFuture<String> help() {
/**
* Get detailed help information for a given command.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or all commands.

public CompletableFuture<String> help() {
/**
* Get detailed help information for a given command.
* @param method: A string containing the method name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or null for all commands.

if (method == null) {
return result(helpString);
}
if (helpMap.containsKey(method)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use an else if here, just to be a little more clear that exactly one of the three conditions will be true.

}

/**
* Create a string containing the name of each method and it's parameters in alphabetical order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No apostrophe on "it's"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants