Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
kostekIV committed Nov 2, 2022
commit c62a4f78123c32da968c2cc91a03e0d57bedb289
53 changes: 27 additions & 26 deletions aleph-client/src/elections.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use codec::Encode;
use primitives::{
BanConfig, BanInfo, CommitteeSeats, ElectionOpenness, EraIndex, EraValidators, SessionCount,
SessionIndex,
Expand Down Expand Up @@ -96,6 +95,33 @@ pub fn get_ban_reason_for_validator<C: ReadStorage>(
connection.read_storage_map(PALLET, "Banned", account_id, None)
}

pub fn ban_from_committee(
connection: &RootConnection,
to_be_banned: &AccountId,
reason: &Vec<u8>,
status: XtStatus,
) {
let call_name = "ban_from_committee";

let ban_from_committee_call = compose_call!(
connection.as_connection().metadata,
PALLET,
call_name,
to_be_banned,
reason
);

let xt = compose_extrinsic!(
connection.as_connection(),
"Sudo",
"sudo_unchecked_weight",
ban_from_committee_call,
0_u64
);

send_xt(connection, xt, Some(call_name), status);
}

pub fn change_ban_config(
sudo_connection: &RootConnection,
minimal_expected_performance: Option<u8>,
Expand Down Expand Up @@ -143,28 +169,3 @@ pub fn set_elections_openness(
);
send_xt(sudo_connection, xt, Some("set_elections_openness"), status);
}

pub fn ban_from_committee<D: Encode>(
connection: &RootConnection,
to_be_banned: &AccountId,
reason: D,
status: XtStatus,
) {
let call = compose_call!(
connection.as_connection().metadata,
PALLET,
"ban_from_committee",
to_be_banned,
reason.encode()
);

let xt = compose_extrinsic!(
connection.as_connection(),
"Sudo",
"sudo_unchecked_weight",
call,
0_u64
);

send_xt(connection, xt, Some("ban_from_committee"), status);
}
2 changes: 1 addition & 1 deletion e2e-tests/src/test/ban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn permissionless_ban(config: &Config) -> anyhow::Result<()> {
ban_from_committee(
&root_connection,
validator_to_ban,
"valid reason",
&vec![],
XtStatus::InBlock,
);
wait_for_full_era_completion(&root_connection)?;
Expand Down