Allow council to slash treasury tip (#7753)

* wk2051 | D4 |Allow council to slash treasury tip | p1

* Update frame/tips/src/lib.rs

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* wk2051 | D5 |Allow council to slash treasury tip | p2

* wk2051 | D5 |Allow council to slash treasury tip | p3

* wk2051 | D5 |Allow council to slash treasury tip | p4

* wk2051 | D5 |Allow council to slash treasury tip | p5

* random change

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_tips --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/tips/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fix typo

* Update frame/tips/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/tips/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/tips/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/tips/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/tips/src/tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* wk2052 | D1 | Allow council to slash treasury tip | p6

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
RK
2020-12-30 00:07:19 +05:30
committed by GitHub
parent 8c795accc8
commit acf9d2145d
7 changed files with 133 additions and 63 deletions
+34 -4
View File
@@ -286,6 +286,40 @@ fn close_tip_works() {
});
}
#[test]
fn slash_tip_works() {
new_test_ext().execute_with(|| {
System::set_block_number(1);
Balances::make_free_balance_be(&Treasury::account_id(), 101);
assert_eq!(Treasury::pot(), 100);
assert_eq!(Balances::reserved_balance(0), 0);
assert_eq!(Balances::free_balance(0), 100);
assert_ok!(TipsModTestInst::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
assert_eq!(Balances::reserved_balance(0), 12);
assert_eq!(Balances::free_balance(0), 88);
let h = tip_hash();
assert_eq!(last_event(), RawEvent::NewTip(h));
// can't remove from any origin
assert_noop!(
TipsModTestInst::slash_tip(Origin::signed(0), h.clone()),
BadOrigin,
);
// can remove from root.
assert_ok!(TipsModTestInst::slash_tip(Origin::root(), h.clone()));
assert_eq!(last_event(), RawEvent::TipSlashed(h, 0, 12));
// tipper slashed
assert_eq!(Balances::reserved_balance(0), 0);
assert_eq!(Balances::free_balance(0), 88);
});
}
#[test]
fn retract_tip_works() {
new_test_ext().execute_with(|| {
@@ -409,12 +443,8 @@ fn test_last_reward_migration() {
s.top = data.into_iter().collect();
println!("Executing the test!");
sp_io::TestExternalities::new(s).execute_with(|| {
println!("Calling migrate_retract_tip_for_tip_new()!");
TipsModTestInst::migrate_retract_tip_for_tip_new();
// Test w/ finder