mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 07:01:02 +00:00
Split Indices module from Balances (#1404)
* Indices module * Remove indices stuff from balances * Rejob node, move Lookup into system. * Fix up some modules. * Fix democracy tests * Fix staking tests * Fix more tests * Final test fixes * Bump runtime versions * Assets uses compact dispatchers * Contracts module uses indexed addressing * Democracy has more compact encoding * Example now demonstrates compact eencoding * Sudo uses indexed address * Upgrade key also uses indexed lookups * Assets more compact types. * Fix test * Rebuild runtime, whitespace * Remove TOODs * Remove TODOs * Add a couple of tests back to balances. * Update lib.rs * Update lib.rs
This commit is contained in:
@@ -50,7 +50,7 @@ mod tests {
|
||||
pub use runtime_io::with_externalities;
|
||||
pub use substrate_primitives::H256;
|
||||
pub use primitives::BuildStorage;
|
||||
pub use primitives::traits::{BlakeTwo256};
|
||||
pub use primitives::traits::{BlakeTwo256, IdentityLookup};
|
||||
pub use primitives::testing::{Digest, DigestItem, Header};
|
||||
pub use substrate_primitives::{Blake2Hasher};
|
||||
pub use {seats, motions, voting};
|
||||
@@ -85,14 +85,15 @@ mod tests {
|
||||
type Hashing = BlakeTwo256;
|
||||
type Digest = Digest;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type Log = DigestItem;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type AccountIndex = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
type EnsureAccountLiquid = ();
|
||||
type Event = Event;
|
||||
}
|
||||
@@ -121,7 +122,6 @@ mod tests {
|
||||
existential_deposit: 0,
|
||||
transfer_fee: 0,
|
||||
creation_fee: 0,
|
||||
reclaim_rebate: 0,
|
||||
}.build_storage().unwrap().0);
|
||||
t.extend(democracy::GenesisConfig::<Test>{
|
||||
launch_period: 1,
|
||||
|
||||
@@ -220,7 +220,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Call {
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value.into(), 0.into()))
|
||||
Call::Balances(balances::Call::set_balance(42, value.into(), 0.into()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -237,7 +237,7 @@ mod tests {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 3))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), 3))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -290,11 +290,11 @@ mod tests {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 2))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), 2))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(1, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false, 0, 1))
|
||||
event: OuterEvent::motions(RawEvent::Voted(1, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), false, 0, 1))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -312,15 +312,15 @@ mod tests {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 3))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), 3))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false, 1, 1))
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), false, 1, 1))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Disapproved(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into()))
|
||||
event: OuterEvent::motions(RawEvent::Disapproved(hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into()))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -338,19 +338,19 @@ mod tests {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 2))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), 2))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), true, 2, 0))
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), true, 2, 0))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Approved(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into()))
|
||||
event: OuterEvent::motions(RawEvent::Approved(hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into()))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Executed(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false))
|
||||
event: OuterEvent::motions(RawEvent::Executed(hex!["cd0b662a49f004093b80600415cf4126399af0d27ed6c185abeb1469c17eb5bf"].into(), false))
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use codec::{Compact, HasCompact};
|
||||
use primitives::traits::{Zero, One, As};
|
||||
use primitives::traits::{Zero, One, As, StaticLookup};
|
||||
use runtime_io::print;
|
||||
use srml_support::{StorageValue, StorageMap, dispatch::Result};
|
||||
use democracy;
|
||||
use balances::{self, address::Address};
|
||||
use balances;
|
||||
use system::{self, ensure_signed};
|
||||
|
||||
// no polynomial attacks:
|
||||
@@ -127,14 +127,14 @@ decl_module! {
|
||||
fn reap_inactive_voter(
|
||||
origin,
|
||||
reporter_index: Compact<u32>,
|
||||
who: Address<T::AccountId, T::AccountIndex>,
|
||||
who: <T::Lookup as StaticLookup>::Source,
|
||||
who_index: Compact<u32>,
|
||||
assumed_vote_index: Compact<VoteIndex>
|
||||
) {
|
||||
let reporter = ensure_signed(origin)?;
|
||||
let assumed_vote_index: VoteIndex = assumed_vote_index.into();
|
||||
|
||||
let who = <balances::Module<T>>::lookup(who)?;
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
ensure!(!Self::presentation_active(), "cannot reap during presentation period");
|
||||
ensure!(Self::voter_last_active(&reporter).is_some(), "reporter must be a voter");
|
||||
let last_active = Self::voter_last_active(&who).ok_or("target for inactivity cleanup must be active")?;
|
||||
@@ -226,7 +226,7 @@ decl_module! {
|
||||
/// `signed` should have at least
|
||||
fn present_winner(
|
||||
origin,
|
||||
candidate: Address<T::AccountId, T::AccountIndex>,
|
||||
candidate: <T::Lookup as StaticLookup>::Source,
|
||||
total: <T::Balance as HasCompact>::Type,
|
||||
index: Compact<VoteIndex>
|
||||
) -> Result {
|
||||
@@ -235,7 +235,7 @@ decl_module! {
|
||||
ensure!(!total.is_zero(), "stake deposited to present winner and be added to leaderboard should be non-zero");
|
||||
let index: VoteIndex = index.into();
|
||||
|
||||
let candidate = <balances::Module<T>>::lookup(candidate)?;
|
||||
let candidate = T::Lookup::lookup(candidate)?;
|
||||
ensure!(index == Self::vote_index(), "index not current");
|
||||
let (_, _, expiring) = Self::next_finalise().ok_or("cannot present outside of presentation period")?;
|
||||
let stakes = Self::snapshoted_stakes();
|
||||
@@ -288,8 +288,8 @@ decl_module! {
|
||||
/// Remove a particular member. A tally will happen instantly (if not already in a presentation
|
||||
/// period) to fill the seat if removal means that the desired members are not met.
|
||||
/// This is effective immediately.
|
||||
fn remove_member(who: Address<T::AccountId, T::AccountIndex>) {
|
||||
let who = <balances::Module<T>>::lookup(who)?;
|
||||
fn remove_member(who: <T::Lookup as StaticLookup>::Source) {
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
let new_council: Vec<(T::AccountId, T::BlockNumber)> = Self::active_council()
|
||||
.into_iter()
|
||||
.filter(|i| i.0 != who)
|
||||
@@ -874,8 +874,8 @@ mod tests {
|
||||
|
||||
System::set_block_number(6);
|
||||
assert!(Council::presentation_active());
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (0, 0), (20, 2), (50, 5)]));
|
||||
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
@@ -900,7 +900,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 0.into(), 0.into()), "stake deposited to present winner and be added to leaderboard should be non-zero");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2, 0.into(), 0.into()), "stake deposited to present winner and be added to leaderboard should be non-zero");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -917,9 +917,9 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()), Err("duplicate presentation"));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()), Err("duplicate presentation"));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_eq!(Council::active_council(), vec![(5, 11), (2, 11)]);
|
||||
@@ -936,7 +936,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -945,12 +945,12 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(5),
|
||||
(Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
|
||||
@@ -970,7 +970,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -979,7 +979,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()), "candidate must not form a duplicated member if elected");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2, 20.into(), 1.into()), "candidate must not form a duplicated member if elected");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -992,7 +992,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1001,7 +1001,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(11);
|
||||
@@ -1009,7 +1009,7 @@ mod tests {
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(5),
|
||||
(Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
|
||||
@@ -1029,7 +1029,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1038,12 +1038,12 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(2),
|
||||
42.into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
), "bad reporter index");
|
||||
});
|
||||
@@ -1058,7 +1058,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1067,12 +1067,12 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(2),
|
||||
(Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into(), 42.into(),
|
||||
2, 42.into(),
|
||||
2.into()
|
||||
), "bad target index");
|
||||
});
|
||||
@@ -1093,10 +1093,10 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1104,8 +1104,8 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_eq!(Council::vote_index(), 2);
|
||||
@@ -1115,7 +1115,7 @@ mod tests {
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(4),
|
||||
(Council::voters().iter().position(|&i| i == 4).unwrap() as u32).into(),
|
||||
2.into(),
|
||||
2,
|
||||
(Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
@@ -1135,7 +1135,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1144,12 +1144,12 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(4),
|
||||
0.into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
), "reporter must be a voter");
|
||||
});
|
||||
@@ -1172,10 +1172,10 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1, 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(30, 3),
|
||||
@@ -1184,7 +1184,7 @@ mod tests {
|
||||
(60, 1)
|
||||
]));
|
||||
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()), "candidate not worthy of leaderboard");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()), "candidate not worthy of leaderboard");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1205,11 +1205,11 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2, 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1, 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(30, 3),
|
||||
@@ -1225,7 +1225,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert!(!Council::presentation_active());
|
||||
assert_noop!(Council::present_winner(Origin::signed(5), 5.into(), 1.into(), 0.into()), "cannot present outside of presentation period");
|
||||
assert_noop!(Council::present_winner(Origin::signed(5), 5, 1.into(), 0.into()), "cannot present outside of presentation period");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1240,7 +1240,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()), "index not current");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2, 20.into(), 1.into()), "index not current");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1259,7 +1259,7 @@ mod tests {
|
||||
System::set_block_number(6);
|
||||
assert_eq!(Balances::free_balance(&1), 1);
|
||||
assert_eq!(Balances::reserved_balance(&1), 9);
|
||||
assert_noop!(Council::present_winner(Origin::signed(1), 1.into(), 20.into(), 0.into()), "presenter must have sufficient slashable funds");
|
||||
assert_noop!(Council::present_winner(Origin::signed(1), 1, 20.into(), 0.into()), "presenter must have sufficient slashable funds");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1277,7 +1277,7 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_err!(Council::present_winner(Origin::signed(4), 2.into(), 80.into(), 0.into()), "incorrect total");
|
||||
assert_err!(Council::present_winner(Origin::signed(4), 2, 80.into(), 0.into()), "incorrect total");
|
||||
|
||||
assert_eq!(Balances::total_balance(&4), 38);
|
||||
});
|
||||
@@ -1304,7 +1304,7 @@ mod tests {
|
||||
|
||||
System::set_block_number(6);
|
||||
assert!(Council::presentation_active());
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1, 60.into(), 0.into()));
|
||||
// leaderboard length is the empty seats plus the carry count (i.e. 5 + 2), where those
|
||||
// to be carried are the lowest and stored in lowest indexes
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
@@ -1313,9 +1313,9 @@ mod tests {
|
||||
(0, 0),
|
||||
(60, 1)
|
||||
]));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(30, 3),
|
||||
(40, 4),
|
||||
@@ -1361,10 +1361,10 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1, 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5, 50.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
@@ -1373,8 +1373,8 @@ mod tests {
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 90.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3, 90.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4, 40.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert!(!Council::presentation_active());
|
||||
|
||||
@@ -259,7 +259,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Call {
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value.into(), 0.into()))
|
||||
Call::Balances(balances::Call::set_balance(42, value.into(), 0.into()))
|
||||
}
|
||||
|
||||
fn cancel_referendum_proposal(id: u32) -> Call {
|
||||
|
||||
Reference in New Issue
Block a user