paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Provide helpful message when incorrectly forcing balance to below ED #14702

Open gilescope opened 1 year ago

gilescope commented 1 year ago

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 commented 1 year ago

Here's another example where we use debug_asserts so I think this is fair game: https://github.com/paritytech/substrate/blob/19eb56a3fc51140b269e339ecb7e9a4a378c26ff/frame/support/src/traits/tokens/fungibles/regular.rs#L549C4-L549C60

gilescope commented 1 year ago

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?)