Skip to content
Snippets Groups Projects
Commit c3ef81ab authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Make sure we generate a valid slot in tests (#2520)

Currently the first last timestamp is `0` and that leads to the first
slot being `0` which is reserved for genesis. There is some debug assert
in BABE that complains about this in Cumulus :D
parent 5ffb8cb4
Branches
No related merge requests found
......@@ -62,7 +62,13 @@ impl InitPolkadotBlockBuilder for Client {
let minimum_period = BasicExternalities::new_empty()
.execute_with(|| polkadot_test_runtime::MinimumPeriod::get());
let timestamp = last_timestamp + minimum_period;
let timestamp = if last_timestamp == 0 {
std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH)
.expect("Time is always after UNIX_EPOCH; qed")
.as_millis() as u64
} else {
last_timestamp + minimum_period
};
// `SlotDuration` is a storage parameter type that requires externalities to access the value.
let slot_duration = BasicExternalities::new_empty()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment