Skip to content

Commit 8eb3efc

Browse files
committed
fix use of treasury in tests using TenToFourteen
1 parent 3010a34 commit 8eb3efc

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

runtime/tests/cli_integration_tests_mining_tokens.rs

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,26 @@ mod tests {
1717
assert_ok,
1818
impl_outer_origin,
1919
parameter_types,
20-
traits::EnsureOrigin,
20+
traits::{
21+
Contains,
22+
ContainsLengthBound,
23+
EnsureOrigin,
24+
},
2125
weights::{
2226
IdentityFee,
2327
Weight,
2428
},
2529
};
2630
use frame_system::EnsureRoot;
2731

32+
use std::cell::RefCell;
33+
use sp_core::{
34+
u32_trait::{
35+
_2,
36+
_3,
37+
_4,
38+
},
39+
};
2840
use sp_core::H256;
2941
use sp_runtime::{
3042
testing::Header,
@@ -82,6 +94,12 @@ mod tests {
8294
Trait as MiningSamplingTokenTrait,
8395
};
8496
use roaming_operators;
97+
use datahighway_runtime::{
98+
AccountId,
99+
Balance,
100+
BlockNumber,
101+
DAYS,
102+
};
85103

86104
// pub fn origin_of(who: &AccountId) -> <Runtime as frame_system::Trait>::Origin {
87105
// <Runtime as frame_system::Trait>::Origin::signed((*who).clone())
@@ -139,22 +157,50 @@ mod tests {
139157
type MaxLocks = ();
140158
type WeightInfo = ();
141159
}
142-
type BlockNumber = u32;
143160
impl pallet_transaction_payment::Trait for Test {
144161
type Currency = Balances;
145162
type FeeMultiplierUpdate = ();
146163
type OnTransactionPayment = ();
147164
type TransactionByteFee = ();
148165
type WeightToFee = IdentityFee<u64>;
149166
}
167+
168+
thread_local! {
169+
static TEN_TO_FOURTEEN: RefCell<Vec<u64>> = RefCell::new(vec![10,11,12,13,14]);
170+
}
171+
pub struct TenToFourteen;
172+
impl Contains<u64> for TenToFourteen {
173+
fn sorted_members() -> Vec<u64> {
174+
TEN_TO_FOURTEEN.with(|v| v.borrow().clone())
175+
}
176+
177+
#[cfg(feature = "runtime-benchmarks")]
178+
fn add(new: &u64) {
179+
TEN_TO_FOURTEEN.with(|v| {
180+
let mut members = v.borrow_mut();
181+
members.push(*new);
182+
members.sort();
183+
})
184+
}
185+
}
186+
impl ContainsLengthBound for TenToFourteen {
187+
fn max_len() -> usize {
188+
TEN_TO_FOURTEEN.with(|v| v.borrow().len())
189+
}
190+
191+
fn min_len() -> usize {
192+
0
193+
}
194+
}
195+
150196
parameter_types! {
151197
pub const ProposalBond: Permill = Permill::from_percent(5);
152-
pub const ProposalBondMinimum: BlockNumber = 1_000_000_000_000_000_000;
153-
pub const SpendPeriod: BlockNumber = 1;
198+
pub const ProposalBondMinimum: u64 = 1_000_000_000_000_000_000;
199+
pub const SpendPeriod: BlockNumber = 1 * DAYS;
154200
pub const Burn: Permill = Permill::from_percent(0);
155201
pub const TipCountdown: BlockNumber = 1;
156202
pub const TipFindersFee: Percent = Percent::from_percent(20);
157-
pub const TipReportDepositBase: u32 = 1_000_000_000_000_000_000;
203+
pub const TipReportDepositBase: u64 = 1_000_000_000_000_000_000;
158204
pub const MaximumReasonLength: u32 = 16384;
159205
pub const BountyValueMinimum: u64 = 1;
160206
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
@@ -183,15 +229,12 @@ mod tests {
183229
type OnSlash = ();
184230
type ProposalBond = ProposalBond;
185231
type ProposalBondMinimum = ProposalBondMinimum;
186-
// type RejectOrigin = pallet_collective::EnsureMembers<_2, AccountId, GeneralCouncilInstance>;
187232
type RejectOrigin = EnsureRoot<u64>;
188233
type SpendPeriod = SpendPeriod;
189234
type TipCountdown = TipCountdown;
190235
type TipFindersFee = TipFindersFee;
191236
type TipReportDepositBase = TipReportDepositBase;
192-
// FIXME - upgrade to Substrate 3 since does not use Tippers, only then
193-
// can we add tests for the eligibility/proxy code
194-
// type Tippers = GeneralCouncilProvider;
237+
type Tippers = TenToFourteen;
195238
type WeightInfo = ();
196239
}
197240
// FIXME - remove this when figure out how to use these types within mining-speed-boost runtime module itself

0 commit comments

Comments
 (0)