mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
fix tests (#5416)
This commit is contained in:
@@ -40,6 +40,8 @@ use crate::{
|
||||
CompactAssignments, ValidatorIndex, NominatorIndex, Validators, OffchainAccuracy,
|
||||
};
|
||||
|
||||
const INIT_TIMESTAMP: u64 = 30_000;
|
||||
|
||||
/// The AccountId alias in this test module.
|
||||
pub(crate) type AccountId = u64;
|
||||
pub(crate) type AccountIndex = u64;
|
||||
@@ -482,6 +484,14 @@ impl ExtBuilder {
|
||||
let validators = Session::validators();
|
||||
SESSION.with(|x| *x.borrow_mut() = (validators.clone(), HashSet::new()));
|
||||
});
|
||||
|
||||
// We consider all test to start after timestamp is initialized
|
||||
// This must be ensured by having `timestamp::on_initialize` called before
|
||||
// `staking::on_initialize`
|
||||
ext.execute_with(|| {
|
||||
Timestamp::set_timestamp(INIT_TIMESTAMP);
|
||||
});
|
||||
|
||||
ext
|
||||
}
|
||||
}
|
||||
@@ -593,7 +603,7 @@ pub fn start_session(session_index: SessionIndex) {
|
||||
for i in Session::current_index()..session_index {
|
||||
Staking::on_finalize(System::block_number());
|
||||
System::set_block_number((i + 1).into());
|
||||
Timestamp::set_timestamp(System::block_number() * 1000);
|
||||
Timestamp::set_timestamp(System::block_number() * 1000 + INIT_TIMESTAMP);
|
||||
Session::on_initialize(System::block_number());
|
||||
Staking::on_initialize(System::block_number());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user