diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index ff781660417c9c178cdbee5e5889d584a87f9268..d858edb07ac5e88caa77310ab6f76c30b95686a3 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -62,7 +62,7 @@ pub mod pallet { + pallet_authorship::Config // + pallet_certification::Config<I, IdtyIndex = IdtyIndex> + pallet_identity::Config<IdtyIndex = IdtyIndex> - // + pallet_session::Config + + pallet_session::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From<Event<Self, I>> diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index a6c3209d759f1bf3a6382b24748406be3cead8e8..456d6b29c6a33b0977af993f5a7086142bbcd484 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -22,7 +22,7 @@ use frame_support::{ use frame_system as system; use pallet_session::{ShouldEndSession, TestSessionHandler}; use sp_core::{ConstU32, H256}; -use sp_runtime::testing::UintAuthorityId; +use sp_runtime::testing::{TestSignature, UintAuthorityId}; use sp_runtime::traits::{ConvertInto, IdentifyAccount, IsMember, Verify}; use sp_runtime::{ impl_opaque_keys, @@ -38,9 +38,9 @@ pub type IdtyIndex = u64; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; pub type Signature = MultiSignature; pub type AccountPublic = <Signature as Verify>::Signer; -pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId; +// pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId; -// type AccountId = u64; +type AccountId = u64; // type Block = frame_system::mocking::MockBlock<Test>; // type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; @@ -52,12 +52,12 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, - // Session: pallet_session::{Pallet, Call, Storage, Config<T>, Event}, + Session: pallet_session::{Pallet, Call, Storage, Config<T>, Event}, Authorship: pallet_authorship::{Pallet, Call, Storage}, Distance: pallet_distance::{Pallet, Call, Config<T>, Storage, Event<T>}, Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>}, // Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>}, - // AuthorityMembers: pallet_authority_members::{Pallet, Call, Storage, Config<T>, Event<T>}, + AuthorityMembers: pallet_authority_members::{Pallet, Call, Storage, Config<T>, Event<T>}, } ); @@ -77,7 +77,7 @@ impl system::Config for Test { type BlockNumber = BlockNumber; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; + type AccountId = u64; type Lookup = IdentityLookup<Self::AccountId>; type Header = Header; type RuntimeEvent = RuntimeEvent; @@ -137,17 +137,17 @@ impl ShouldEndSession<u64> for TestShouldEndSession { } } -// impl pallet_session::Config for Test { -// type RuntimeEvent = RuntimeEvent; -// type ValidatorId = u64; -// type ValidatorIdOf = ConvertInto; -// type ShouldEndSession = TestShouldEndSession; -// type NextSessionRotation = (); -// type SessionManager = AuthorityMembers; -// type SessionHandler = TestSessionHandler; -// type Keys = MockSessionKeys; -// type WeightInfo = (); -// } +impl pallet_session::Config for Test { + type RuntimeEvent = RuntimeEvent; + type ValidatorId = u64; + type ValidatorIdOf = ConvertInto; + type ShouldEndSession = TestShouldEndSession; + type NextSessionRotation = (); + type SessionManager = AuthorityMembers; + type SessionHandler = TestSessionHandler; + type Keys = MockSessionKeys; + type WeightInfo = (); +} parameter_types! { pub const ChangeOwnerKeyPeriod: u64 = 10; @@ -172,12 +172,12 @@ impl pallet_identity::Config for Test { type IdtyData = (); type IdtyNameValidator = IdtyNameValidatorTestImpl; type IdtyIndex = u64; - type NewOwnerKeySigner = AccountPublic; - type NewOwnerKeySignature = Signature; + type NewOwnerKeySigner = UintAuthorityId; + type NewOwnerKeySignature = TestSignature; type OnIdtyChange = (); type RemoveIdentityConsumers = (); - type RevocationSigner = AccountPublic; - type RevocationSignature = Signature; + type RevocationSigner = UintAuthorityId; + type RevocationSignature = TestSignature; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } @@ -217,20 +217,20 @@ impl IsMember<u64> for TestIsSmithMember { } } -// impl pallet_authority_members::Config for Test { -// type KeysWrapper = MockSessionKeys; -// type IsMember = TestIsSmithMember; -// type MaxAuthorities = ConstU32<4>; -// type MaxKeysLife = ConstU32<5>; -// type MaxOfflineSessions = ConstU32<2>; -// type MemberId = u64; -// type MemberIdOf = ConvertInto; -// type OnNewSession = (); -// type OnRemovedMember = (); -// type RemoveMemberOrigin = system::EnsureRoot<u64>; -// type RuntimeEvent = RuntimeEvent; -// type WeightInfo = (); -// } +impl pallet_authority_members::Config for Test { + type KeysWrapper = MockSessionKeys; + type IsMember = TestIsSmithMember; + type MaxAuthorities = ConstU32<4>; + type MaxKeysLife = ConstU32<5>; + type MaxOfflineSessions = ConstU32<2>; + type MemberId = u64; + type MemberIdOf = ConvertInto; + type OnNewSession = (); + type OnRemovedMember = (); + type RemoveMemberOrigin = system::EnsureRoot<u64>; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} pub struct FullIdentificationOfImpl; impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOfImpl { @@ -238,20 +238,20 @@ impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf Some(()) } } -// impl pallet_session::historical::Config for Test { -// type FullIdentification = (); -// type FullIdentificationOf = FullIdentificationOfImpl; -// } +impl pallet_session::historical::Config for Test { + type FullIdentification = (); + type FullIdentificationOf = FullIdentificationOfImpl; +} // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig { system: SystemConfig::default(), - // authority_members: pallet_authority_members::GenesisConfig::default(), + authority_members: pallet_authority_members::GenesisConfig::default(), // cert: pallet_certification::GenesisConfig::default(), distance: pallet_distance::GenesisConfig::default(), identity: pallet_identity::GenesisConfig::default(), - // session: pallet_session::GenesisConfig::default(), + session: pallet_session::GenesisConfig::default(), } .build_storage() .unwrap() diff --git a/pallets/distance/src/tests.rs b/pallets/distance/src/tests.rs index 5f1410151dd27966e49d91f7177284ac76f9d44b..e940820d2c85dca3b24001b23bbac14c71b9b641 100644 --- a/pallets/distance/src/tests.rs +++ b/pallets/distance/src/tests.rs @@ -19,7 +19,7 @@ use frame_support::{assert_noop, assert_ok}; use sp_std::collections::btree_map::BTreeMap; #[test] -fn test_must_receive_cert_before_can_issue() { +fn test_compilation() { new_test_ext().execute_with(|| { assert_eq!(true, true); // assert_eq!(