Mock epoch index and randomness in SproofBuilder (for testing) (#1594)

* minimal babe randomness in sproof builder

* fix indexing

* fix index and clean comment

* use current para block for epoch and randomness

* epoch is para block randomness is relay block

* fix

* make more configurable but keep defaults

* fix export

* fix

* flatten

* better field names

* Update primitives/parachain-inherent/src/mock.rs

* Update primitives/parachain-inherent/src/mock.rs

* FMT

* FIX

* fmt

* Update primitives/parachain-inherent/src/mock.rs

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Amar Singh
2022-09-08 04:38:56 -04:00
committed by GitHub
parent 11b18e89c6
commit 49397d9a79
2 changed files with 40 additions and 2 deletions
@@ -44,6 +44,7 @@ pub struct RelayStateSproofBuilder {
pub hrmp_channels: BTreeMap<relay_chain::v2::HrmpChannelId, AbridgedHrmpChannel>,
pub current_slot: relay_chain::v2::Slot,
pub current_epoch: u64,
pub randomness: relay_chain::Hash,
}
impl Default for RelayStateSproofBuilder {
@@ -69,6 +70,7 @@ impl Default for RelayStateSproofBuilder {
hrmp_channels: BTreeMap::new(),
current_slot: 0.into(),
current_epoch: 0u64,
randomness: relay_chain::Hash::default(),
}
}
}
@@ -156,6 +158,10 @@ impl RelayStateSproofBuilder {
insert(relay_chain::well_known_keys::hrmp_channels(channel), metadata.encode());
}
insert(relay_chain::well_known_keys::EPOCH_INDEX.to_vec(), self.current_epoch.encode());
insert(
relay_chain::well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec(),
self.randomness.encode(),
);
insert(relay_chain::well_known_keys::CURRENT_SLOT.to_vec(), self.current_slot.encode());
}