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:
Kian Paimani
2021-11-01 14:41:38 +00:00
committed by GitHub
parent 7f1bff9462
commit bba9cfd8a2
11 changed files with 420 additions and 15 deletions
+11 -2
View File
@@ -692,6 +692,9 @@ impl<T: Config> Pallet<T> {
// track every nominator iterated over, but not necessarily added to `all_voters`
let mut nominators_seen = 0u32;
// cache the total-issuance once in this function
let weight_of = Self::weight_of_fn();
let mut nominators_iter = T::SortedListProvider::iter();
while nominators_taken < nominators_quota && nominators_seen < nominators_quota * 2 {
let nominator = match nominators_iter.next() {
@@ -705,17 +708,23 @@ impl<T: Config> Pallet<T> {
if let Some(Nominations { submitted_in, mut targets, suppressed: _ }) =
<Nominators<T>>::get(&nominator)
{
log!(
trace,
"fetched nominator {:?} with weight {:?}",
nominator,
weight_of(&nominator)
);
targets.retain(|stash| {
slashing_spans
.get(stash)
.map_or(true, |spans| submitted_in >= spans.last_nonzero_slash())
});
if !targets.len().is_zero() {
all_voters.push((nominator.clone(), Self::weight_of(&nominator), targets));
all_voters.push((nominator.clone(), weight_of(&nominator), targets));
nominators_taken.saturating_inc();
}
} else {
log!(error, "invalid item in `SortedListProvider`: {:?}", nominator)
log!(error, "DEFENSIVE: invalid item in `SortedListProvider`: {:?}", nominator)
}
}