mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
introduce remote-tests for pallet-bags-list (#10036)
* make a few primitives in bags-list public * push new stuff * update * update log target * bring remote tests here * revert pub * Update frame/bags-list/remote-tests/Cargo.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * some rev commnets * Fix * cleanup * Update Cargo.lock Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -65,12 +65,10 @@ pub mod mock;
|
||||
mod tests;
|
||||
pub mod weights;
|
||||
|
||||
pub use list::{notional_bag_for, Bag, Error, List, Node};
|
||||
pub use pallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
pub use list::Error;
|
||||
use list::List;
|
||||
|
||||
pub(crate) const LOG_TARGET: &'static str = "runtime::bags_list";
|
||||
|
||||
// syntactic sugar for logging.
|
||||
@@ -155,7 +153,7 @@ pub mod pallet {
|
||||
|
||||
/// How many ids are registered.
|
||||
// NOTE: This is merely a counter for `ListNodes`. It should someday be replaced by the
|
||||
// `CountedMaop` storage.
|
||||
// `CountedMap` storage.
|
||||
#[pallet::storage]
|
||||
pub(crate) type CounterForListNodes<T> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ mod tests;
|
||||
///
|
||||
/// Note that even if the thresholds list does not have `VoteWeight::MAX` as its final member, this
|
||||
/// function behaves as if it does.
|
||||
pub(crate) fn notional_bag_for<T: Config>(weight: VoteWeight) -> VoteWeight {
|
||||
pub fn notional_bag_for<T: Config>(weight: VoteWeight) -> VoteWeight {
|
||||
let thresholds = T::BagThresholds::get();
|
||||
let idx = thresholds.partition_point(|&threshold| weight > threshold);
|
||||
thresholds.get(idx).copied().unwrap_or(VoteWeight::MAX)
|
||||
@@ -690,7 +690,7 @@ pub struct Node<T: Config> {
|
||||
|
||||
impl<T: Config> Node<T> {
|
||||
/// Get a node by id.
|
||||
pub(crate) fn get(id: &T::AccountId) -> Option<Node<T>> {
|
||||
pub fn get(id: &T::AccountId) -> Option<Node<T>> {
|
||||
crate::ListNodes::<T>::try_get(id).ok()
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ impl<T: Config> Node<T> {
|
||||
}
|
||||
|
||||
/// `true` when this voter is in the wrong bag.
|
||||
pub(crate) fn is_misplaced(&self, current_weight: VoteWeight) -> bool {
|
||||
pub fn is_misplaced(&self, current_weight: VoteWeight) -> bool {
|
||||
notional_bag_for::<T>(current_weight) != self.bag_upper
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user