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

Use construct_runtime in tests #8059

Merged
5 commits merged into from
Feb 6, 2021
Merged

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Feb 5, 2021

related #7949

@gui1117 gui1117 requested a review from ascjones February 5, 2021 16:30
@gui1117 gui1117 added A0-please_review Pull request needs code review. A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). 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. labels Feb 5, 2021
let _sender = ensure_signed(origin)?;
Value::put(n);
Ok(())
mod pallet_test {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here the pallet is declared in its own module, but nothing has changed

verify {
assert_eq!(Value::get(), Some(b));
}
mod benchmarks {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here benchmark macro is called in its own module because benchmark macro uses in scope Call for the pallet call. But construct_runtime already defines the outer Call.

the benchmark call and the test below haven't been changed


pub const CALL: &<Test as Config>::Call = &Call;
/// A simple call, which one doesn't matter.
pub const CALL: &<Test as Config>::Call = &Call::System(frame_system::Call::set_heap_pages(0u64));
Copy link
Contributor Author

@gui1117 gui1117 Feb 5, 2021

Choose a reason for hiding this comment

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

previously Call was a struct which panics in its implementation of dispatchable and was meant to be not used.
Using a random call doesn't change the nature of the test

@gui1117 gui1117 removed the A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). label Feb 5, 2021
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

Would be nice to somehow also warn if someone uses PalletInfo = (), because basically now this is now dangerous if you use it in any test setup that has multiple pallets.

@gui1117
Copy link
Contributor Author

gui1117 commented Feb 6, 2021

Would be nice to somehow also warn if someone uses PalletInfo = (), because basically now this is now dangerous if you use it in any test setup that has multiple pallets.

yes but we can't deprecate a trait implementation, we can only warn during execution by printing some message, or remove it.

@gui1117
Copy link
Contributor Author

gui1117 commented Feb 6, 2021

bot merge

@ghost
Copy link

ghost commented Feb 6, 2021

Waiting for commit status.

@ghost
Copy link

ghost commented Feb 6, 2021

Checks failed; merge aborted.

@gui1117
Copy link
Contributor Author

gui1117 commented Feb 6, 2021

bot merge

@ghost
Copy link

ghost commented Feb 6, 2021

Waiting for commit status.

@ghost ghost merged commit 0b719f8 into master Feb 6, 2021
@ghost ghost deleted the gui-use-construct-runtime-even-more branch February 6, 2021 20:12
@shawntabrizi
Copy link
Member

we can't deprecate a trait implementation

Why not?

@ascjones
Copy link
Contributor

ascjones commented Feb 8, 2021

rust-lang/rust#39935

@kianenigma
Copy link
Contributor

I think adding a manual line of warning in the impl is also capable of preventing some people messing up their test setup :D

@ascjones
Copy link
Contributor

ascjones commented Feb 8, 2021

I was thinking that once all PalletInfo = () instances have been removed then we just delete the () implementation entirely. Better to get a compilation error than spend ages debugging your tests for a storage collision.

@kianenigma
Copy link
Contributor

I was thinking that once all PalletInfo = () instances have been removed then we just delete the () implementation entirely. Better to get a compilation error than spend ages debugging your tests for a storage collision.

💯

This pull request was closed.
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants