Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add benchmarks for QueryPallet and ExpectPallet
  • Loading branch information
KiChjang committed Dec 19, 2021
commit ab1c0c7336d63534c34589be0eb769af25909116
34 changes: 34 additions & 0 deletions xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,40 @@ benchmarks! {
})));
}

query_pallet {
let query_id = Default::default();
let destination = T::valid_destination().map_err(|_| BenchmarkError::Skip)?;
let max_weight = Default::default();
let mut executor = new_executor::<T>(Default::default());

let instruction = Instruction::QueryPallet {
module_name: b"frame_system".to_vec(),
response_info: QueryResponseInfo { destination, query_id, max_weight },
};
let xcm = Xcm(vec![instruction]);
}: {
executor.execute(xcm)?;
} verify {
// TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426
}

expect_pallet {
let mut executor = new_executor::<T>(Default::default());

let instruction = Instruction::ExpectPallet {
index: 0,
name: b"System".to_vec(),
module_name: b"frame_system".to_vec(),
crate_major: 4,
min_crate_minor: 0,
Comment on lines +398 to +402
Copy link
Member

Choose a reason for hiding this comment

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

is there a way to make this test more adaptable?

For example, you will easily fail this benchmark when the crate version increments. Better to query some value you know will succeed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well hmm, I guess I could create a dummy pallet, import it into the runtime and give it a fixed index location.

Copy link
Member

Choose a reason for hiding this comment

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

would also need to be generic for any runtime we benchmark this on too, so making a custom pallet is not a good choice.

};
let xcm = Xcm(vec![instruction]);
}: {
executor.execute(xcm)?;
} verify {
// the execution succeeding is all we need to verify this xcm was successful
}

impl_benchmark_test_suite!(
Pallet,
crate::generic::mock::new_test_ext(),
Expand Down