-
Notifications
You must be signed in to change notification settings - Fork 42
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(evmstaking/types): add test cases for withdraw #55
test(evmstaking/types): add test cases for withdraw #55
Conversation
|
||
// Test with spaces, it should trim the spaces | ||
stringWithSpaces := " " + ws.String() + " " // add leading and trailing spaces | ||
trimmedString := strings.TrimSpace(stringWithSpaces) |
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.
I think we want to test that String()
will correctly trim spaces not TrimSpace
can trim spaces. You should add a new test case where it has leading or trailing spaces in the resulted string from a NewWithdrawal
. If it is impossible to construct such a case, you may skip the test case.
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.
@limengformal
I think it's good to skip the test case because testing that case is quite tricky.
To test that part, we would need to mock the String()
of Withdrawal
that intentionally returns a string with leading or trailing spaces. However, this seems quite complex and cumbersome. (Currently we'are using default String
defined in evmstaking.pb.go
for Withdrwal struct)
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.
@zsystm Then let's remove it
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.
@limengformal
You mean let's remove the code we are currently discussing in the comments?
I'll remove it soon.
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.
yes
Increased test coverage from 0% to 86.7%.
cover error cases
a116f10
to
c042fa4
Compare
This PR increased test coverage of client/x/evmstaking/types/withdraw.go from 0% to 100%.
issue: #64