Skip to content

Commit f2bb38a

Browse files
committed
fix propogation tests
1 parent 01d9fcc commit f2bb38a

File tree

6 files changed

+53
-56
lines changed

6 files changed

+53
-56
lines changed

cliff.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ footer="""
5252
"""
5353
# postprocessors
5454
postprocessors=[
55-
{ pattern='<REPO>', replace="https://github.com/orhun/git-cliff" }, # replace repository URL
55+
{ pattern='<REPO>', replace="https://github.com/entropy/entropy-core" }, # replace repository URL
5656
]
5757

5858
[git]

node/cli/src/service.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use sc_offchain::OffchainDb;
3939
use sc_service::{config::Configuration, error::Error as ServiceError, RpcHandlers, TaskManager};
4040
use sc_statement_store::Store as StatementStore;
4141
use sc_telemetry::{Telemetry, TelemetryWorker};
42-
use sp_api::{offchain::DbExternalities, ProvideRuntimeApi};
4342
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
43+
use sp_api::{offchain::DbExternalities, ProvideRuntimeApi};
4444
use sp_core::crypto::Pair;
4545
use sp_runtime::{generic, traits::Block as BlockT, SaturatedConversion};
4646

@@ -389,24 +389,24 @@ pub fn new_full_base(
389389
if config.offchain_worker.enabled {
390390
use futures::FutureExt;
391391

392-
task_manager.spawn_handle().spawn(
393-
"offchain-workers-runner",
394-
"offchain-work",
395-
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
396-
runtime_api_provider: client.clone(),
397-
keystore: Some(keystore_container.keystore()),
398-
offchain_db: backend.offchain_storage(),
399-
transaction_pool: Some(OffchainTransactionPoolFactory::new(
400-
transaction_pool.clone(),
401-
)),
402-
network_provider: network.clone(),
403-
is_validator: config.role.is_authority(),
404-
enable_http_requests: true,
405-
custom_extensions: move |_| vec![],
406-
})
407-
.run(client.clone(), task_manager.spawn_handle())
408-
.boxed(),
409-
);
392+
task_manager.spawn_handle().spawn(
393+
"offchain-workers-runner",
394+
"offchain-work",
395+
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
396+
runtime_api_provider: client.clone(),
397+
keystore: Some(keystore_container.keystore()),
398+
offchain_db: backend.offchain_storage(),
399+
transaction_pool: Some(OffchainTransactionPoolFactory::new(
400+
transaction_pool.clone(),
401+
)),
402+
network_provider: network.clone(),
403+
is_validator: config.role.is_authority(),
404+
enable_http_requests: true,
405+
custom_extensions: move |_| vec![],
406+
})
407+
.run(client.clone(), task_manager.spawn_handle())
408+
.boxed(),
409+
);
410410
if let Some(endpoint) = tss_server_endpoint {
411411
let mut offchain_db = OffchainDb::new(
412412
backend.offchain_storage().expect("failed getting offchain storage"),

pallets/constraints/src/mock.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use frame_support::parameter_types;
22
use frame_system as system;
33
use sp_core::H256;
44
use sp_runtime::{
5-
traits::{BlakeTwo256, IdentityLookup}, BuildStorage
5+
traits::{BlakeTwo256, IdentityLookup},
6+
BuildStorage,
67
};
78

89
use crate as pallet_constraints;
@@ -28,16 +29,16 @@ impl system::Config for Test {
2829
type AccountData = pallet_balances::AccountData<u64>;
2930
type AccountId = u64;
3031
type BaseCallFilter = frame_support::traits::Everything;
32+
type Block = Block;
3133
type BlockHashCount = BlockHashCount;
3234
type BlockLength = ();
3335
type BlockWeights = ();
34-
type Block = Block;
3536
type DbWeight = ();
36-
type Nonce = u64;
3737
type Hash = H256;
3838
type Hashing = BlakeTwo256;
3939
type Lookup = IdentityLookup<Self::AccountId>;
4040
type MaxConsumers = frame_support::traits::ConstU32<16>;
41+
type Nonce = u64;
4142
type OnKilledAccount = ();
4243
type OnNewAccount = ();
4344
type OnSetCode = ();
@@ -69,9 +70,9 @@ impl pallet_balances::Config for Test {
6970
type MaxHolds = ();
7071
type MaxLocks = ();
7172
type MaxReserves = ();
72-
type RuntimeHoldReason = RuntimeHoldReason;
7373
type ReserveIdentifier = [u8; 8];
7474
type RuntimeEvent = RuntimeEvent;
75+
type RuntimeHoldReason = RuntimeHoldReason;
7576
type WeightInfo = ();
7677
}
7778

pallets/free-tx/src/mock.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use sp_runtime::{
1414
curve::PiecewiseLinear,
1515
testing::{TestXt, UintAuthorityId},
1616
traits::{BlakeTwo256, ConvertInto, IdentityLookup, Zero},
17-
Perbill, BuildStorage
17+
BuildStorage, Perbill,
1818
};
1919
use sp_staking::{EraIndex, SessionIndex};
2020
use sp_std::collections::btree_map::BTreeMap;
@@ -54,16 +54,16 @@ impl system::Config for Test {
5454
type AccountData = pallet_balances::AccountData<u64>;
5555
type AccountId = u64;
5656
type BaseCallFilter = frame_support::traits::Everything;
57+
type Block = Block;
5758
type BlockHashCount = BlockHashCount;
5859
type BlockLength = ();
5960
type BlockWeights = ();
60-
type Block = Block;
6161
type DbWeight = ();
62-
type Nonce = u64;
6362
type Hash = H256;
6463
type Hashing = BlakeTwo256;
6564
type Lookup = IdentityLookup<Self::AccountId>;
6665
type MaxConsumers = frame_support::traits::ConstU32<16>;
66+
type Nonce = u64;
6767
type OnKilledAccount = ();
6868
type OnNewAccount = ();
6969
type OnSetCode = ();
@@ -101,9 +101,9 @@ impl pallet_balances::Config for Test {
101101
type MaxHolds = ();
102102
type MaxLocks = ();
103103
type MaxReserves = ();
104-
type RuntimeHoldReason = RuntimeHoldReason;
105104
type ReserveIdentifier = [u8; 8];
106105
type RuntimeEvent = RuntimeEvent;
106+
type RuntimeHoldReason = RuntimeHoldReason;
107107
type WeightInfo = ();
108108
}
109109

@@ -220,6 +220,7 @@ impl pallet_staking::Config for Test {
220220
type CurrencyToVote = ();
221221
type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
222222
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
223+
type EventListeners = ();
223224
type GenesisElectionProvider = Self::ElectionProvider;
224225
type HistoryDepth = ConstU32<84>;
225226
type MaxNominations = MaxNominations;
@@ -236,7 +237,6 @@ impl pallet_staking::Config for Test {
236237
type SlashDeferDuration = SlashDeferDuration;
237238
type TargetList = pallet_staking::UseValidatorsMap<Self>;
238239
type UnixTime = pallet_timestamp::Pallet<Test>;
239-
type EventListeners = ();
240240
type VoterList = BagsList;
241241
type WeightInfo = ();
242242
}

pallets/propagation/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ std=[
8383
'pallet-constraints/std',
8484
'pallet-balances/std',
8585
'pallet-babe/std',
86+
'pallet-relayer/std',
8687
"sp-io/std",
8788
"sp-runtime/std",
8889
"sp-npos-elections/std",

pallets/propagation/src/mock.rs

+22-27
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
11
use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight};
22
use frame_support::{
33
parameter_types,
4-
traits::{ConstU32, FindAuthor, GenesisBuild, OneSessionHandler},
4+
traits::{ConstU32, FindAuthor, OneSessionHandler},
55
};
66
use frame_system as system;
77
use pallet_session::historical as pallet_session_historical;
88
use pallet_staking_extension::ServerInfo;
99
use sp_core::H256;
1010
use sp_runtime::{
1111
curve::PiecewiseLinear,
12-
testing::{Header, TestXt, UintAuthorityId},
12+
testing::{TestXt, UintAuthorityId},
1313
traits::{BlakeTwo256, ConvertInto, IdentityLookup},
14-
Perbill,
14+
BuildStorage, Perbill,
1515
};
1616
use sp_staking::{EraIndex, SessionIndex};
1717

1818
use crate as pallet_propagation;
1919

2020
const NULL_ARR: [u8; 32] = [0; 32];
2121

22-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
2322
type Block = frame_system::mocking::MockBlock<Test>;
2423
type BlockNumber = u64;
2524
type AccountId = u64;
2625
type Balance = u64;
2726

2827
// Configure a mock runtime to test the pallet.
2928
frame_support::construct_runtime!(
30-
pub enum Test where
31-
Block = Block,
32-
NodeBlock = Block,
33-
UncheckedExtrinsic = UncheckedExtrinsic,
29+
pub enum Test
3430
{
35-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
36-
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
37-
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
38-
Authorship: pallet_authorship::{Pallet, Storage},
39-
Relayer: pallet_relayer::{Pallet, Call, Storage, Event<T>},
40-
Constraints: pallet_constraints::{Pallet, Call, Storage, Event<T>},
41-
Propagation: pallet_propagation::{Pallet, Call, Storage, Event<T>},
42-
Staking: pallet_staking_extension::{Pallet, Call, Storage, Event<T>, Config<T>},
43-
FrameStaking: pallet_staking::{Pallet, Call, Storage, Event<T>},
44-
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
45-
Historical: pallet_session_historical::{Pallet},
46-
BagsList: pallet_bags_list::{Pallet, Call, Storage, Event<T>},
31+
System: frame_system,
32+
Balances: pallet_balances,
33+
Timestamp: pallet_timestamp,
34+
Authorship: pallet_authorship,
35+
Relayer: pallet_relayer,
36+
Constraints: pallet_constraints,
37+
Propagation: pallet_propagation,
38+
Staking: pallet_staking_extension,
39+
FrameStaking: pallet_staking,
40+
Session: pallet_session,
41+
Historical: pallet_session_historical,
42+
BagsList: pallet_bags_list,
4743
}
4844
);
4945

@@ -56,17 +52,16 @@ impl system::Config for Test {
5652
type AccountData = pallet_balances::AccountData<Balance>;
5753
type AccountId = u64;
5854
type BaseCallFilter = frame_support::traits::Everything;
55+
type Block = Block;
5956
type BlockHashCount = BlockHashCount;
6057
type BlockLength = ();
61-
type BlockNumber = u64;
6258
type BlockWeights = ();
6359
type DbWeight = ();
6460
type Hash = H256;
6561
type Hashing = BlakeTwo256;
66-
type Header = Header;
67-
type Index = u64;
6862
type Lookup = IdentityLookup<Self::AccountId>;
6963
type MaxConsumers = frame_support::traits::ConstU32<16>;
64+
type Nonce = u64;
7065
type OnKilledAccount = ();
7166
type OnNewAccount = ();
7267
type OnSetCode = ();
@@ -100,13 +95,13 @@ impl pallet_balances::Config for Test {
10095
type DustRemoval = ();
10196
type ExistentialDeposit = ExistentialDeposit;
10297
type FreezeIdentifier = ();
103-
type HoldIdentifier = ();
10498
type MaxFreezes = ();
10599
type MaxHolds = ();
106100
type MaxLocks = MaxLocks;
107101
type MaxReserves = ();
108102
type ReserveIdentifier = [u8; 8];
109103
type RuntimeEvent = RuntimeEvent;
104+
type RuntimeHoldReason = RuntimeHoldReason;
110105
type WeightInfo = ();
111106
}
112107

@@ -220,17 +215,17 @@ impl pallet_staking::Config for Test {
220215
type BondingDuration = BondingDuration;
221216
type Currency = Balances;
222217
type CurrencyBalance = Balance;
223-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
218+
type CurrencyToVote = ();
224219
type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
225220
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
221+
type EventListeners = ();
226222
type GenesisElectionProvider = Self::ElectionProvider;
227223
type HistoryDepth = ConstU32<84>;
228224
type MaxNominations = MaxNominations;
229225
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
230226
type MaxUnlockingChunks = ConstU32<32>;
231227
type NextNewSession = Session;
232228
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
233-
type OnStakerSlash = ();
234229
type Reward = ();
235230
type RewardRemainder = ();
236231
type RuntimeEvent = RuntimeEvent;
@@ -320,7 +315,7 @@ impl pallet_propagation::Config for Test {
320315

321316
// Build genesis storage according to the mock runtime.
322317
pub fn new_test_ext() -> sp_io::TestExternalities {
323-
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
318+
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap();
324319
let pallet_staking_extension = pallet_staking_extension::GenesisConfig::<Test> {
325320
threshold_servers: vec![
326321
(5, ServerInfo { tss_account: 7, x25519_public_key: NULL_ARR, endpoint: vec![20] }),

0 commit comments

Comments
 (0)