Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

gilescope
Copy link
Contributor

Had to debug through some code to find out what was going wrong. This will make it obvious for the next person writing a new test and wondering why setting the balance doesn't work.

I've run all the tests in debug mode to make sure they currently all pass:

cargo nextest run --workspace --locked --verbose --features runtime-benchmarks,try-runtime,experimental
...
Summary [ 702.876s] 5452 tests run: 5452 passed (97 slow), 25 skipped

@gilescope gilescope added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Aug 2, 2023
@gilescope gilescope requested review from a team and NachoPal August 2, 2023 11:18
@gilescope
Copy link
Contributor Author

@gilescope gilescope requested a review from jsidorenko August 10, 2023 07:12
liamaharon
liamaharon previously approved these changes Aug 10, 2023
Copy link
Contributor

@liamaharon liamaharon left a comment

Choose a reason for hiding this comment

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

Looks fine.

However I'm not sure if this is correct usage of debug_assert!, which I understand is supposed to make assertions that should never fail - failure means there is some fundamental breakage in the way the program is supposed to execute.

Is there an alternative that maybe logs instead of asserts?

@liamaharon liamaharon dismissed their stale review August 10, 2023 09:58

not sure actually if this is correct use of debug_assert!

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

This should be an update of the docs and not more. The function doesn't prevent users to pass values that are smaller than ED. I also don't see any reason why we should prevent this and then having a debug_assert!.

@gilescope
Copy link
Contributor Author

Thanks for the feedback. I've switched it to log an error. I wanted there to be some warning/error in the output when someone runs cargo test. If the log message is just a warning then it's not visible from the command output, so there would be little point. (Could we configure warnings to be displayed when tests are run?)

Copy link
Contributor

@liamaharon liamaharon left a comment

Choose a reason for hiding this comment

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

I agree with Basti that this should be a docs change.

Fundamentally, the purpose of this pr is to clarify edge case behavior to the developer. Explanation of code behavior is not something that should happen during runtime, but happen when the devs read the docs.

A good developer will read the docs of a method if they encounter behaviour they do not expect while using it, so I don't think having this log provides additional value compared to just adding that.

Moreover, the log is quite verbose. I'd be concerned about setting precedent that it's OK to start documenting edge case behavior with logs throughout the codebase when a doc comment would suffice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants