-
Notifications
You must be signed in to change notification settings - Fork 46
Enhance sui blockchain #2521
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
Merged
+141
−14
Merged
Enhance sui blockchain #2521
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e1517d5
update sui version
FelixFan1992 0bc05ce
update
FelixFan1992 60e2916
improve sui blockchain
FelixFan1992 d1422b4
rebase
FelixFan1992 c382748
fix
FelixFan1992 d31e301
fix feedback
FelixFan1992 7cc1c3d
add changeset
FelixFan1992 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - update sui default image version and update logic to work with its SUI CLI output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package blockchain | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/docker/docker/pkg/stdcopy" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestParseSuiKeytoolGenerateJSON(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| const addr = "0xabc" | ||
| compact := `{"alias":null,"flag":0,"keyScheme":"ed25519","mnemonic":"a b c","peerId":"p","publicBase64Key":"k","suiAddress":"` + addr + `"}` | ||
|
|
||
| t.Run("compact one-line JSON", func(t *testing.T) { | ||
| t.Parallel() | ||
| got, err := parseSuiKeytoolGenerateJSON(compact) | ||
| require.NoError(t, err) | ||
| require.Equal(t, addr, got.SuiAddress) | ||
| }) | ||
|
|
||
| t.Run("preamble before JSON", func(t *testing.T) { | ||
| t.Parallel() | ||
| in := "some log line\n" + compact | ||
| got, err := parseSuiKeytoolGenerateJSON(in) | ||
| require.NoError(t, err) | ||
| require.Equal(t, addr, got.SuiAddress) | ||
| }) | ||
|
|
||
| t.Run("legacy newline after brace (old parser shape)", func(t *testing.T) { | ||
| t.Parallel() | ||
| legacy := "{\n \"suiAddress\": \"" + addr + "\"\n}" | ||
| got, err := parseSuiKeytoolGenerateJSON(legacy) | ||
| require.NoError(t, err) | ||
| require.Equal(t, addr, got.SuiAddress) | ||
| }) | ||
|
|
||
| t.Run("docker multiplexed stdout", func(t *testing.T) { | ||
| t.Parallel() | ||
| var buf bytes.Buffer | ||
| w := stdcopy.NewStdWriter(&buf, stdcopy.Stdout) | ||
| _, err := w.Write([]byte(compact)) | ||
| require.NoError(t, err) | ||
| got, err := parseSuiKeytoolGenerateJSON(buf.String()) | ||
| require.NoError(t, err) | ||
| require.Equal(t, addr, got.SuiAddress) | ||
|
FelixFan1992 marked this conversation as resolved.
|
||
| }) | ||
|
|
||
| t.Run("invalid", func(t *testing.T) { | ||
| t.Parallel() | ||
| _, err := parseSuiKeytoolGenerateJSON("no json here") | ||
| require.Error(t, err) | ||
| require.True(t, strings.Contains(err.Error(), "failed to parse")) | ||
| }) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The parse error includes a quoted slice of the full
keyOutoutput, which (perSuiWalletInfo) contains sensitive material like the mnemonic. This risks leaking secrets into test logs/CI output when parsing fails. Consider removing raw output from the error message, or redacting sensitive fields before including any snippet (e.g., only include a small prefix/suffix without mnemonic).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.
this is a valid point, but do we care if we leak secrets used for tests?