Joystream / Joystream/joystream
Use DefaultInstance in pallet-working-team for benchmark's test to work
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
Since for the test function to be generated benchmarks_instance calls benchmark_iter which calls impl_benchmark_test, there when creating the function it use the following:
fn [<test_benchmark_ $name>] <T: Trait> () -> Result<(), &'static str>
where T: frame_system::Trait, $( $where_clause )*
For this to work Trait needs a default implementation(otherwise Trait doesn't exist what exists is Trait<I>) or it would fail with the following error(compiled with -Z macro_backtrace):
error[E0107]: wrong number of type arguments: expected 1, found 0
--> /home/conectado/.cargo/git/checkouts/substrate-7e08433d4c370a21/00768a1/frame/benchmarking/src/lib.rs:1109:37
[....] snip for redability
...
1048 | / macro_rules! impl_benchmark_test {
1049 | (
1050 | { $( $where_clause:tt )* }
1051 | NO_INSTANCE
...
1109 | fn [<test_benchmark_ $name>] <T: Trait> () -> Result<(), &'static str>
| ^^^^^ expected 1 type argument
...
1152 | };
1153 | | }
| |__- in this expansion of `$crate::impl_benchmark_test!` (#4)
|
::: runtime-modules/working-team/src/benchmarking.rs:225:1
|
225 | / benchmarks_instance! {
226 | | _ { }
227 | |
228 | | /*
... |
581 | | verify { assert_eq!(true, true); }
582 | | }
| |__- in this macro invocation (#1)
error: aborting due to previous error
What is need to be done is:
- Change in
decl_storagehere the definition of theStorefor:
trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as WorkingTeam {
- Change
decl_moduleand the declaration of theTraitaccordingly - Change implement
Traitinstead ofTrait<TestWorkingTeamInstance>forTesthere because for the verify tests we useTest
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Update runtime-modules/working-team/src/lib.rs so the storage, module, and Trait declarations use DefaultInstance, then adjust runtime-modules/working-team/src/tests/mock.rs to implement Trait for Test. Start by reviewing the benchmarks_instance! usage in runtime-modules/working-team/src/benchmarking.rs and the linked benchmarking macro definitions. Done means the generated benchmark test compiles and the verify tests using Test pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100