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

Minimal fee requires a ticker #385

Merged
merged 2 commits into from
Mar 8, 2019
Merged

Conversation

husio
Copy link
Contributor

@husio husio commented Mar 7, 2019

Do not allow a minimal fee to not have a ticker.

resolve #369

@husio husio requested a review from ethanfrey March 7, 2019 09:06
@husio husio requested a review from alpe as a code owner March 7, 2019 09:06
@husio husio removed the request for review from alpe March 7, 2019 09:07
@codecov-io

This comment has been minimized.

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

Code is fine.

One question about gconf... There is no way to return an error on parsing init if there is no ticker on the fee, but it will cause every tx on the chain to error.

I looked at gconf/genesis.go and it doens't know the type at all on parsing, which makes this impossible in current design.

Thus, nothing simple to do here as part of this PR, but a thought for future enhancements... to add some validation steps on init... Maybe Initializer of cash could run after gconf Initializer, then load those gconf values and do custom assertions on it (like IsZero() or Valdiate() passes).

What do you think? Stuff for a different issue in any case....

if cmp.Ticker == "" {
cmp.Ticker = fee.Ticker
return nil, errors.Wrap(coin.ErrInvalidCurrency, "no ticker")
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 fine, but isn't this also covered by the !fee.SameType() line below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Look like Coin.IsGTE is calling SameType as well, which means it would cover all three cases. I think I prefer verbosity here. Having those 3 rules tested explicitly made it easier for me to understand what is expected from the data in order to be valid.

I will merge it as it is right now. If you think this should be changed then I can create another pull request.

&FeeInfo{Fees: &min},
min,
errors.ErrEmpty.Is,
"no fee given, nothing expected": {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the cleanup.
one i found your map-driven (not table driven) tests with labels, there is no going back. love the descriptive names in the test errors (not test-4)

Copy link
Contributor Author

@husio husio Mar 8, 2019

Choose a reason for hiding this comment

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

I have learned it from one of the meetups in Berlin https://youtu.be/yszygk1cpEc?t=712

@ethanfrey
Copy link
Contributor

by the way, i like reading expect: coin.ErrInvalidCurrency.Is,

sounds like something yoda would say

@husio husio merged commit a98e01c into master Mar 8, 2019
@husio husio deleted the minimal_fee_requires_a_ticker branch March 8, 2019 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Require ticker for min fee - no wildcard
3 participants