Skip to content
Snippets Groups Projects
Unverified Commit ab2d22a9 authored by bgallois's avatar bgallois
Browse files

wip: fix all pallets tests

parent d5cbe5f5
No related branches found
No related tags found
No related merge requests found
Pipeline #35450 failed
This commit is part of merge request !229. Comments created here will be created in the context of that merge request.
...@@ -6234,6 +6234,7 @@ dependencies = [ ...@@ -6234,6 +6234,7 @@ dependencies = [
"sp-membership", "sp-membership",
"sp-runtime 24.0.0", "sp-runtime 24.0.0",
"sp-staking", "sp-staking",
"sp-state-machine 0.28.0",
"sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)", "sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)",
] ]
...@@ -6418,6 +6419,7 @@ dependencies = [ ...@@ -6418,6 +6419,7 @@ dependencies = [
"sp-io 23.0.0", "sp-io 23.0.0",
"sp-membership", "sp-membership",
"sp-runtime 24.0.0", "sp-runtime 24.0.0",
"sp-state-machine 0.28.0",
"sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)", "sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)",
] ]
...@@ -6459,6 +6461,7 @@ dependencies = [ ...@@ -6459,6 +6461,7 @@ dependencies = [
"sp-io 23.0.0", "sp-io 23.0.0",
"sp-keystore 0.27.0", "sp-keystore 0.27.0",
"sp-runtime 24.0.0", "sp-runtime 24.0.0",
"sp-state-machine 0.28.0",
"sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)", "sp-std 8.0.0 (git+https://github.com/bgallois/duniter-polkadot-sdk?branch=duniter-v1.6.0)",
] ]
......
...@@ -109,3 +109,7 @@ version = '1.0.119' ...@@ -109,3 +109,7 @@ version = '1.0.119'
[dev-dependencies.sp-io] [dev-dependencies.sp-io]
git = 'https://github.com/bgallois/duniter-polkadot-sdk' git = 'https://github.com/bgallois/duniter-polkadot-sdk'
branch = 'duniter-v1.6.0' branch = 'duniter-v1.6.0'
[dev-dependencies.sp-state-machine]
git = 'https://github.com/bgallois/duniter-polkadot-sdk'
branch = 'duniter-v1.6.0'
...@@ -16,28 +16,24 @@ ...@@ -16,28 +16,24 @@
use super::*; use super::*;
use crate::{self as pallet_authority_members}; use crate::{self as pallet_authority_members};
use frame_support::{ use frame_support::{pallet_prelude::*, parameter_types, traits::Everything};
pallet_prelude::*,
parameter_types,
traits::{Everything, GenesisBuild},
BasicExternalities,
};
use frame_system as system; use frame_system as system;
use pallet_offences::traits::OnOffenceHandler; use pallet_offences::traits::OnOffenceHandler;
use pallet_offences::SlashStrategy; use pallet_offences::SlashStrategy;
use pallet_session::ShouldEndSession; use pallet_session::ShouldEndSession;
use sp_core::{crypto::key_types::DUMMY, H256}; use sp_core::{crypto::key_types::DUMMY, H256};
use sp_runtime::BuildStorage;
use sp_runtime::{ use sp_runtime::{
impl_opaque_keys, impl_opaque_keys,
testing::{Header, UintAuthorityId}, testing::UintAuthorityId,
traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys}, traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys},
KeyTypeId, KeyTypeId,
}; };
use sp_staking::offence::OffenceDetails; use sp_staking::offence::OffenceDetails;
use sp_state_machine::BasicExternalities;
type AccountId = u64; type AccountId = u64;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
impl_opaque_keys! { impl_opaque_keys! {
pub struct MockSessionKeys { pub struct MockSessionKeys {
...@@ -53,14 +49,11 @@ impl From<UintAuthorityId> for MockSessionKeys { ...@@ -53,14 +49,11 @@ impl From<UintAuthorityId> for MockSessionKeys {
// Configure a mock runtime to test the pallet. // Configure a mock runtime to test the pallet.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, System: frame_system,
Session: pallet_session::{Pallet, Call, Storage, Config<T>, Event}, Session: pallet_session,
AuthorityMembers: pallet_authority_members::{Pallet, Call, Storage, Config<T>, Event<T>}, AuthorityMembers: pallet_authority_members,
} }
); );
...@@ -73,16 +66,14 @@ impl system::Config for Test { ...@@ -73,16 +66,14 @@ impl system::Config for Test {
type BaseCallFilter = Everything; type BaseCallFilter = Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Block = Block;
type DbWeight = (); type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
...@@ -94,6 +85,8 @@ impl system::Config for Test { ...@@ -94,6 +85,8 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type Nonce = u64;
} }
pub struct TestSessionHandler; pub struct TestSessionHandler;
...@@ -172,10 +165,10 @@ pub fn new_test_ext(initial_authorities_len: u64) -> sp_io::TestExternalities { ...@@ -172,10 +165,10 @@ pub fn new_test_ext(initial_authorities_len: u64) -> sp_io::TestExternalities {
.map(|i| (i * 3, i * 3, UintAuthorityId(i * 3).into())) .map(|i| (i * 3, i * 3, UintAuthorityId(i * 3).into()))
.collect(); .collect();
let mut t = frame_system::GenesisConfig::default() let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage::<Test>() .build_storage()
.unwrap(); .unwrap();
BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::build_storage(&mut t, || {
for (ref k, ..) in &keys { for (ref k, ..) in &keys {
frame_system::Pallet::<Test>::inc_providers(k); frame_system::Pallet::<Test>::inc_providers(k);
} }
......
...@@ -22,26 +22,19 @@ use frame_support::{ ...@@ -22,26 +22,19 @@ use frame_support::{
use frame_system as system; use frame_system as system;
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
BuildStorage, BuildStorage,
}; };
type AccountId = u64; type AccountId = u64;
type BlockNumber = u64;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
pub type IdtyIndex = u64; pub type IdtyIndex = u64;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
// Configure a mock runtime to test the pallet. // Configure a mock runtime to test the pallet.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test {
Block = Block, System: frame_system,
NodeBlock = Block, DefaultCertification: pallet_certification,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
DefaultCertification: pallet_certification::{Pallet, Call, Event<T>, Storage, Config<T>},
} }
); );
...@@ -54,16 +47,14 @@ impl system::Config for Test { ...@@ -54,16 +47,14 @@ impl system::Config for Test {
type BaseCallFilter = Everything; type BaseCallFilter = Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Block = Block;
type DbWeight = (); type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
...@@ -75,6 +66,8 @@ impl system::Config for Test { ...@@ -75,6 +66,8 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type Nonce = u64;
} }
parameter_types! { parameter_types! {
...@@ -102,7 +95,7 @@ impl pallet_certification::Config for Test { ...@@ -102,7 +95,7 @@ impl pallet_certification::Config for Test {
pub fn new_test_ext( pub fn new_test_ext(
gen_conf: pallet_certification::GenesisConfig<Test>, gen_conf: pallet_certification::GenesisConfig<Test>,
) -> sp_io::TestExternalities { ) -> sp_io::TestExternalities {
GenesisConfig { RuntimeGenesisConfig {
system: SystemConfig::default(), system: SystemConfig::default(),
default_certification: gen_conf, default_certification: gen_conf,
} }
......
...@@ -19,23 +19,23 @@ use crate::{self as pallet_distance}; ...@@ -19,23 +19,23 @@ use crate::{self as pallet_distance};
use core::marker::PhantomData; use core::marker::PhantomData;
use frame_support::{ use frame_support::{
parameter_types, parameter_types,
traits::{Everything, GenesisBuild, OnFinalize, OnInitialize}, traits::{Everything, OnFinalize, OnInitialize},
}; };
use frame_system as system; use frame_system as system;
use pallet_balances::AccountData; use pallet_balances::AccountData;
use pallet_session::ShouldEndSession; use pallet_session::ShouldEndSession;
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_runtime::BuildStorage;
use sp_runtime::{ use sp_runtime::{
impl_opaque_keys, impl_opaque_keys,
key_types::DUMMY, key_types::DUMMY,
testing::{Header, TestSignature, UintAuthorityId}, testing::{TestSignature, UintAuthorityId},
traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys}, traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys},
KeyTypeId, Perbill, KeyTypeId, Perbill,
}; };
type Balance = u64; type Balance = u64;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
pub type AccountId = u64; pub type AccountId = u64;
impl_opaque_keys! { impl_opaque_keys! {
...@@ -52,18 +52,14 @@ impl From<UintAuthorityId> for MockSessionKeys { ...@@ -52,18 +52,14 @@ impl From<UintAuthorityId> for MockSessionKeys {
// Configure a mock runtime to test the pallet. // Configure a mock runtime to test the pallet.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test {
Block = Block, System: frame_system,
NodeBlock = Block, Session: pallet_session,
UncheckedExtrinsic = UncheckedExtrinsic, Authorship: pallet_authorship,
{ AuthorityMembers: pallet_authority_members,
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, Balances: pallet_balances,
Session: pallet_session::{Pallet, Call, Storage, Config<T>, Event}, Identity: pallet_identity,
Authorship: pallet_authorship::{Pallet, Storage}, Distance: pallet_distance,
AuthorityMembers: pallet_authority_members::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Identity: pallet_identity::{Pallet, Call, Storage, Config<T>, Event<T>},
Distance: pallet_distance::{Pallet, Call, Storage, Event<T>},
} }
); );
...@@ -76,16 +72,14 @@ impl system::Config for Test { ...@@ -76,16 +72,14 @@ impl system::Config for Test {
type BaseCallFilter = Everything; type BaseCallFilter = Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Block = Block;
type DbWeight = (); type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
...@@ -97,6 +91,8 @@ impl system::Config for Test { ...@@ -97,6 +91,8 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type Nonce = u64;
} }
pub struct TestSessionHandler; pub struct TestSessionHandler;
...@@ -207,10 +203,11 @@ impl pallet_balances::Config for Test { ...@@ -207,10 +203,11 @@ impl pallet_balances::Config for Test {
type MaxReserves = (); type MaxReserves = ();
type ReserveIdentifier = [u8; 8]; type ReserveIdentifier = [u8; 8];
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type HoldIdentifier = ();
type FreezeIdentifier = (); type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>; type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>; type MaxFreezes = ConstU32<0>;
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
} }
parameter_types! { parameter_types! {
...@@ -265,8 +262,8 @@ impl pallet_distance::Config for Test { ...@@ -265,8 +262,8 @@ impl pallet_distance::Config for Test {
// Build genesis storage according to the mock runtime. // Build genesis storage according to the mock runtime.
#[allow(dead_code)] // ??? Clippy triggers dead code for new_test_ext while it is used during test benchmark #[allow(dead_code)] // ??? Clippy triggers dead code for new_test_ext while it is used during test benchmark
pub fn new_test_ext() -> sp_io::TestExternalities { pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default() let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage::<Test>() .build_storage()
.unwrap(); .unwrap();
pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"]; pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"];
......
...@@ -20,6 +20,7 @@ std = [ ...@@ -20,6 +20,7 @@ std = [
'frame-system/std', 'frame-system/std',
'frame-benchmarking/std', 'frame-benchmarking/std',
'pallet-balances/std', 'pallet-balances/std',
'pallet-identity/std',
'pallet-provide-randomness/std', 'pallet-provide-randomness/std',
'pallet-treasury/std', 'pallet-treasury/std',
'serde', 'serde',
......
...@@ -101,3 +101,7 @@ version = '1.0.119' ...@@ -101,3 +101,7 @@ version = '1.0.119'
[dev-dependencies.sp-io] [dev-dependencies.sp-io]
git = 'https://github.com/bgallois/duniter-polkadot-sdk' git = 'https://github.com/bgallois/duniter-polkadot-sdk'
branch = 'duniter-v1.6.0' branch = 'duniter-v1.6.0'
[dev-dependencies.sp-state-machine]
git = 'https://github.com/bgallois/duniter-polkadot-sdk'
branch = 'duniter-v1.6.0'
...@@ -19,15 +19,16 @@ use crate::{self as pallet_duniter_wot}; ...@@ -19,15 +19,16 @@ use crate::{self as pallet_duniter_wot};
use frame_support::{parameter_types, traits::Everything}; use frame_support::{parameter_types, traits::Everything};
use frame_system as system; use frame_system as system;
use sp_core::H256; use sp_core::H256;
use sp_runtime::BuildStorage;
use sp_runtime::{ use sp_runtime::{
testing::{Header, TestSignature, UintAuthorityId}, testing::{TestSignature, UintAuthorityId},
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
}; };
use sp_state_machine::BasicExternalities;
use std::collections::BTreeMap; use std::collections::BTreeMap;
type AccountId = u64; type AccountId = u64;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
pub struct IdentityIndexOf<T: pallet_identity::Config>(PhantomData<T>); pub struct IdentityIndexOf<T: pallet_identity::Config>(PhantomData<T>);
impl<T: pallet_identity::Config> sp_runtime::traits::Convert<T::AccountId, Option<T::IdtyIndex>> impl<T: pallet_identity::Config> sp_runtime::traits::Convert<T::AccountId, Option<T::IdtyIndex>>
...@@ -40,16 +41,12 @@ impl<T: pallet_identity::Config> sp_runtime::traits::Convert<T::AccountId, Optio ...@@ -40,16 +41,12 @@ impl<T: pallet_identity::Config> sp_runtime::traits::Convert<T::AccountId, Optio
// Configure a mock runtime to test the pallet. // Configure a mock runtime to test the pallet.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test {
Block = Block, System: frame_system,
NodeBlock = Block, DuniterWot: pallet_duniter_wot,
UncheckedExtrinsic = UncheckedExtrinsic, Identity: pallet_identity,
{ Membership: pallet_membership,
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, Cert: pallet_certification,
DuniterWot: pallet_duniter_wot::{Pallet},
Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>},
Membership: pallet_membership::{Pallet, Config<T>, Storage, Event<T>},
Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>},
} }
); );
...@@ -64,15 +61,13 @@ impl system::Config for Test { ...@@ -64,15 +61,13 @@ impl system::Config for Test {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Block = Block;
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
...@@ -84,6 +79,8 @@ impl system::Config for Test { ...@@ -84,6 +79,8 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type Nonce = u64;
} }
// DuniterWot // DuniterWot
...@@ -181,8 +178,8 @@ pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie" ...@@ -181,8 +178,8 @@ pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"
// Build genesis storage according to the mock runtime. // Build genesis storage according to the mock runtime.
pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities { pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default() let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage::<Test>() .build_storage()
.unwrap(); .unwrap();
pallet_identity::GenesisConfig::<Test> { pallet_identity::GenesisConfig::<Test> {
...@@ -226,7 +223,7 @@ pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities { ...@@ -226,7 +223,7 @@ pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities {
.assimilate_storage(&mut t) .assimilate_storage(&mut t)
.unwrap(); .unwrap();
frame_support::BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::execute_with_storage(&mut t, || {
// manually increment genesis identities sufficient counter // manually increment genesis identities sufficient counter
// In real world, this is done by pallet-identity // In real world, this is done by pallet-identity
for i in 1..=initial_identities_len { for i in 1..=initial_identities_len {
......
...@@ -77,3 +77,4 @@ branch = 'duniter-v1.6.0' ...@@ -77,3 +77,4 @@ branch = 'duniter-v1.6.0'
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
sp-io = { git = 'https://github.com/bgallois/duniter-polkadot-sdk', branch = 'duniter-v1.6.0' } sp-io = { git = 'https://github.com/bgallois/duniter-polkadot-sdk', branch = 'duniter-v1.6.0' }
sp-keystore = { git = 'https://github.com/bgallois/duniter-polkadot-sdk', branch = 'duniter-v1.6.0' } sp-keystore = { git = 'https://github.com/bgallois/duniter-polkadot-sdk', branch = 'duniter-v1.6.0' }
sp-state-machine = { git = 'https://github.com/bgallois/duniter-polkadot-sdk', branch = 'duniter-v1.6.0' }
...@@ -18,20 +18,20 @@ use super::*; ...@@ -18,20 +18,20 @@ use super::*;
use crate::{self as pallet_identity}; use crate::{self as pallet_identity};
use frame_support::{ use frame_support::{
parameter_types, parameter_types,
traits::{Everything, GenesisBuild, OnFinalize, OnInitialize}, traits::{Everything, OnFinalize, OnInitialize},
}; };
use frame_system as system; use frame_system as system;
use sp_core::{Pair, H256}; use sp_core::{Pair, H256};
use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
use sp_runtime::BuildStorage;
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
MultiSignature, MultiSigner, MultiSignature, MultiSigner,
}; };
use sp_state_machine::BasicExternalities;
use std::sync::Arc; use std::sync::Arc;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
pub type Signature = MultiSignature; pub type Signature = MultiSignature;
pub type AccountPublic = <Signature as Verify>::Signer; pub type AccountPublic = <Signature as Verify>::Signer;
pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId; pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
...@@ -43,13 +43,10 @@ fn account(id: u8) -> AccountId { ...@@ -43,13 +43,10 @@ fn account(id: u8) -> AccountId {
// Configure a mock runtime to test the pallet. // Configure a mock runtime to test the pallet.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, System: frame_system,
Identity: pallet_identity::{Pallet, Call, Storage, Config<T>, Event<T>}, Identity: pallet_identity,
} }
); );
...@@ -63,15 +60,13 @@ impl system::Config for Test { ...@@ -63,15 +60,13 @@ impl system::Config for Test {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Block = Block;
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
...@@ -83,6 +78,8 @@ impl system::Config for Test { ...@@ -83,6 +78,8 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type Nonce = u64;
} }
parameter_types! { parameter_types! {
...@@ -122,13 +119,13 @@ impl pallet_identity::Config for Test { ...@@ -122,13 +119,13 @@ impl pallet_identity::Config for Test {
// Build genesis storage according to the mock runtime. // Build genesis storage according to the mock runtime.
pub fn new_test_ext(gen_conf: pallet_identity::GenesisConfig<Test>) -> sp_io::TestExternalities { pub fn new_test_ext(gen_conf: pallet_identity::GenesisConfig<Test>) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default() let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage::<Test>() .build_storage()
.unwrap(); .unwrap();
gen_conf.assimilate_storage(&mut t).unwrap(); gen_conf.assimilate_storage(&mut t).unwrap();
frame_support::BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::execute_with_storage(&mut t, || {
frame_system::Pallet::<Test>::inc_providers(&account(2)); frame_system::Pallet::<Test>::inc_providers(&account(2));
frame_system::Pallet::<Test>::inc_providers(&account(3)); frame_system::Pallet::<Test>::inc_providers(&account(3));
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment