mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 02:51:01 +00:00
Exchange pallet benchmarks (#158)
* exchange benchmarks: framework * updated comment about tx size Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
ebdfffc4b1
commit
00bd13f8cd
@@ -27,7 +27,7 @@
|
||||
use crate::finality::FinalityVotes;
|
||||
use crate::validators::CHANGE_EVENT_HASH;
|
||||
use crate::verification::calculate_score;
|
||||
use crate::{HeaderToImport, Storage};
|
||||
use crate::{HeaderToImport, Storage, Trait};
|
||||
|
||||
use primitives::{
|
||||
rlp_encode,
|
||||
@@ -60,25 +60,34 @@ impl HeaderBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given hash.
|
||||
/// Creates default header on top of test parent with given hash.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_hash(parent_hash: H256) -> Self {
|
||||
use crate::mock::TestRuntime;
|
||||
Self::with_parent_hash_on_runtime::<crate::mock::TestRuntime>(parent_hash)
|
||||
}
|
||||
|
||||
/// Creates default header on top of test parent with given number. First parent is selected.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_number(parent_number: u64) -> Self {
|
||||
Self::with_parent_number_on_runtime::<crate::mock::TestRuntime>(parent_number)
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given hash.
|
||||
pub fn with_parent_hash_on_runtime<T: Trait>(parent_hash: H256) -> Self {
|
||||
use crate::Headers;
|
||||
use frame_support::StorageMap;
|
||||
|
||||
let parent_header = Headers::<TestRuntime>::get(&parent_hash).unwrap().header;
|
||||
let parent_header = Headers::<T>::get(&parent_hash).unwrap().header;
|
||||
Self::with_parent(&parent_header)
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given number. First parent is selected.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_number(parent_number: u64) -> Self {
|
||||
pub fn with_parent_number_on_runtime<T: Trait>(parent_number: u64) -> Self {
|
||||
use crate::HeadersByNumber;
|
||||
use frame_support::StorageMap;
|
||||
|
||||
let parent_hash = HeadersByNumber::get(parent_number).unwrap()[0].clone();
|
||||
Self::with_parent_hash(parent_hash)
|
||||
Self::with_parent_hash_on_runtime::<T>(parent_hash)
|
||||
}
|
||||
|
||||
/// Creates default header on top of non-existent parent.
|
||||
@@ -185,6 +194,12 @@ impl HeaderBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Update transactions root field of this header.
|
||||
pub fn with_transactions_root(mut self, transactions_root: H256) -> Self {
|
||||
self.header.transactions_root = transactions_root;
|
||||
self
|
||||
}
|
||||
|
||||
/// Signs header by given author.
|
||||
pub fn sign_by(self, author: &SecretKey) -> Header {
|
||||
self.header.sign_by(author)
|
||||
|
||||
Reference in New Issue
Block a user