mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 03:09:56 +00:00
tests updated and small tweaks of the lib
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
@@ -11,13 +11,16 @@ use pallet_session::historical as pallet_session_historical;
|
||||
use sp_runtime::{
|
||||
testing::{TestXt, UintAuthorityId},
|
||||
traits::ConvertInto,
|
||||
BuildStorage, Permill,
|
||||
Permill,
|
||||
};
|
||||
use sp_staking::{
|
||||
offence::{OffenceError, ReportOffence},
|
||||
SessionIndex,
|
||||
};
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use sp_runtime::BuildStorage;
|
||||
|
||||
use crate as slow_clap;
|
||||
use crate::Config;
|
||||
|
||||
@@ -84,24 +87,22 @@ impl ReportOffence<u64, IdentificationTuple, Offence> for OffenceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alice_account_id() -> <Runtime as frame_system::Config>::AccountId { 69 }
|
||||
pub fn eve_account_id() -> <Runtime as frame_system::Config>::AccountId { 1337 }
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::<Runtime>::default()
|
||||
let t = frame_system::GenesisConfig::<Runtime>::default()
|
||||
.build_storage()
|
||||
.unwrap();
|
||||
|
||||
pallet_balances::GenesisConfig::<Runtime> {
|
||||
balances: vec![ (alice_account_id(), 100) ],
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
let mut result = sp_io::TestExternalities::new(t);
|
||||
|
||||
result.execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
for i in 1..=3 {
|
||||
System::inc_providers(&i);
|
||||
assert_eq!(Session::set_keys(
|
||||
RuntimeOrigin::signed(i),
|
||||
i.into(),
|
||||
vec![],
|
||||
), Ok(()));
|
||||
}
|
||||
});
|
||||
|
||||
result
|
||||
@@ -167,6 +168,7 @@ impl frame_support::traits::EstimateNextSessionRotation<u64> for TestNextSession
|
||||
|
||||
impl ghost_networks::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type NetworkId = u32;
|
||||
type RegisterOrigin = EnsureRoot<Self::AccountId>;
|
||||
type UpdateOrigin = EnsureRoot<Self::AccountId>;
|
||||
@@ -199,23 +201,15 @@ impl Config for Runtime {
|
||||
type ReportUnresponsiveness = OffenceHandler;
|
||||
|
||||
type MaxAuthorities = ConstU32<5>;
|
||||
type MaxNumberOfClaps = ConstU32<100>;
|
||||
type ApplauseThreshold = ConstU32<0>;
|
||||
type MaxAuthorityInfoInSession = ConstU32<5_000>;
|
||||
type OffenceThreshold = ConstU32<40>;
|
||||
type ApplauseThreshold = ConstU32<50>;
|
||||
type OffenceThreshold = ConstU32<75>;
|
||||
type UnsignedPriority = ConstU64<{ 1 << 20 }>;
|
||||
type TreasuryPalletId = TreasuryPalletId;
|
||||
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
pub type Extrinsic = TestXt<RuntimeCall, ()>;
|
||||
|
||||
// impl frame_system::offchain::SigningTypes for Runtime {
|
||||
// type Public = <Signature as Verify>::Signer;
|
||||
// type Signature = Signature;
|
||||
// }
|
||||
|
||||
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime
|
||||
where
|
||||
RuntimeCall: From<LocalCall>,
|
||||
@@ -224,30 +218,16 @@ where
|
||||
type Extrinsic = Extrinsic;
|
||||
}
|
||||
|
||||
// impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
|
||||
// where
|
||||
// RuntimeCall: From<LocalCall>,
|
||||
// {
|
||||
// fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
// call: Self::OverarchingCall,
|
||||
// _public: Self::Public,
|
||||
// _account: Self::AccountId,
|
||||
// nonce: Self::Nonce,
|
||||
// ) -> Option<(RuntimeCall, <Extrinsic as ExtrinsicT>::SignaturePayload)> {
|
||||
// Some((call, (nonce.into(), ())))
|
||||
// }
|
||||
// }
|
||||
pub fn advance_session() {
|
||||
let now = System::block_number().max(1);
|
||||
System::set_block_number(now + 1);
|
||||
Session::rotate_session();
|
||||
|
||||
// pub fn advance_session() {
|
||||
// let now = System::block_number().max(1);
|
||||
// System::set_block_number(now + 1);
|
||||
// Session::rotate_session();
|
||||
//
|
||||
// let authorities = Session::validators()
|
||||
// .into_iter()
|
||||
// .map(UintAuthorityId)
|
||||
// .collect();
|
||||
//
|
||||
// SlowClap::set_authorities(authorities);
|
||||
// assert_eq!(Session::current_index(), (now / Period::get()) as u32);
|
||||
// }
|
||||
let authorities = Session::validators()
|
||||
.into_iter()
|
||||
.map(UintAuthorityId)
|
||||
.collect();
|
||||
|
||||
SlowClap::set_test_authorities(authorities);
|
||||
assert_eq!(Session::current_index(), (now / Period::get()) as u32);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user