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

Add validation for negative fee amount #397

Conversation

raghavapamula
Copy link
Contributor

Fixes # https://jira.coinbase-corp.com/browse/ROSE-90

Motivation

Operations of type fee must have negative value

Solution

Add validation for this behaviour

Open questions

if err != nil {
return err
}
if val.Sign() != -1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add test coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -513,6 +521,52 @@ func TestOperationsValidations(t *testing.T) {
construction: false,
err: ErrRelatedOperationInFeeNotAllowed,
},

"fee amount is non-negative": {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the happy path, we want error case test as well

xiaying-peng
xiaying-peng previously approved these changes Apr 12, 2022
@raghavapamula raghavapamula force-pushed the add_validation_for_negative_fee_amount branch 7 times, most recently from 75dad3c to 72fac48 Compare April 12, 2022 21:39
@raghavapamula raghavapamula force-pushed the add_validation_for_negative_fee_amount branch from 72fac48 to 99d1fdf Compare April 12, 2022 21:39
@xiaying-peng xiaying-peng self-requested a review April 12, 2022 21:52
@shrimalmadhur shrimalmadhur merged commit 30818f6 into coinbase:master Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants