mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
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
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user