Runtime benchmarks: start (#136)

* runtime benchmarks: start

* merge tests + benchmarks infrastructure

* fix compilation

* Fix compilation issues with runtime-benchmark feature flag

Mainly involved pulling in correct dependencies and adding some functions
which were called but didn't yet exist.

* Fix broken compilation for tests

* Move header signing methods into trait

* Move signing related test helpers to own module

* Remove comment about feature flag

* Add constants to tests

* Add top level comment for testing utilities

Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
Svyatoslav Nikolsky
2020-06-24 23:25:21 +03:00
committed by Bastian Köcher
parent ea45fa8da7
commit e39ca0dc16
20 changed files with 944 additions and 528 deletions
+4 -7
View File
@@ -273,19 +273,16 @@ impl ValidatorsSource {
}
}
/// Get validator that should author the block at given step.
pub fn step_validator(header_validators: &[Address], header_step: u64) -> Address {
header_validators[(header_step % header_validators.len() as u64) as usize]
}
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use crate::mock::{custom_test_ext, genesis, validators_addresses, TestRuntime};
use crate::mock::{run_test, validators_addresses, TestRuntime};
use crate::{BridgeStorage, Headers, ScheduledChange, ScheduledChanges, StoredHeader};
use frame_support::StorageMap;
use primitives::{TransactionOutcome, H256};
const TOTAL_VALIDATORS: usize = 3;
pub(crate) fn validators_change_recept(parent_hash: H256) -> Receipt {
Receipt {
gas_used: 0.into(),
@@ -425,7 +422,7 @@ pub(crate) mod tests {
}
fn try_finalize_with_scheduled_change(scheduled_at: Option<HeaderId>) -> Option<ChangeToEnact> {
custom_test_ext(genesis(), validators_addresses(3)).execute_with(|| {
run_test(TOTAL_VALIDATORS, |_| {
let config = ValidatorsConfiguration::Single(ValidatorsSource::Contract(Default::default(), Vec::new()));
let validators = Validators::new(&config);
let storage = BridgeStorage::<TestRuntime>::new();