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

go-filecoin show and go-filecoin chain combined (#1587) #3106

Conversation

deaswang
Copy link
Contributor

Fixes #1587

@anorth
Copy link
Member

anorth commented Jul 23, 2019

@shannonwells could you please shepherd this PR?

@deaswang deaswang force-pushed the refactor/1587-combine-chain-and-show branch from c42ace8 to 5bddcec Compare July 31, 2019 08:37
@deaswang
Copy link
Contributor Author

deaswang commented Aug 1, 2019

@shannonwells Any response for this PR?

Copy link
Member

@frrist frrist left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @deaswang and thank you for the submission. Please see my comment about out of scope changes -- they will be great to have after some design discussion.

assert.Contains(t, output, "Height: 1")
assert.Contains(t, output, "Nonce: 0")
assert.Contains(t, output, "Timestamp: ")
assert.Contains(t, output, "Messages: ")
Copy link
Member

Choose a reason for hiding this comment

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

We need a test case for blocks that contain messages. The block being tested here doesn't have any messages.

})
}

func TestBlockDaemon(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need all the chain_daemon_test use FAST Library? TestChainLs TestChainHead

@frrist frrist added the C-ux Category: Anything related to user experience label Aug 1, 2019

showMessages, _ := req.Options["messages"].(bool)
if showMessages == true {
_, err = fmt.Fprintf(w, `Messages: %s`+"\n", block.Messages)
Copy link
Contributor

@shannonwells shannonwells Aug 1, 2019

Choose a reason for hiding this comment

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

I'm curious to know what this output would look like. I imagine it would not be very human-friendly, which defeats the purpose of a Text output encoder. Also, what happens when you combine showMessages=false and you use --enc json ?

Copy link
Contributor Author

@deaswang deaswang Aug 2, 2019

Choose a reason for hiding this comment

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

in text enc, if show message, there will be one extra line Messages: [], if not show message, no message line.
in json enc, the code will not run here. no matter show or not show message, it will be the marshall of types.Block, so messages":null always exist in json body.
about the messages format, it depend on fmt.Fprintf in text enc, json Marshall in json enc.
about enc, if you run go-filecoin --help, you'll find it is main option, so if something need update, it is not only chain command problem.

},
Type: types.Block{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, block *types.Block) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

@anorth, @frrist I had thought we were avoiding adding extra Text encoders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is copy from old show block command. and almost all the command has extra Text encoders. so this text encoders should be one new issue to fix all commands.

Copy link
Contributor

@shannonwells shannonwells Aug 5, 2019

Choose a reason for hiding this comment

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

You are not wrong, but there has been some discussion about not putting in new Text encodings and having people add | jq if they want human-readable output. Even so it's fine to leave it as written.

})

t.Run("chain block <cid-of-genesis-block> --enc json returns JSON for a filecoin block", func(t *testing.T) {
d := th.NewDaemon(t,
Copy link
Contributor

Choose a reason for hiding this comment

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

Also need a test for combining --show-messages false and --enc json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not support --show-messages false and --enc json. it always show message in json enc.

Copy link
Contributor

@shannonwells shannonwells left a comment

Choose a reason for hiding this comment

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

Thank you for submitting this PR. I apologize for the delay in reviewing these changes. Please see my other comments.

@deaswang deaswang force-pushed the refactor/1587-combine-chain-and-show branch from bdc6628 to 753ac0c Compare August 5, 2019 02:30
@deaswang deaswang force-pushed the refactor/1587-combine-chain-and-show branch from c2e4435 to 9f2c142 Compare August 8, 2019 08:09
@deaswang
Copy link
Contributor Author

deaswang commented Aug 8, 2019

@frrist I have update the test use FAST Library.

@deaswang
Copy link
Contributor Author

#3196
for show command added some more function. combined should be unnecessary.
Close

@deaswang deaswang closed this Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-ux Category: Anything related to user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go-filecoin show and go-filecoin chain should be combined
4 participants