-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
test(types/address): add unit tests for the file types/address.go #20237
Merged
+312
−26
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
061d055
test(types/address): add more unit tests for the file types/address.go
EmilGeorgiev da45914
add more test for format
EmilGeorgiev c19f5a8
add test cases fir val address
EmilGeorgiev d70d29b
fix failing tests
EmilGeorgiev cfdf494
add test cases for addrress type
EmilGeorgiev 2c45c4e
fix lint
EmilGeorgiev d27068c
Merge branch 'main' into tests-types/address
EmilGeorgiev e454d89
fix comments
EmilGeorgiev 2c488cf
fix comments
EmilGeorgiev 40fed6a
fix comments
EmilGeorgiev 804e649
fix golint
EmilGeorgiev c5abd38
fix failing tests
EmilGeorgiev d5e53b4
fix lint
EmilGeorgiev 20908d5
Merge branch 'main' into tests-types/address
EmilGeorgiev 884317a
Merge branch 'main' into tests-types/address
facundomedica 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 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 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,37 @@ | ||
package types_test | ||
|
||
import ( | ||
"encoding/hex" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func FuzzBech32AccAddrConsistencyYAML(f *testing.F) { | ||
if testing.Short() { | ||
f.Skip("running in -short mode") | ||
} | ||
|
||
f.Add([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}) | ||
f.Add([]byte{16, 1, 2, 3, 4, 5, 16, 27, 58, 9, 51, 11, 12, 13, 14, 15, 16, 17, 20, 21}) | ||
f.Add([]byte{19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}) | ||
|
||
f.Fuzz(func(t *testing.T, input []byte) { | ||
acc := types.AccAddress(input) | ||
res := &types.AccAddress{} | ||
|
||
testMarshalYAML(t, &acc, res, acc.MarshalYAML, res.UnmarshalYAML) | ||
|
||
str := acc.String() | ||
var err error | ||
*res, err = types.AccAddressFromBech32(str) | ||
require.NoError(t, err) | ||
require.Equal(t, acc, *res) | ||
|
||
str = hex.EncodeToString(acc) | ||
*res, err = types.AccAddressFromHexUnsafe(str) | ||
require.NoError(t, err) | ||
require.Equal(t, acc, *res) | ||
}) | ||
} |
Oops, something went wrong.
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.
Consider adding a comment to explain the purpose of skipping the test in short mode.
Adding a comment will help other developers understand why the test is skipped in short mode.